2 # This script performs nfs updates on servers.
6 # redirect output, and find the credentials directory (not robust, but
8 if [ -d /var/athena ] && [ -w /var/athena ]; then
9 exec >/var/athena/moira_update.log 2>&1
11 exec >/tmp/moira_update.log 2>&1
15 if [ -d /usr/etc ]; then
19 # The following exit codes are defined and MUST BE CONSISTENT with the
20 # error codes the library uses:
22 MR_MISSINGFILE=47836473
26 PATH=/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc
28 TARFILE=/var/tmp/nfs.out
29 SRCDIR=/var/tmp/nfs.dir
31 uchost=`hostname | tr '[a-z]' '[A-Z]'`
32 echo $uchost | egrep -e "\." >/dev/null
34 uchost=$uchost.MIT.EDU
37 # Alert if the tar file does not exist
38 test -r $TARFILE || exit $MR_MISSINGFILE
40 # Make a temporary directory to unpack the tar file into
42 mkdir $SRCDIR || exit $MR_MKCRED
43 cd $SRCDIR || exit $MR_MKCRED
46 tar xpf $TARFILE || exit $MR_TARERR
48 for type in dirs quotas; do
49 echo "Installing ${type}:"
50 for i in $uchost.$type; do
52 # Convert from the filename HOST.@dev@device.type to /dev/device
53 dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | \
56 ./install_${type} $dev < $i
60 if [ ${type} = "quotas" ]; then
61 ./zero_quotas $dev < $i
71 # build new credentials files
72 rm -f $creddir/credentials.new
73 cp ${uchost}.cred $creddir/credentials.new
77 if [ -s $creddir/credentials.local ]; then
78 cat $creddir/credentials.local >> $creddir/credentials.new
81 # After this point, if /tmp gets cleared out by reactivate (which happens
82 # on a combined server/workstation), we don't care.
83 mkcred $creddir/credentials.new
88 # Try to install the files
89 for e in "" .dir .pag; do
90 mv -f $creddir/credentials.new$e $creddir/credentials$e
93 # If any of them didn't get installed, fail
94 for e in "" .dir .pag; do
95 if [ ! -f $creddir/credentials$e ]; then
103 test -f $TARFILE && rm -f $TARFILE
104 test -f $0 && rm -f $0