]>
Commit | Line | Data |
---|---|---|
51bf07bb | 1 | #!/bin/csh -f |
39f6c9df | 2 | # This script performs nfs updates on servers. |
3 | ||
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 | |
9 | ||
10 | set path=(/etc /bin /usr/bin /usr/etc) | |
51bf07bb | 11 | |
39f6c9df | 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 | |
16 | ||
17 | # Create a frash source directory | |
18 | rm -f $SRC_DIR | |
19 | mkdir $SRC_DIR | |
20 | chmod 755 $SRC_DIR | |
21 | ||
22 | # Alert if the tarfile does not exist | |
23 | if (! -r $TARFILE) then | |
24 | exit SMS_TARERR | |
25 | endif | |
51bf07bb | 26 | |
39f6c9df | 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 | |
30 | # protocol redesign | |
31 | set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU | |
51bf07bb | 32 | |
39f6c9df | 33 | cd $SRC_DIR |
51bf07bb | 34 | |
39f6c9df | 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 | |
42 | tar xf $TARFILE $file | |
43 | if ($status) exit SMS_TARERR | |
44 | endif | |
45 | end | |
51bf07bb | 46 | |
39f6c9df | 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}.;;' | \ | |
52 | sed 's;@;/;g'` | |
53 | echo ${uchost}:$dev | |
54 | ./install_${type} $dev < $i | |
55 | if ($status) exit $status | |
56 | end | |
51bf07bb | 57 | end |
58 | ||
39f6c9df | 59 | # build new credentials files. |
51bf07bb | 60 | rm -f /usr/etc/credentials.new |
39f6c9df | 61 | cp ${uchost}.cred /usr/etc/credentials.new |
62 | if ($status) exit SMS_SMS_NOCRED | |
51bf07bb | 63 | |
64 | /usr/etc/mkcred /usr/etc/credentials.new | |
39f6c9df | 65 | if ($status) exit SMS_MKCRED |
66 | ||
67 | # Try to install the files | |
68 | foreach e ( "" .dir .pag) | |
69 | mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e | |
70 | end | |
51bf07bb | 71 | |
39f6c9df | 72 | # If any of them didn't get installed, fail |
51bf07bb | 73 | foreach e ( "" .dir .pag) |
39f6c9df | 74 | if (! -e /usr/etc/credentials$e) exit SMS_NOCRED |
51bf07bb | 75 | end |
76 | ||
39f6c9df | 77 | # cleanup |
78 | rm -f $TARFILE | |
79 | cd $SRC_DIR/.. | |
80 | rm -rf $SRC_DIR | |
81 | rm $0 | |
82 | ||
83 | exit 0 | |
84 | ||
85 | # | |
86 | # $Source$ | |
87 | # $Header$ | |
88 | # |