]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/csh -f | |
2 | # This script performs nfs updates on servers. | |
3 | # | |
4 | # $Source$ | |
5 | echo '$Header$' | |
6 | ||
7 | # The following exit codes are defined and MUST BE CONSISTENT with the | |
8 | # SMS error codes the library uses: | |
9 | set SMS_NOCRED = 47836470 | |
10 | set SMS_MKCRED = 47836474 | |
11 | set SMS_TARERR = 47836476 | |
12 | ||
13 | set path=(/etc /bin /usr/bin /usr/etc) | |
14 | ||
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 | ||
20 | # Alert if the tarfile does not exist | |
21 | if (! -r $TARFILE) then | |
22 | exit $SMS_TARERR | |
23 | endif | |
24 | ||
25 | # Create a fresh source directory | |
26 | rm -rf $SRC_DIR | |
27 | mkdir $SRC_DIR | |
28 | chmod 755 $SRC_DIR | |
29 | ||
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 | |
35 | ||
36 | cd $SRC_DIR | |
37 | ||
38 | # Just extract everything since some of what we need exists as | |
39 | # hardlinks and tar doesn't deal well with extracting them in isolation. | |
40 | tar xf $TARFILE | |
41 | if ($status) exit $SMS_TARERR | |
42 | ||
43 | foreach type (dirs quotas) | |
44 | echo "Installing ${type}:" | |
45 | foreach i ( ${uchost}*.${type} ) | |
46 | # Convert the from the filename HOST.@dev@device.type to /dev/device | |
47 | set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"` | |
48 | echo ${uchost}:$dev | |
49 | ./install_${type} $dev < $i | |
50 | if ($status) exit $status | |
51 | end | |
52 | end | |
53 | ||
54 | # build new credentials files. | |
55 | rm -f /usr/etc/credentials.new | |
56 | cp ${uchost}.cred /usr/etc/credentials.new | |
57 | if ($status) exit $SMS_NOCRED | |
58 | ||
59 | /usr/etc/mkcred /usr/etc/credentials.new | |
60 | if ($status) exit $SMS_MKCRED | |
61 | ||
62 | # Try to install the files | |
63 | foreach e ( "" .dir .pag) | |
64 | mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e | |
65 | end | |
66 | ||
67 | # If any of them didn't get installed, fail | |
68 | foreach e ( "" .dir .pag) | |
69 | if (! -e /usr/etc/credentials$e) exit $SMS_NOCRED | |
70 | end | |
71 | ||
72 | ||
73 | ||
74 | # cleanup | |
75 | rm -f $TARFILE | |
76 | cd $SRC_DIR/.. | |
77 | rm -rf $SRC_DIR | |
78 | rm $0 | |
79 | ||
80 | exit 0 |