#!/bin/sh
#
# (C) R. J. Livermore  1995-1999
# (C) Livermore Software Laboratories, Inc. 1995-1999
#
# NOTICE TO USERS OF SOURCE CODE EXAMPLES
#
# FAS PROVIDES THE SOURCE CODE EXAMPLES, "AS IS" WITHOUT WARRANTY OF ANY
# KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE
# ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOURCE CODE EXAMPLES
# IS WITH YOU.  SHOULD ANY PART OF THE SOURCE CODE PROVE DEFECTIVE, YOU
# (AND NOT FAS OR AGENT OF FAS) ASSUME THE ENTIRE COST OF ALL NECESSARY
# SERVICING, REPAIR OR CORRECTION.
#
#
# file:  /usr/local/etc/refresh_syslogd
#
# This script refreshes syslogd with the HUP signal and rotates the log
# appending the date to the name of the rotated log.
#
# cron can be configured to automate the script.  To do so,
# insert a line at the bottom of /usr/spool/cron/crontabs/root specifying
# the download script and the time and date of download.  The first numer
# in a cron statement is minutes, the second is hours in military time, the 
# fifth is the day of the week, and everything after the day of the week
# is executed.  See example.
# example:
#		43 2 * * 1 /usr/local/etc/refresh_syslogd
#
if [ "`uname`" = "AIX" ]; then
	mv /var/adm/syslog /var/adm/syslog.`date +%y%m%d`
	touch /var/adm/syslog
	chmod 644 /var/adm/syslog
	refresh -s syslogd
elif [ "`uname`" = "HP-UX" ]; then
	mv /var/adm/syslog/syslog.log /var/adm/syslog/syslog.log.`date +%y%m%d`
	touch /var/adm/syslog/syslog.log
	chmod 644 /var/adm/syslog/syslog.log
	kill -HUP `cat /var/run/syslog.pid`
elif [ "`uname`" = "SunOS" ]; then
	mv /var/adm/messages /var/adm/messages.`date +%y%m%d`
	touch /var/adm/messages
	chmod 644 /var/adm/messages
	kill -HUP `cat /etc/syslog.pid`
elif [ "`uname`" = "Linux" ]; then
	mv /var/log/messages /var/log/messages.`date +%y%m%d`
	touch /var/log/messages
	chmod 644 /var/log/messages
	kill -HUP `cat /var/run/syslogd.pid`
else
  echo "Unsupported operating system"
  exit
fi
