]> andersk Git - moira.git/blame_incremental - gen/nfs.sh
added fsgroup
[moira.git] / gen / nfs.sh
... / ...
CommitLineData
1#!/bin/csh -f
2# This script performs nfs updates on servers.
3#
4# $Source$
5echo '$Header$'
6
7# The following exit codes are defined and MUST BE CONSISTENT with the
8# SMS error codes the library uses:
9set SMS_NOCRED = 47836470
10set SMS_MKCRED = 47836474
11set SMS_TARERR = 47836476
12
13set path=(/etc /bin /usr/bin /usr/etc)
14
15# The file containg the information for the update
16set TARFILE=/tmp/nfs.out
17# The directory into which we will empty the tarfile
18set SRC_DIR=/tmp/nfs.dir
19
20# Alert if the tarfile does not exist
21if (! -r $TARFILE) then
22 exit $SMS_TARERR
23endif
24
25# Create a fresh source directory
26rm -rf $SRC_DIR
27mkdir $SRC_DIR
28chmod 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
34set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU
35
36cd $SRC_DIR
37
38# Only files starting with $uchost, install_, and list- are needed.
39# The files starting with list- are needed because the credentials
40# files are hard links to them. Tar will fail if they are not extracted.
41foreach file (`/bin/tar tf $TARFILE | awk '{print $1}'`)
42 if (($file =~ ./${uchost}*) || \
43 ($file =~ ./install_*) || \
44 ($file =~ ./list-*)) then
45 tar xf $TARFILE $file
46 if ($status) exit $SMS_TARERR
47 endif
48end
49
50foreach type (dirs quotas)
51 echo "Installing ${type}:"
52 foreach i ( ${uchost}*.${type} )
53 # Convert the from the filename HOST.@dev@device.type to /dev/device
54 set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"`
55 echo ${uchost}:$dev
56 ./install_${type} $dev < $i
57 if ($status) exit $status
58 end
59end
60
61# build new credentials files.
62rm -f /usr/etc/credentials.new
63cp ${uchost}.cred /usr/etc/credentials.new
64if ($status) exit $SMS_NOCRED
65
66/usr/etc/mkcred /usr/etc/credentials.new
67if ($status) exit $SMS_MKCRED
68
69# Try to install the files
70foreach e ( "" .dir .pag)
71 mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e
72end
73
74# If any of them didn't get installed, fail
75foreach e ( "" .dir .pag)
76 if (! -e /usr/etc/credentials$e) exit $SMS_NOCRED
77end
78
79
80
81# cleanup
82rm -f $TARFILE
83cd $SRC_DIR/..
84rm -rf $SRC_DIR
85rm $0
86
87exit 0
This page took 0.039882 seconds and 5 git commands to generate.