]> andersk Git - moira.git/blobdiff - regtape/reg-update
rename "employee" to "staff" and "students" to "student" to match
[moira.git] / regtape / reg-update
index cd174c6b1864a9ec3087b6f1b507f9a18dd24c2f..44a0625dbf2a893206f2fdfdc7bac9b7aaf26e5b 100644 (file)
@@ -1,18 +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
-
-for who in  staff students ; do
-  [ -f /moira/tapes/$who.input.$date.Z ] \
-  && cd /moira/ \
-  && mv $who.input.0 $who.input.1 \
-  && mv $who.input   $who.input.0 \
-  && zcat tapes/$who.input.$date.Z > $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
-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
This page took 0.101784 seconds and 4 git commands to generate.