Cover V05, I08
Article
Figure 1
Figure 2
Figure 3
Listing 1
Listing 2
Sidebar 1

aug96.tar


Listing 1: AdminLog.sh

#!/bin/sh

# ----------------------------------------------------
# AdminLog.sh                       September 28, 1995
# Scott A. Tarvainen
# ----------------------------------------------------
# This script is a front-end to the AdminLogDB TCL/TK
# System Administrator Log Program.  It controls
# access to the database records as well as the
# structure of the database itself.
# ----------------------------------------------------

# Use DATE to uniquely identify daily database creation

DATE=`date | awk '{print $3$2$6}'`
PROGDIR="/usr/local/bin"

# Create database home directory if necessary

if [ ! -d $PROGDIR/AdminLogs ]; then
mkdir $PROGDIR/AdminLogs > /dev/null 2>& 1
if [ $? = 1 ]; then
echo "Error encountered making $PROGDIR/AdminLogs"
echo "Please correct error and try again"
sleep 2
exit 1
fi
fi

# Ensure no one else is accessing program

if [ ! -f $PROGDIR/log.tmp ]; then
echo `hostname` > $PROGDIR/log.tmp
chmod 666 $PROGDIR/log.tmp
clear
echo
echo
echo
echo "  **************************************"
echo "  *                                    *"
echo "  *  System Administrator Log Program  *"
echo "  *                                    *"
echo "  **************************************"
echo
echo
echo "  1.  Open Today's  Log"
echo "  2.  Open Previous Log"
echo
echo -n "  Enter Option --> "
read OPTION

# Open today's log

if [ $OPTION = 1 ]; then

if [ -f $PROGDIR/AdminLogs/log.$DATE ]; then
echo
echo "  Opening Log for $DATE"
sleep 2
$PROGDIR/AdminLogDB $PROGDIR/AdminLogs/log.$DATE

else
echo
echo -n "  No log file exists for $DATE,"
echo -n " Do you wish to create it ? <YN> "
read ANSWER
if [ $ANSWER = "Y" -o $ANSWER = "y" ]; then
echo "  creating new log entry for $DATE"
sleep 2
umask 117
echo "  SYSTEM  ADMINISTRATOR  LOG  FOR  $DATE" \
> $PROGDIR/AdminLogs/log.$DATE
echo -n "  Administrator 20,Time 12;  " \
>> $PROGDIR/AdminLogs/log.$DATE
echo "LOG ENTRY: 50; 50; 50; 50; 50; 50; 50; 50; 50; 50" \
>> $PROGDIR/AdminLogs/log.$DATE
chgrp wheel $PROGDIR/AdminLogs/log.$DATE
$PROGDIR/AdminLogDB $PROGDIR/AdminLogs/log.$DATE
else
echo "  Will not create new entry....Exiting"
sleep 2
fi
fi
break

# Open previous log

elif [ $OPTION = 2 ]; then

echo
echo "  Enter date of Log you wish to open"
echo "  Format for date is DMmmYYY or DDMmmYYYY"
echo -n "  For example, 1Oct1995 or 23Oct1995 -------> "
read PREV_DATE

if [ -f $PROGDIR/AdminLogs/log.$PREV_DATE ]; then
echo
echo "  Opening Log for $PREV_DATE"
sleep 2
$PROGDIR/AdminLogDB $PROGDIR/AdminLogs/log.$PREV_DATE
else
echo
echo "  No Log file exists for $PREV_DATE...Exiting"
sleep 2
fi
break

else
echo
echo "  Invalid Option...Try Again"
sleep 3
fi

# Remove temporary touch file so someone else can access program

if [ -f $PROGDIR/log.tmp ]; then
rm $PROGDIR/log.tmp
fi

# Don't allow access if temporary touch file exists

else
IN_USE=`cat $PROGDIR/log.tmp`
echo
echo "Log Program already running on $IN_USE"
echo
sleep 3
fi

# End of File