HP-UX System Administrator's Guide: Routine Management Tasks

1. Decide on run level:
a. See what’s started at run level 2:
ls /sbin/rc2.d/S*
/sbin/rc2.d/S008net.sd
/sbin/rc2.d/S560SnmpMaster
/sbin/rc2.d/S100swagentd
/sbin/rc2.d/S565SnmpHpunix...
b. See what’s started at run level 3:
ls /sbin/rc3.d/S*
/sbin/rc3.d/S100nfs.server
/sbin/rc3.d/S100nfs.server is a link to /sbin/init.d/nfs.server,
which starts up portmap, rpc.mountd, nfsd and related functions. Since
none of these are needed by the web_productname daemon, it is safe to start
it in run level 2, using the placeholder number 900 (see below).
Similarly, we stop the script in run level 1, using the placeholder number 100.
2. Write the start-up/shutdown and configuration scripts.
You can use /sbin/init.d/template as a basis, and create the following
start-up/shutdown script, saving it as /sbin/init.d/web_productname:
#!/sbin/sh
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
web_productname_daemon="web_productname"
rval=0
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')
# message that appears in the startup checklist
echo "Starting the web_productname daemon"
;;
'stop_msg')
# message that appears in the shutdown checklist
echo "Stopping the web_productname daemon"
;;
'start')
82 Booting and Shutdown