HP-UX HB v13.00 Ch-03 - System Startup
HP-UX Handbook – Rev 13.00 Page 12 (of 14)
Chapter 03 System Startup
October 29, 2013
Example
The file /sbin/init.d/template is a good starting place for making your own start/stop
scripts. The example here uses some of the comments from that template.
In the example, a file /sbin/init.d/mygame will start or stop a program called
/opt/mygame/mygamed, a multi-player daemon used by the engineering staff to maintain contact
with each other during the day. The daemon should be started at boot time and stopped on
shutdown.
The script reads the configuration file /etc/rc.config.d/mygame. It will start the daemon only
if the MYGAME variable is set to 1. It will then use the MAXPLAYERS variable as an argument to
send to the daemon.
After putting these files in place, make symbolic links to the /sbin/init.d/ script so that it gets
run properly by /sbin/rc:
ln -s /sbin/init.d/mygame /sbin/rc2.d/S900mygame
ln -s /sbin/init.d/mygame /sbin/rc1.d/K100mygame
Here is the /etc/rc.config.d/mygame configuration file:
# set MYGAME to 0 to disable the game daemon
MYGAME=1
# default MAXPLAYERS is 5
MAXPLAYERS=17
Here is the /sbin/init.d/mygame script:
#!/sbin/sh
# This script will read in ('dot' in) the file /etc/rc.config.d/mygame
# and start the 'mygamed' program if the MYGAME variable is set to 1.
# It also reads the MAXPLAYERS variable from the config file and passes
# that as an argument to the daemon.
# Allowed exit values:
# 0 = success; causes OK to show up in checklist.
# 1 = failure; causes FAIL to show up in checklist.
# 2 = skip; causes N/A to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# Input and output:
# stdin is redirected from /dev/null