From c9c95ffc04f820e01ccce30c614629423f130baa Mon Sep 17 00:00:00 2001 From: dkk Date: Tue, 4 Nov 1997 22:00:55 +0000 Subject: [PATCH] Added a command-line arg, to allow the administrator to load only one of student or staff data files (instead of both together). The frequency of the two data files varied greatly, so the script was being used only as an example until these changes were applied. The script also now uses a separate directory (/moira/load/). --- regtape/reg-update | 58 ++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/regtape/reg-update b/regtape/reg-update index 28ee8e65..44a0625d 100644 --- a/regtape/reg-update +++ b/regtape/reg-update @@ -1,23 +1,41 @@ -#!/bin/sh +#!/bin/sh -vx # -# Script to update Moira from Registrar's "tapes". +# Script to update Moira from Registrar and Personnel "tapes". + +if [ "filler $1" != "filler staff" -a "filler $1" != "filler student" ] ; then + echo "Bad argument $1" + echo "Usage: $0 [ staff | student ]" + exit 1 +fi +who="$1" +rdir=/moira +bdir=$rdir/bin +tdir=$rdir/tapes +ldir=$rdir/load date=`date +%y%m%d` -##### date=`expr $date - 1` # files are postdated by 1 day - -cd /moira/ || exit 1 -for who in staff student ; do - if [ -f tapes/$who.input.$date.Z ] ; then - [ -s $who.input ] \ - && mv $who.input.0 $who.input.1 \ - && mv $who.input $who.input.0 - - zcat tapes/$who.input.$date.Z | bin/$who.cvt > $who.input - - [ -s $who.input ] \ - && [ `diff $who.input.0 $who.input | wc -l` -lt 500 ] \ - && bin/$who -n $who.input > $who.output.$date 2>&1 \ - && egrep -v "($who): (adding|updating)" $who.output.$date > $who.err 2>&1 \ - && cat /usr/local/lib/mail_header $who.err | mail dkk - fi -done +date=`expr $date - 1` # files are postdated by 1 day + +cd "$ldir" || exit 2 + +if [ -f "$tdir/$who.input.$date.Z" ] ; then + + if [ -f "$ldir/$who.input.$date" ] ; then + echo "Pre-existing $ldir/$who.input.$date, will not overwrite." + exit 3 + fi + + zcat "$tdir/$who.input.$date.Z" | "$bdir/$who.cvt" \ + > "$ldir/$who.input.$date" + + [ -s "$ldir/$who.input.$date" ] \ + && [ `diff $ldir/$who.input.last $ldir/$who.input.$date |wc -l` -lt 500 ] \ + && rm $ldir/$who.input.last \ + && ln -s $who.input.$date $ldir/$who.input.last \ + && $bdir/$who -n $ldir/$who.input.$date > $ldir/$who.output.$date 2>&1 \ + +# && egrep -v "($who): (adding|updating)" $ldir/$who.output.$date \ +# > $ldir/$who.err.$date 2>&1 \ +# && cat /usr/local/lib/mail_header $who.err | mail dkk + +fi -- 2.45.2