]>
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 | |
2ce085d2 | 8 | # MR error codes the library uses: |
9 | set MR_NOCRED = 47836470 | |
10 | set MR_MKCRED = 47836474 | |
11 | set MR_TARERR = 47836476 | |
39f6c9df | 12 | |
7460e259 | 13 | set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc) |
b93a8e7c | 14 | set nonomatch |
51bf07bb | 15 | |
39f6c9df | 16 | # The file containg the information for the update |
17 | set TARFILE=/tmp/nfs.out | |
18 | # The directory into which we will empty the tarfile | |
19 | set SRC_DIR=/tmp/nfs.dir | |
20 | ||
39f6c9df | 21 | # Alert if the tarfile does not exist |
22 | if (! -r $TARFILE) then | |
2ce085d2 | 23 | exit $MR_TARERR |
39f6c9df | 24 | endif |
51bf07bb | 25 | |
e46282d6 | 26 | # Create a fresh source directory |
27 | rm -rf $SRC_DIR | |
28 | mkdir $SRC_DIR | |
29 | chmod 755 $SRC_DIR | |
30 | ||
2ce085d2 | 31 | # Note that since MR is going to be exported, assuming .MIT.EDU is |
39f6c9df | 32 | # incorrect. For now however, it is probably not worth the effort |
33 | # to canonicalize the hostname, especially with the upcoming update | |
34 | # protocol redesign | |
35 | set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU | |
51bf07bb | 36 | |
39f6c9df | 37 | cd $SRC_DIR |
51bf07bb | 38 | |
18eb262b | 39 | # Just extract everything since some of what we need exists as |
40 | # hardlinks and tar doesn't deal well with extracting them in isolation. | |
41 | tar xf $TARFILE | |
2ce085d2 | 42 | if ($status) exit $MR_TARERR |
51bf07bb | 43 | |
39f6c9df | 44 | foreach type (dirs quotas) |
45 | echo "Installing ${type}:" | |
46 | foreach i ( ${uchost}*.${type} ) | |
b93a8e7c | 47 | if (-e $i) then |
48 | # Convert the from the filename HOST.@dev@device.type to /dev/device | |
49 | set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"` | |
50 | echo ${uchost}:$dev | |
51 | ./install_${type} $dev < $i | |
52 | if ($status) exit $status | |
53 | if ($type == quotas) ./zero_quotas $dev < $i | |
54 | if ($status) exit $status | |
71ec1a6c | 55 | # save the files used here for later debugging |
56 | mv $i /tmp | |
b93a8e7c | 57 | endif |
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 |
2ce085d2 | 64 | if ($status) exit $MR_NOCRED |
51bf07bb | 65 | |
7460e259 | 66 | mkcred /usr/etc/credentials.new |
2ce085d2 | 67 | if ($status) exit $MR_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) |
2ce085d2 | 76 | if (! -e /usr/etc/credentials$e) exit $MR_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 |