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