]> andersk Git - moira.git/blame - gen/nfs.sh
Command line printer manipulation client, and build goo.
[moira.git] / gen / nfs.sh
CommitLineData
f4f32185 1#!/bin/sh
39f6c9df 2# This script performs nfs updates on servers.
e46282d6 3#
568331c6 4# $Header$
39f6c9df 5
f4f32185 6# redirect output, and find the credentials directory (not robust, but
7# works for now).
8if [ -d /var/athena ] && [ -w /var/athena ]; then
f4f32185 9 exec >/var/athena/moira_update.log 2>&1
10else
f4f32185 11 exec >/tmp/moira_update.log 2>&1
12fi
13
a8ceae19 14creddir=/var/athena
15if [ -d /usr/etc ]; then
16 creddir=/usr/etc
17fi
18
f4f32185 19# The following exit codes are defined and MUST BE CONSISTENT with the
59ec8dae 20# error codes the library uses:
f4f32185 21MR_NOCRED=47836470
22MR_MISSINGFILE=47836473
23MR_MKCRED=47836474
24MR_TARERR=47836476
25
26PATH=/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc
27
28TARFILE=/var/tmp/nfs.out
29SRCDIR=/var/tmp/nfs.dir
30
31uchost=`hostname | tr '[a-z]' '[A-Z]'`
32echo $uchost | egrep -e "\." >/dev/null
33if [ $? != 0 ]; then
34 uchost=$uchost.MIT.EDU
35fi
36
37# Alert if the tar file does not exist
38test -r $TARFILE || exit $MR_MISSINGFILE
39
40# Make a temporary directory to unpack the tar file into
41rm -rf $SRCDIR
42mkdir $SRCDIR || exit $MR_MKCRED
43cd $SRCDIR || exit $MR_MKCRED
44
45# Extract everything
46tar xpf $TARFILE || exit $MR_TARERR
47
48for type in dirs quotas; do
49 echo "Installing ${type}:"
50 for i in $uchost.$type; do
51 if [ -f $i ]; then
52 # Convert from the filename HOST.@dev@device.type to /dev/device
53 dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | \
54 sed "s,@,/,g"`
55 echo ${uchost}:$dev
56 ./install_${type} $dev < $i
57 if [ $? != 0 ]; then
58 exit $MR_NOCRED
59 fi
60 if [ ${type} = "quotas" ]; then
61 ./zero_quotas $dev < $i
62 if [ $? != 0 ]; then
63 exit $MR_NOCRED
64 fi
65 fi
66 mv -f $i /var/tmp
67 fi
68 done
69done
70
71# build new credentials files
fec3cea4 72rm -f $creddir/credentials.new
73cp ${uchost}.cred $creddir/credentials.new
f4f32185 74if [ $? != 0 ]; then
75 exit $MR_NOCRED
76fi
77if [ -s $creddir/credentials.local ]; then
fec3cea4 78 cat $creddir/credentials.local >> $creddir/credentials.new
f4f32185 79fi
51bf07bb 80
f4f32185 81# After this point, if /tmp gets cleared out by reactivate (which happens
82# on a combined server/workstation), we don't care.
fec3cea4 83mkcred $creddir/credentials.new
f4f32185 84if [ $? != 0 ]; then
85 exit $MR_MKCRED
86fi
39f6c9df 87
88# Try to install the files
f4f32185 89for e in "" .dir .pag; do
90 mv -f $creddir/credentials.new$e $creddir/credentials$e
91done
51bf07bb 92
39f6c9df 93# If any of them didn't get installed, fail
f4f32185 94for e in "" .dir .pag; do
95 if [ ! -f $creddir/credentials$e ]; then
96 exit $MR_NOCRED
97 fi
98done
e46282d6 99
39f6c9df 100# cleanup
f4f32185 101cd /
102rm -rf $SRCDIR
103test -f $TARFILE && rm -f $TARFILE
104test -f $0 && rm -f $0
39f6c9df 105
106exit 0
This page took 0.138792 seconds and 5 git commands to generate.