]>
Commit | Line | Data |
---|---|---|
f4f32185 | 1 | #!/bin/sh |
39f6c9df | 2 | # This script performs nfs updates on servers. |
e46282d6 | 3 | # |
568331c6 | 4 | # $Header$ |
39f6c9df | 5 | |
f4f32185 | 6 | # redirect output, and find the credentials directory (not robust, but |
7 | # works for now). | |
8 | if [ -d /var/athena ] && [ -w /var/athena ]; then | |
9 | creddir=/var/athena | |
10 | exec >/var/athena/moira_update.log 2>&1 | |
11 | else | |
12 | creddir=/usr/etc | |
13 | exec >/tmp/moira_update.log 2>&1 | |
14 | fi | |
15 | ||
16 | # The following exit codes are defined and MUST BE CONSISTENT with the | |
59ec8dae | 17 | # error codes the library uses: |
f4f32185 | 18 | MR_NOCRED=47836470 |
19 | MR_MISSINGFILE=47836473 | |
20 | MR_MKCRED=47836474 | |
21 | MR_TARERR=47836476 | |
22 | ||
23 | PATH=/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc | |
24 | ||
25 | TARFILE=/var/tmp/nfs.out | |
26 | SRCDIR=/var/tmp/nfs.dir | |
27 | ||
28 | uchost=`hostname | tr '[a-z]' '[A-Z]'` | |
29 | echo $uchost | egrep -e "\." >/dev/null | |
30 | if [ $? != 0 ]; then | |
31 | uchost=$uchost.MIT.EDU | |
32 | fi | |
33 | ||
34 | # Alert if the tar file does not exist | |
35 | test -r $TARFILE || exit $MR_MISSINGFILE | |
36 | ||
37 | # Make a temporary directory to unpack the tar file into | |
38 | rm -rf $SRCDIR | |
39 | mkdir $SRCDIR || exit $MR_MKCRED | |
40 | cd $SRCDIR || exit $MR_MKCRED | |
41 | ||
42 | # Extract everything | |
43 | tar xpf $TARFILE || exit $MR_TARERR | |
44 | ||
45 | for type in dirs quotas; do | |
46 | echo "Installing ${type}:" | |
47 | for i in $uchost.$type; do | |
48 | if [ -f $i ]; then | |
49 | # Convert from the filename HOST.@dev@device.type to /dev/device | |
50 | dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | \ | |
51 | sed "s,@,/,g"` | |
52 | echo ${uchost}:$dev | |
53 | ./install_${type} $dev < $i | |
54 | if [ $? != 0 ]; then | |
55 | exit $MR_NOCRED | |
56 | fi | |
57 | if [ ${type} = "quotas" ]; then | |
58 | ./zero_quotas $dev < $i | |
59 | if [ $? != 0 ]; then | |
60 | exit $MR_NOCRED | |
61 | fi | |
62 | fi | |
63 | mv -f $i /var/tmp | |
64 | fi | |
65 | done | |
66 | done | |
67 | ||
68 | # build new credentials files | |
fec3cea4 | 69 | rm -f $creddir/credentials.new |
70 | cp ${uchost}.cred $creddir/credentials.new | |
f4f32185 | 71 | if [ $? != 0 ]; then |
72 | exit $MR_NOCRED | |
73 | fi | |
74 | if [ -s $creddir/credentials.local ]; then | |
fec3cea4 | 75 | cat $creddir/credentials.local >> $creddir/credentials.new |
f4f32185 | 76 | fi |
51bf07bb | 77 | |
f4f32185 | 78 | # After this point, if /tmp gets cleared out by reactivate (which happens |
79 | # on a combined server/workstation), we don't care. | |
fec3cea4 | 80 | mkcred $creddir/credentials.new |
f4f32185 | 81 | if [ $? != 0 ]; then |
82 | exit $MR_MKCRED | |
83 | fi | |
39f6c9df | 84 | |
85 | # Try to install the files | |
f4f32185 | 86 | for e in "" .dir .pag; do |
87 | mv -f $creddir/credentials.new$e $creddir/credentials$e | |
88 | done | |
51bf07bb | 89 | |
39f6c9df | 90 | # If any of them didn't get installed, fail |
f4f32185 | 91 | for e in "" .dir .pag; do |
92 | if [ ! -f $creddir/credentials$e ]; then | |
93 | exit $MR_NOCRED | |
94 | fi | |
95 | done | |
e46282d6 | 96 | |
39f6c9df | 97 | # cleanup |
f4f32185 | 98 | cd / |
99 | rm -rf $SRCDIR | |
100 | test -f $TARFILE && rm -f $TARFILE | |
101 | test -f $0 && rm -f $0 | |
39f6c9df | 102 | |
103 | exit 0 |