]> andersk Git - moira.git/blame - gen/nfs.sh
fix list extraction problems
[moira.git] / gen / nfs.sh
CommitLineData
51bf07bb 1#!/bin/csh -f
39f6c9df 2# This script performs nfs updates on servers.
e46282d6 3#
4# $Source$
5echo '$Header$'
39f6c9df 6
7# The following exit codes are defined and MUST BE CONSISTENT with the
8# SMS error codes the library uses:
e46282d6 9set SMS_NOCRED = 47836470
10set SMS_MKCRED = 47836474
11set SMS_TARERR = 47836476
39f6c9df 12
13set path=(/etc /bin /usr/bin /usr/etc)
51bf07bb 14
39f6c9df 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
39f6c9df 20# Alert if the tarfile does not exist
21if (! -r $TARFILE) then
de9119eb 22 exit $SMS_TARERR
39f6c9df 23endif
51bf07bb 24
e46282d6 25# Create a fresh source directory
26rm -rf $SRC_DIR
27mkdir $SRC_DIR
28chmod 755 $SRC_DIR
29
39f6c9df 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
51bf07bb 35
39f6c9df 36cd $SRC_DIR
51bf07bb 37
18eb262b 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.
40tar xf $TARFILE
41if ($status) exit $SMS_TARERR
51bf07bb 42
39f6c9df 43foreach 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
e46282d6 47 set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"`
39f6c9df 48 echo ${uchost}:$dev
49 ./install_${type} $dev < $i
e46282d6 50 if ($status) exit $status
39f6c9df 51 end
51bf07bb 52end
53
39f6c9df 54# build new credentials files.
51bf07bb 55rm -f /usr/etc/credentials.new
39f6c9df 56cp ${uchost}.cred /usr/etc/credentials.new
e46282d6 57if ($status) exit $SMS_NOCRED
51bf07bb 58
59/usr/etc/mkcred /usr/etc/credentials.new
de9119eb 60if ($status) exit $SMS_MKCRED
39f6c9df 61
62# Try to install the files
63foreach e ( "" .dir .pag)
64 mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e
65end
51bf07bb 66
39f6c9df 67# If any of them didn't get installed, fail
51bf07bb 68foreach e ( "" .dir .pag)
de9119eb 69 if (! -e /usr/etc/credentials$e) exit $SMS_NOCRED
51bf07bb 70end
71
e46282d6 72
73
39f6c9df 74# cleanup
75rm -f $TARFILE
76cd $SRC_DIR/..
77rm -rf $SRC_DIR
78rm $0
79
80exit 0
This page took 0.064245 seconds and 5 git commands to generate.