2 # This script performs nfs updates on servers.
4 # The following exit codes are defined and MUST BE CONSISTENT with the
5 # SMS error codes the library uses:
6 set SMS_NOCRED 47836470
7 set SMS_MKCRED 47836474
8 set SMS_TARERR 47836476
10 set path=(/etc /bin /usr/bin /usr/etc)
12 # The file containg the information for the update
13 set TARFILE=/tmp/nfs.out
14 # The directory into which we will empty the tarfile
15 set SRC_DIR=/tmp/nfs.dir
17 # Create a frash source directory
22 # Alert if the tarfile does not exist
23 if (! -r $TARFILE) then
27 # Note that since SMS is going to be exported, assuming .MIT.EDU is
28 # incorrect. For now however, it is probably not worth the effort
29 # to canonicalize the hostname, especially with the upcoming update
31 set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU
35 # Only files starting with $uchost, install_, and list- are needed.
36 # The files starting with list- are needed because the credentials
37 # files are hard links to them. Tar will fail if they are not extracted.
38 foreach file (`/bin/tar tf $TARFILE | awk '{print $1}'`)
39 if (($file =~ ./${uchost}*) || \
40 ($file =~ ./install_*) || \
41 ($file =~ ./list-*)) then
43 if ($status) exit SMS_TARERR
47 foreach type (dirs quotas)
48 echo "Installing ${type}:"
49 foreach i ( ${uchost}*.${type} )
50 # Convert the from the filename HOST.@dev@device.type to /dev/device
51 set dev=`echo $i | sed 's;.${type};;' | sed 's;${uchost}.;;' | \
54 ./install_${type} $dev < $i
55 if ($status) exit $status
59 # build new credentials files.
60 rm -f /usr/etc/credentials.new
61 cp ${uchost}.cred /usr/etc/credentials.new
62 if ($status) exit SMS_SMS_NOCRED
64 /usr/etc/mkcred /usr/etc/credentials.new
65 if ($status) exit SMS_MKCRED
67 # Try to install the files
68 foreach e ( "" .dir .pag)
69 mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e
72 # If any of them didn't get installed, fail
73 foreach e ( "" .dir .pag)
74 if (! -e /usr/etc/credentials$e) exit SMS_NOCRED