#!/bin/bash
#
# Add a cron job to set the root user's password just after midnight every night
#
# Usage:
#   setupCron
#
# Dependencies:
# . The CONSOLE_PATH environment variable must be set to the top HMC/SE directory

mycronprog=updateRootPasswd # The name of our cron program we want to have crond run
tempfn=setupCron.$$         # Name of a temp file

# Get copy of root's current crontab, less comment lines
crontab -l | sed -e '/^#/d' > $tempfn

# If no entry for our cron program, add it now
grep $mycronprog $tempfn > /dev/null || (echo -e "CONSOLE_TOP_DIR=$CONSOLE_PATH\n01 00 * * * $CONSOLE_PATH$mycronprog" | cat $tempfn - | crontab -)

rm $tempfn              # Delete our temp file






