]> andersk Git - moira.git/blob - gen/nfs.sh
update for 8.3 (oops)
[moira.git] / gen / nfs.sh
1 #!/bin/csh -f
2 # This script performs nfs updates on servers.
3 #
4 # $Header$
5
6 # The following exit codes are defined and MUST BE CONSISTENT with the
7 # error codes the library uses:
8 set MR_NOCRED = 47836470
9 set MR_MKCRED = 47836474
10 set MR_TARERR = 47836476
11
12 set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc)
13 set nonomatch
14
15 # The file containg the information for the update
16 set TARFILE=/var/tmp/nfs.out
17 # The directory into which we will empty the tarfile
18 set SRC_DIR=/var/tmp/nfs.dir
19
20 # Alert if the tarfile does not exist
21 if (! -r $TARFILE) then
22    exit $MR_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 set uchost=`hostname | tr '[a-z]' '[A-Z]'`
31 if ($uchost !~ *.*) then
32     set uchost=$uchost.MIT.EDU
33 endif
34
35 cd $SRC_DIR
36
37 # Just extract everything since some of what we need exists as
38 # hardlinks and tar doesn't deal well with extracting them in isolation.
39 tar xf $TARFILE
40 if ($status) exit $MR_TARERR
41
42 foreach type (dirs quotas)
43    echo "Installing ${type}:"
44    foreach i ( ${uchost}*.${type} )
45      if (-e $i) then
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         if ($type == quotas) ./zero_quotas $dev < $i
52         if ($status) exit $status
53         # save the files used here for later debugging
54         mv $i /var/tmp
55      endif
56    end
57 end
58
59 # find credentials directory (not robust, but works for the current
60 # situation)
61 set creddir = /var/athena
62 if (-d /usr/etc) then
63     set creddir = /usr/etc
64 endif
65
66 # build new credentials files.
67 rm -f $creddir/credentials.new
68 cp ${uchost}.cred $creddir/credentials.new
69 if ($status) exit $MR_NOCRED
70 if (-e $creddir/credentials.local) then
71     cat $creddir/credentials.local >> $creddir/credentials.new
72 endif
73
74 # After this point, if /tmp gets cleared out by reactivate (which
75 # happens on a combined server/workstation) we don't care.
76 mkcred $creddir/credentials.new
77 if ($status) exit $MR_MKCRED
78
79 # Try to install the files
80 foreach e ( "" .dir .pag)
81    mv -f $creddir/credentials.new$e $creddir/credentials$e
82 end
83
84 # If any of them didn't get installed, fail
85 foreach e ( "" .dir .pag)
86    if (! -e $creddir/credentials$e) exit $MR_NOCRED
87 end
88
89
90
91 # cleanup
92 if ( -f $TARFILE ) rm -f $TARFILE
93 if ( -d $SRC_DIR ) then
94   cd $SRC_DIR/..
95   rm -rf $SRC_DIR
96 endif
97 if ( -f $0 ) rm -r $0
98
99 exit 0
This page took 0.122841 seconds and 5 git commands to generate.