-foreach type (dirs quotas)
- echo "Installing ${type}:"
- foreach i ( ${uchost}*.${type} )
- if (-e $i) then
- # Convert the from the filename HOST.@dev@device.type to /dev/device
- set dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | sed "s,@,/,g"`
- echo ${uchost}:$dev
- ./install_${type} $dev < $i
- if ($status) exit $status
- if ($type == quotas) ./zero_quotas $dev < $i
- if ($status) exit $status
- # save the files used here for later debugging
- mv $i /var/tmp
- endif
- end
-end
-
-# build new credentials files.
-rm -f /usr/etc/credentials.new
-cp ${uchost}.cred /usr/etc/credentials.new
-if ($status) exit $MR_NOCRED
-if (-e /usr/etc/credentials.local) then
- cat /usr/etc/credentials.local >> /usr/etc/credentials.new
-endif
-
-# After this point, if /tmp gets cleared out by reactivate (which
-# happens on a combined server/workstation) we don't care.
-
-if ("`uname -sr`" =~ SunOS*5*) then
- mkdir /usr/etc/credtmp
- mount -F tmpfs swap /usr/etc/credtmp
- ln -s /usr/etc/credentials.new /usr/etc/credtmp/credentials.new
- mkcred /usr/etc/credtmp/credentials.new
- if ($status) then
- umount /usr/etc/credtmp
- rmdir /usr/etc/credtmp
- exit $MR_MKCRED
- endif
- mv /usr/etc/credtmp/credentials.new.{dir,pag} /usr/etc/
- umount /usr/etc/credtmp
- rmdir /usr/etc/credtmp
-else
- mkcred /usr/etc/credentials.new
- if ($status) exit $MR_MKCRED
-endif
+# The following exit codes are defined and MUST BE CONSISTENT with the
+# error codes the library uses:
+MR_NOCRED=47836470
+MR_MISSINGFILE=47836473
+MR_MKCRED=47836474
+MR_TARERR=47836476
+
+PATH=/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc
+
+TARFILE=/var/tmp/nfs.out
+SRCDIR=/var/tmp/nfs.dir
+
+uchost=`hostname | tr '[a-z]' '[A-Z]'`
+echo $uchost | egrep -e "\." >/dev/null
+if [ $? != 0 ]; then
+ uchost=$uchost.MIT.EDU
+fi
+
+# Alert if the tar file does not exist
+test -r $TARFILE || exit $MR_MISSINGFILE
+
+# Make a temporary directory to unpack the tar file into
+rm -rf $SRCDIR
+mkdir $SRCDIR || exit $MR_MKCRED
+cd $SRCDIR || exit $MR_MKCRED
+
+# Extract everything
+tar xpf $TARFILE || exit $MR_TARERR
+
+for type in dirs quotas; do
+ echo "Installing ${type}:"
+ for i in $uchost.$type; do
+ if [ -f $i ]; then
+ # Convert from the filename HOST.@dev@device.type to /dev/device
+ dev=`echo $i | sed "s,.${type},," | sed "s,${uchost}.,," | \
+ sed "s,@,/,g"`
+ echo ${uchost}:$dev
+ ./install_${type} $dev < $i
+ if [ $? != 0 ]; then
+ exit $MR_NOCRED
+ fi
+ if [ ${type} = "quotas" ]; then
+ ./zero_quotas $dev < $i
+ if [ $? != 0 ]; then
+ exit $MR_NOCRED
+ fi
+ fi
+ mv -f $i /var/tmp
+ fi
+ done
+done
+
+# build new credentials files
+rm -f $creddir/credentials.new
+cp ${uchost}.cred $creddir/credentials.new
+if [ $? != 0 ]; then
+ exit $MR_NOCRED
+fi
+if [ -s $creddir/credentials.local ]; then
+ cat $creddir/credentials.local >> $creddir/credentials.new
+fi
+
+# After this point, if /tmp gets cleared out by reactivate (which happens
+# on a combined server/workstation), we don't care.
+mkcred $creddir/credentials.new
+if [ $? != 0 ]; then
+ exit $MR_MKCRED
+fi