]>
Commit | Line | Data |
---|---|---|
51bf07bb | 1 | #!/bin/csh -f |
39f6c9df | 2 | # This script performs nfs updates on servers. |
e46282d6 | 3 | # |
4 | # $Source$ | |
5 | echo '$Header$' | |
39f6c9df | 6 | |
7 | # The following exit codes are defined and MUST BE CONSISTENT with the | |
8 | # SMS error codes the library uses: | |
e46282d6 | 9 | set SMS_NOCRED = 47836470 |
10 | set SMS_MKCRED = 47836474 | |
11 | set SMS_TARERR = 47836476 | |
39f6c9df | 12 | |
13 | set path=(/etc /bin /usr/bin /usr/etc) | |
51bf07bb | 14 | |
39f6c9df | 15 | # The file containg the information for the update |
16 | set TARFILE=/tmp/nfs.out | |
17 | # The directory into which we will empty the tarfile | |
18 | set SRC_DIR=/tmp/nfs.dir | |
19 | ||
39f6c9df | 20 | # Alert if the tarfile does not exist |
21 | if (! -r $TARFILE) then | |
de9119eb | 22 | exit $SMS_TARERR |
39f6c9df | 23 | endif |
51bf07bb | 24 | |
e46282d6 | 25 | # Create a fresh source directory |
26 | rm -rf $SRC_DIR | |
27 | mkdir $SRC_DIR | |
28 | chmod 755 $SRC_DIR | |
29 | ||
39f6c9df | 30 | # Note that since SMS is going to be exported, assuming .MIT.EDU is |
31 | # incorrect. For now however, it is probably not worth the effort | |
32 | # to canonicalize the hostname, especially with the upcoming update | |
33 | # protocol redesign | |
34 | set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU | |
51bf07bb | 35 | |
39f6c9df | 36 | cd $SRC_DIR |
51bf07bb | 37 | |
39f6c9df | 38 | # Only files starting with $uchost, install_, and list- are needed. |
39 | # The files starting with list- are needed because the credentials | |
40 | # files are hard links to them. Tar will fail if they are not extracted. | |
41 | foreach file (`/bin/tar tf $TARFILE | awk '{print $1}'`) | |
42 | if (($file =~ ./${uchost}*) || \ | |
43 | ($file =~ ./install_*) || \ | |
44 | ($file =~ ./list-*)) then | |
45 | tar xf $TARFILE $file | |
de9119eb | 46 | if ($status) exit $SMS_TARERR |
39f6c9df | 47 | endif |
48 | end | |
51bf07bb | 49 | |
39f6c9df | 50 | foreach type (dirs quotas) |
51 | echo "Installing ${type}:" | |
52 | foreach i ( ${uchost}*.${type} ) | |
53 | # Convert the from the filename HOST.@dev@device.type to /dev/device | |
e46282d6 | 54 | set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"` |
39f6c9df | 55 | echo ${uchost}:$dev |
56 | ./install_${type} $dev < $i | |
e46282d6 | 57 | if ($status) exit $status |
39f6c9df | 58 | end |
51bf07bb | 59 | end |
60 | ||
39f6c9df | 61 | # build new credentials files. |
51bf07bb | 62 | rm -f /usr/etc/credentials.new |
39f6c9df | 63 | cp ${uchost}.cred /usr/etc/credentials.new |
e46282d6 | 64 | if ($status) exit $SMS_NOCRED |
51bf07bb | 65 | |
66 | /usr/etc/mkcred /usr/etc/credentials.new | |
de9119eb | 67 | if ($status) exit $SMS_MKCRED |
39f6c9df | 68 | |
69 | # Try to install the files | |
70 | foreach e ( "" .dir .pag) | |
71 | mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e | |
72 | end | |
51bf07bb | 73 | |
39f6c9df | 74 | # If any of them didn't get installed, fail |
51bf07bb | 75 | foreach e ( "" .dir .pag) |
de9119eb | 76 | if (! -e /usr/etc/credentials$e) exit $SMS_NOCRED |
51bf07bb | 77 | end |
78 | ||
e46282d6 | 79 | |
80 | ||
39f6c9df | 81 | # cleanup |
82 | rm -f $TARFILE | |
83 | cd $SRC_DIR/.. | |
84 | rm -rf $SRC_DIR | |
85 | rm $0 | |
86 | ||
87 | exit 0 |