HP-UX HB v13.00 Ch-03 - System Startup

HP-UX Handbook Rev 13.00 Page 13 (of 14)
Chapter 03 System Startup
October 29, 2013
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
# NOTE:
# If your script executes in run state 0 or state 1, then /usr might
# not be available. Do not attempt to access commands or files in
# /usr unless your script executes in run state 2 or greater. Other
# file systems typically not mounted until run state 2 include /var
# and /opt.
rval=0
# Function to kill the named process(es).
# $1=<search pattern for your process>
killproc() {
pid=`ps -e | awk '$NF~/'"$1"'/ {print $1}'`
if [ "X$pid" != "X" ]; then
if kill "$pid"; then
echo "$1 stopped"
else
rval=1
echo "Unable to stop $1"
fi
fi
}
case $1 in
'start_msg')
# Emit a _short_ message relating to running this script with
# the 'start' arg; this message appears as part of the checklist.
echo "Starting the mygamed daemon"
;;
'stop_msg')
# Emit a _short_ message relating to running this script with
# the 'stop' arg; this message appears as part of the checklist.
echo "Stopping the mygamed daemon"
;;
'start')
# source the system configuration variables
MAXPLAYERS=5 # set a default to pass to daemon
if [ -f /etc/rc.config.d/mygame ] ; then
. /etc/rc.config.d/mygame
else
echo "WARNING: /etc/rc.config.d/mygame defaults file
MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$MYGAME" != 1 ]; then
rval=2
else
# Execute the commands to start your subsystem
/opt/mygame/mygamed -m $MAXPLAYERS
fi