Chapter 03 System Startup HP-UX Handbook Revision 13.
Chapter 03 System Startup October 29, 2013 TERMS OF USE AND LEGAL RESTRICTIONS FOR THE HP-UX RECOVERY HANDBOOK ATTENTION: PLEASE READ THESE TERMS CAREFULLY BEFORE USING THE HP-UX HANDBOOK. USING THESE MATERIALS INDICATES THAT YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THE HP-UX HANDBOOK. THE HP-UX HANDBOOK HAS BEEN COMPILED FROM THE NOTES OF HP ENGINEERS AND CONTAINS HP CONFIDENTIAL INFORMATION.
Chapter 03 System Startup October 29, 2013 TABLE OF CONTENTS Introduction 4 Configuration Files - /etc/rc.config.d/* 5 /etc/rc.config ................................................................................................................. 5 /etc/rc.config.d .............................................................................................................. 5 /etc/rc.config.d/* ...........................................................................................................
Chapter 03 System Startup October 29, 2013 Introduction The Run/Halt-Script based system startup that is used at HP-UX 10.X and 11.X follows the OSF/1 industry standard that has been adopted by Sun, SGI, and other vendors. There are four components involved: Execution Scripts, Configuration Files, Execution Script Links and Sequencer Script: Execution Scripts (/sbin/init.d/*) are located in /sbin/init.d/. They are invoked with either “start” or “stop” argument in order to start or stop the subsystem.
Chapter 03 System Startup October 29, 2013 Configuration Files - /etc/rc.config.d/* The system configuration used at startup is contained in files within the directory /etc/rc.config.d. The script /etc/rc.config sources all of the files within /etc/rc.config.d and /etc/TIMEZONE and exports their contents to the environment. /etc/rc.config The file /etc/rc.config is a script that sources all of the /etc/rc.config.d/* scripts, and also sources /etc/TIMEZONE.
Chapter 03 System Startup October 29, 2013 scripts must be written to be read by the POSIX shell, and not the Bourne shell, ksh, or csh. In some cases, these files must also be read and possibly modified by Software Distributor control scripts or SAM. See sd(4) and sam(1M). For this reason, each variable definition must appear on a separate line, with the syntax: variable=value No trailing comments may appear on a variable definition line.
Chapter 03 System Startup October 29, 2013 Execution Scripts - /sbin/init.d/* Each of the scripts in /sbin/init.d/ deals with one application or one subsystem, such as NFS server daemons. A single script in /sbin/init.d/ must be able to start up an application (or subsystem) or kill it. The script will be passed the command line parameter 'start' or 'stop' depending on whether it is supposed to start or kill the appropriate daemons. In some cases, only a start action will be applicable.
Chapter 03 System Startup October 29, 2013 Script Output To ensure proper reporting of startup events, startup scripts are required to comply with the following guidelines for script output. Status messages, such as “starting house daemon” must be directed to stdout. All error messages must be directed to stderr. Script output, both stdout and stderr, is redirected to log file /etc/rc.log, unless the startup checklist mode is set to the raw mode. In this case, all output goes to the console.
Chapter 03 System Startup October 29, 2013 Sequencer Script - /sbin/rc The job of the sequencer script /sbin/rc is to invoke the individual startup scripts in /sbin/init.d/. However, /sbin/rc does not invoke these scripts directly, but rather through a series of symbolic links (Execution Script Links) in the /sbin/rc?.d/ directories. For example, if your system is booting to run level 3 (invoking all services, including CDE), then /sbin/rc will invoke all the scripts (symbolic links) in the /sbin/rc2.
Chapter 03 System Startup October 29, 2013 Execution Script Links - /sbin/rc#.d/* The Execution Script Links are located in the Sequencer (or Run Level) Directories /sbin/rcN.d/ where N reflects the Run Level. The contents of sequencer directories consist of symbolic links to startup scripts in /sbin/init.d. These symbolic links must follow a strict naming convention, as noted in the various fields of this example: /sbin/rc2.d/S060cron rc2.
Chapter 03 System Startup October 29, 2013 be stopped in the reverse order to eliminate any dependencies between subsystems. This means that kill scripts will generally not have the same numbers as their start script counterparts. E.g. if two subsystems must be started in a given order due to dependencies (e.g., S111house followed by S222uses_house), the kill counterparts to these scripts must be numbered so that the subsystems are stopped in the opposite order in which they were started (e.g.
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.
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.
Chapter 03 System Startup October 29, 2013 ;; 'stop') # source the system configuration variables killproc mygamed ;; *) echo "Usage: $0 {start|stop|start_msg|stop_msg}" rval=1 ;; esac exit $rval # end of script Troubleshooting Many problems during system startup are caused by temporary files that have been left in the directory for configuration files (/etc/rc.config.d/). When files such as ioscan.out, swlist.out or cron.bk are sourced this can result in errors and even render a system unbootable.