source: trunk/third/moira/gen/nfs.sh @ 23740

Revision 23740, 2.5 KB checked in by broder, 16 years ago (diff)
In moira: * New CVS snapshot (Trac: #195) * Drop patches that have been incorporated upstream. * Update to build without krb4 on systems that no longer have it. This doesn't build yet on squeeze, which lacks a krb4 library, but I'm committing now before I start hacking away at a patch to fix that.
Line 
1#!/bin/sh
2# This script performs nfs updates on servers.
3#
4# $Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/nfs.sh,v 1.25 2000-05-25 05:43:22 zacheiss Exp $
5
6# redirect output, and find the credentials directory (not robust, but
7# works for now).
8if [ -d /var/athena ] && [ -w /var/athena ]; then
9    exec >/var/athena/moira_update.log 2>&1
10else
11    exec >/tmp/moira_update.log 2>&1
12fi
13
14creddir=/var/athena
15if [ -d /usr/etc ]; then
16    creddir=/usr/etc
17fi
18
19# The following exit codes are defined and MUST BE CONSISTENT with the
20# error codes the library uses:
21MR_NOCRED=47836470
22MR_MISSINGFILE=47836473
23MR_MKCRED=47836474
24MR_TARERR=47836476
25
26PATH=/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc
27
28TARFILE=/var/tmp/nfs.out
29SRCDIR=/var/tmp/nfs.dir
30
31uchost=`hostname | tr '[a-z]' '[A-Z]'`
32echo $uchost | egrep -e "\." >/dev/null
33if [ $? != 0 ]; then
34    uchost=$uchost.MIT.EDU
35fi
36
37# Alert if the tar file does not exist
38test -r $TARFILE || exit $MR_MISSINGFILE
39
40# Make a temporary directory to unpack the tar file into
41rm -rf $SRCDIR
42mkdir $SRCDIR || exit $MR_MKCRED
43cd $SRCDIR || exit $MR_MKCRED
44
45# Extract everything
46tar xpf $TARFILE || exit $MR_TARERR
47
48for type in dirs quotas; do
49    echo "Installing ${type}:"
50    for i in $uchost.$type; do
51        if [ -f $i ]; then
52            # Convert from the filename HOST.@dev@device.type to /dev/device
53            dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | \
54                sed "s,@,/,g"`
55            echo ${uchost}:$dev
56            ./install_${type} $dev < $i
57            if [ $? != 0 ]; then
58                exit $MR_NOCRED
59            fi
60            if [ ${type} = "quotas" ]; then
61                ./zero_quotas $dev < $i
62                if [ $? != 0 ]; then
63                    exit $MR_NOCRED
64                fi
65            fi
66            mv -f $i /var/tmp
67        fi
68    done
69done
70   
71# build new credentials files
72rm -f $creddir/credentials.new
73cp ${uchost}.cred $creddir/credentials.new
74if [ $? != 0 ]; then
75    exit $MR_NOCRED
76fi
77if [ -s $creddir/credentials.local ]; then
78    cat $creddir/credentials.local >> $creddir/credentials.new
79fi
80
81# After this point, if /tmp gets cleared out by reactivate (which happens
82# on a combined server/workstation), we don't care.
83mkcred $creddir/credentials.new
84if [ $? != 0 ]; then
85    exit $MR_MKCRED
86fi
87
88# Try to install the files
89for e in "" .dir .pag; do
90    mv -f $creddir/credentials.new$e $creddir/credentials$e
91done
92
93# If any of them didn't get installed, fail
94for e in "" .dir .pag; do
95    if [ ! -f $creddir/credentials$e ]; then
96        exit $MR_NOCRED
97    fi
98done
99
100# cleanup
101cd /
102rm -rf $SRCDIR
103test -f $TARFILE && rm -f $TARFILE
104test -f $0 && rm -f $0
105
106exit 0
Note: See TracBrowser for help on using the repository browser.