Addendum to ifalias script posting.
Sorry for the omission. This is the content of site.rc and
site_lib.sh used by the ifalias script posted yesterday.
# site.rc -- this file holds site specific env vars
# and is referenced by various scripts
# this file must use only the sh(1p) subset of sh/ksh syntax
# the name of the script executing stripped of the path
# this needs to be before the check for site.rc in each script
# PROGNAME=${0##[./]*/} # ksh only
# PROGNAME=`/usr/bin/basename $0`
# set hostname for single user mode
HOSTNAME=`/usr/sbin/rcmgr get HOSTNAME | /usr/bin/cut -f1 -d'.'`
export HOSTNAME
# locations of scripts and programs
SBINDIR=/local/bin
BINDIR=/usr/local/bin
ETCDIR=/local/etc
export SBINDIR BINDIR ETCDIR
# admin email
ADMIN_EMAIL=sysadmin
export ADMIN_EMAIL
# pagers : used by critpage
PAGER1="`/usr/bin/cat /local/etc/oncall_admin.txt`"
PAGER2=xyz_at_mobilecomm.net
export PAGER1 PAGER2
# Set node-specific env variables and functions
if [ -r /local/etc/node.rc ]
then
. /local/etc/node.rc
fi
# Get common functions for site
if [ -r /local/etc/site_lib.sh ]
then
. /local/etc/site_lib.sh
fi
---------- cut here ------------------------------
# site_lib.sh
######################################################################
# common functions
######################################################################
# paging functions assume an email gateway to the pagers
# display an error message
perror () {
msg=$1
echo "$PROGNAME : $msg"
}
# page the critical pagers
# usage : critpage severity "message"
critpage () {
severity=$1
msg=$2
oncall=`cat /local/etc/oncall_admin.txt`
/usr/bin/mailx -r pager_at_tessco.com -s "$HOSTNAME" $oncall <<EOF
h=$HOSTNAME
p=$PROGNAME
$severity
$msg
EOF
echo "
----- Critical Page Event
Date: `date`
To: $oncall
Node: $HOSTNAME
From: $PROGNAME
Severity: $severity
Message: $msg
-----" >>/var/adm/critpage.log
}
# mail error event status
# usage : critmail severity "recipients" "message" [file]
critmail () {
severity=$1
maillist=$2
msg=$3
data=$4
oncall=`cat /local/etc/oncall_admin.txt`
if [ -z "$4" ]
then
/usr/bin/mailx -s "$severity : $HOSTNAME : $PROGNAME $msg" $maillist <<EOF
$HOSTNAME
$PROGNAME
$msg
EOF
else
/usr/bin/mailx -s "$severity : $HOSTNAME : $PROGNAME : $msg" $maillist < $data
fi
}
Received on Sat Jul 29 2000 - 20:25:15 NZST