Managing Systems and Workgroups: A Guide for HP-UX System Administrators

Administering a System: Booting and Shutdown
Customizing Start-up and Shutdown
Chapter 5516
4. Reboot the system to make sure everything works.
On a busy system, this may be inconvenient, but beware of testing on
a configuration other than the one on which your subsystem will
actually run; any 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:
Step 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.
Step 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