]> andersk Git - moira.git/blame - gen/nfs.sh
use path to find mkcred
[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
2ce085d2 8# MR error codes the library uses:
9set MR_NOCRED = 47836470
10set MR_MKCRED = 47836474
11set MR_TARERR = 47836476
39f6c9df 12
7460e259 13set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc)
b93a8e7c 14set nonomatch
51bf07bb 15
39f6c9df 16# The file containg the information for the update
17set TARFILE=/tmp/nfs.out
18# The directory into which we will empty the tarfile
19set SRC_DIR=/tmp/nfs.dir
20
39f6c9df 21# Alert if the tarfile does not exist
22if (! -r $TARFILE) then
2ce085d2 23 exit $MR_TARERR
39f6c9df 24endif
51bf07bb 25
e46282d6 26# Create a fresh source directory
27rm -rf $SRC_DIR
28mkdir $SRC_DIR
29chmod 755 $SRC_DIR
30
2ce085d2 31# Note that since MR is going to be exported, assuming .MIT.EDU is
39f6c9df 32# incorrect. For now however, it is probably not worth the effort
33# to canonicalize the hostname, especially with the upcoming update
34# protocol redesign
35set uchost=`/bin/hostname | tr a-z A-Z`.MIT.EDU
51bf07bb 36
39f6c9df 37cd $SRC_DIR
51bf07bb 38
18eb262b 39# Just extract everything since some of what we need exists as
40# hardlinks and tar doesn't deal well with extracting them in isolation.
41tar xf $TARFILE
2ce085d2 42if ($status) exit $MR_TARERR
51bf07bb 43
39f6c9df 44foreach type (dirs quotas)
45 echo "Installing ${type}:"
46 foreach i ( ${uchost}*.${type} )
b93a8e7c 47 if (-e $i) then
48 # Convert the from the filename HOST.@dev@device.type to /dev/device
49 set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"`
50 echo ${uchost}:$dev
51 ./install_${type} $dev < $i
52 if ($status) exit $status
53 if ($type == quotas) ./zero_quotas $dev < $i
54 if ($status) exit $status
71ec1a6c 55 # save the files used here for later debugging
56 mv $i /tmp
b93a8e7c 57 endif
39f6c9df 58 end
51bf07bb 59end
60
39f6c9df 61# build new credentials files.
51bf07bb 62rm -f /usr/etc/credentials.new
39f6c9df 63cp ${uchost}.cred /usr/etc/credentials.new
2ce085d2 64if ($status) exit $MR_NOCRED
51bf07bb 65
7460e259 66mkcred /usr/etc/credentials.new
2ce085d2 67if ($status) exit $MR_MKCRED
39f6c9df 68
69# Try to install the files
70foreach e ( "" .dir .pag)
71 mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e
72end
51bf07bb 73
39f6c9df 74# If any of them didn't get installed, fail
51bf07bb 75foreach e ( "" .dir .pag)
2ce085d2 76 if (! -e /usr/etc/credentials$e) exit $MR_NOCRED
51bf07bb 77end
78
e46282d6 79
80
39f6c9df 81# cleanup
82rm -f $TARFILE
83cd $SRC_DIR/..
84rm -rf $SRC_DIR
85rm $0
86
87exit 0
This page took 0.111326 seconds and 5 git commands to generate.