]> andersk Git - moira.git/blame - gen/nfs.sh
Hopefully tr will work correctly on all platforms now...
[moira.git] / gen / nfs.sh
CommitLineData
51bf07bb 1#!/bin/csh -f
39f6c9df 2# This script performs nfs updates on servers.
e46282d6 3#
568331c6 4# $Header$
39f6c9df 5
6# The following exit codes are defined and MUST BE CONSISTENT with the
2ce085d2 7# MR error codes the library uses:
8set MR_NOCRED = 47836470
9set MR_MKCRED = 47836474
10set MR_TARERR = 47836476
39f6c9df 11
7460e259 12set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc)
b93a8e7c 13set nonomatch
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
2ce085d2 22 exit $MR_TARERR
39f6c9df 23endif
51bf07bb 24
e46282d6 25# Create a fresh source directory
26rm -rf $SRC_DIR
27mkdir $SRC_DIR
28chmod 755 $SRC_DIR
29
2ce085d2 30# Note that since MR is going to be exported, assuming .MIT.EDU is
39f6c9df 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
caf23b46 34set uchost=`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
2ce085d2 41if ($status) exit $MR_TARERR
51bf07bb 42
39f6c9df 43foreach type (dirs quotas)
44 echo "Installing ${type}:"
45 foreach i ( ${uchost}*.${type} )
b93a8e7c 46 if (-e $i) then
47 # Convert the from the filename HOST.@dev@device.type to /dev/device
48 set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"`
49 echo ${uchost}:$dev
50 ./install_${type} $dev < $i
51 if ($status) exit $status
52 if ($type == quotas) ./zero_quotas $dev < $i
53 if ($status) exit $status
71ec1a6c 54 # save the files used here for later debugging
55 mv $i /tmp
b93a8e7c 56 endif
39f6c9df 57 end
51bf07bb 58end
59
39f6c9df 60# build new credentials files.
51bf07bb 61rm -f /usr/etc/credentials.new
39f6c9df 62cp ${uchost}.cred /usr/etc/credentials.new
2ce085d2 63if ($status) exit $MR_NOCRED
51bf07bb 64
1f2d6eca 65# After this point, if /tmp gets cleared out by reactivate (which
66# happens on a combined server/workstation) we don't care.
67
7460e259 68mkcred /usr/etc/credentials.new
2ce085d2 69if ($status) exit $MR_MKCRED
39f6c9df 70
71# Try to install the files
72foreach e ( "" .dir .pag)
73 mv -f /usr/etc/credentials.new$e /usr/etc/credentials$e
74end
51bf07bb 75
39f6c9df 76# If any of them didn't get installed, fail
51bf07bb 77foreach e ( "" .dir .pag)
2ce085d2 78 if (! -e /usr/etc/credentials$e) exit $MR_NOCRED
51bf07bb 79end
80
e46282d6 81
82
39f6c9df 83# cleanup
1f2d6eca 84 if [ -f $TARFILE ] ; then rm -f $TARFILE ; fi
85 if [ -d $SRC_DIR ] ; then cd $SRC_DIR/.. ; rm -rf $SRC_DIR ; fi
86 if [ -f $0 ] ; then rm -r $0 ; fi
87fi
39f6c9df 88
89exit 0
This page took 0.108468 seconds and 5 git commands to generate.