X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/18eb262b4e06b5f60fbb2744ca5d158f644351b4..refs/heads/LOCKING:/gen/nfs.sh diff --git a/gen/nfs.sh b/gen/nfs.sh index 166223a3..21c18993 100644 --- a/gen/nfs.sh +++ b/gen/nfs.sh @@ -1,16 +1,16 @@ #!/bin/csh -f # This script performs nfs updates on servers. # -# $Source$ -echo '$Header$' +# $Header$ # The following exit codes are defined and MUST BE CONSISTENT with the -# SMS error codes the library uses: -set SMS_NOCRED = 47836470 -set SMS_MKCRED = 47836474 -set SMS_TARERR = 47836476 +# MR error codes the library uses: +set MR_NOCRED = 47836470 +set MR_MKCRED = 47836474 +set MR_TARERR = 47836476 -set path=(/etc /bin /usr/bin /usr/etc) +set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc) +set nonomatch # The file containg the information for the update set TARFILE=/tmp/nfs.out @@ -19,7 +19,7 @@ set SRC_DIR=/tmp/nfs.dir # Alert if the tarfile does not exist if (! -r $TARFILE) then - exit $SMS_TARERR + exit $MR_TARERR endif # Create a fresh source directory @@ -27,37 +27,46 @@ rm -rf $SRC_DIR mkdir $SRC_DIR chmod 755 $SRC_DIR -# Note that since SMS is going to be exported, assuming .MIT.EDU is +# Note that since MR is going to be exported, assuming .MIT.EDU is # incorrect. For now however, it is probably not worth the effort # to canonicalize the hostname, especially with the upcoming update # protocol redesign -set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU +set uchost=`hostname | tr '[a-z]' '[A-Z]'`.MIT.EDU cd $SRC_DIR # Just extract everything since some of what we need exists as # hardlinks and tar doesn't deal well with extracting them in isolation. tar xf $TARFILE -if ($status) exit $SMS_TARERR +if ($status) exit $MR_TARERR foreach type (dirs quotas) echo "Installing ${type}:" foreach i ( ${uchost}*.${type} ) - # Convert the from the filename HOST.@dev@device.type to /dev/device - set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"` - echo ${uchost}:$dev - ./install_${type} $dev < $i - if ($status) exit $status + if (-e $i) then + # Convert the from the filename HOST.@dev@device.type to /dev/device + set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"` + echo ${uchost}:$dev + ./install_${type} $dev < $i + if ($status) exit $status + if ($type == quotas) ./zero_quotas $dev < $i + if ($status) exit $status + # save the files used here for later debugging + mv $i /tmp + endif end end # build new credentials files. rm -f /usr/etc/credentials.new cp ${uchost}.cred /usr/etc/credentials.new -if ($status) exit $SMS_NOCRED +if ($status) exit $MR_NOCRED -/usr/etc/mkcred /usr/etc/credentials.new -if ($status) exit $SMS_MKCRED +# After this point, if /tmp gets cleared out by reactivate (which +# happens on a combined server/workstation) we don't care. + +mkcred /usr/etc/credentials.new +if ($status) exit $MR_MKCRED # Try to install the files foreach e ( "" .dir .pag) @@ -66,15 +75,17 @@ end # If any of them didn't get installed, fail foreach e ( "" .dir .pag) - if (! -e /usr/etc/credentials$e) exit $SMS_NOCRED + if (! -e /usr/etc/credentials$e) exit $MR_NOCRED end # cleanup -rm -f $TARFILE -cd $SRC_DIR/.. -rm -rf $SRC_DIR -rm $0 +if ( -f $TARFILE ) rm -f $TARFILE +if ( -d $SRC_DIR ) then + cd $SRC_DIR/.. + rm -rf $SRC_DIR +endif +if ( -f $0 ) rm -r $0 exit 0