HP-UX System Administrator's Guide: Routine Management Tasks HP-UX 11i v3 (B3921-90023, September 2010)
differences in start-up/shutdown configuration between the test system and the
production system may invalidate the test.
Example:
This example shows one way to automate the start-up of a server daemon, called
web_productname_daemon:
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
80 Booting and Shutdown