-#! /bin/sh
-TARFILE=/tmp/hesiod
-SRC_DIR=/etc/athena/_nameserver
-DEST_DIR=/etc/athena/nameserver
-if [ ! -d $SRC_DIR ]; then
- /bin/rm -f $SRC_DIR
- /bin/mkdir $SRC_DIR
- /bin/chmod 755 $SRC_DIR
-fi
-#if [ ! -d $DEST_DIR ]; then
-# /bin/rm -f $DEST_DIR
-# /bin/mkdir $DEST_DIR
-# /bin/chmod 755 $DEST_DIR
-#fi
+#!/bin/csh -f
+# This script performs updates of hesiod files on hesiod servers.
+# $Header$
+
+set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc)
+
+# The following exit codes are defined and MUST BE CONSISTENT with the
+# MR error codes the library uses:
+set MR_HESFILE = 47836472
+set MR_MISSINGFILE = 47836473
+set MR_NAMED = 47836475
+set MR_TARERR = 47836476
+
+umask 22
+
+# File that will contain the necessary information to be updated
+set TARFILE=/var/tmp/hesiod.out
+# Directory into which we will empty the tarfile
+set SRC_DIR=/etc/athena/_nameserver
+# Directory into which we will put the final product
+set DEST_DIR=/etc/athena/nameserver
+
+# Create the destination directory if it doesn't exist
+if (! -d $DEST_DIR) then
+ rm -f $DEST_DIR
+ mkdir $DEST_DIR
+ chmod 755 $DEST_DIR
+endif
+
+# If $SRC_DIR does not already exist, make sure that it gets created
+# on the same parition as $DEST_DIR.
+if (! -d $SRC_DIR) then
+ chdir $DEST_DIR
+ mkdir ../_nameserver
+ chdir ../_nameserver
+ if ($SRC_DIR != `pwd`) then
+ ln -s `pwd` $SRC_DIR
+ endif
+endif
+
+# Alert if tarfile doesn't exist
+if (! -r $TARFILE) exit $MR_MISSINGFILE
+
+# Empty the tar file one file at a time and move each file to the
+# appropriate place only if it is not zero length.