HP-UX Virtual Partitions

   

HP-UX Virtual Partitions

By Marty Poniatowski

Table of Contents
Chapter 8.  System Startup and Shutdown Scripts

Each Virtual Partition is like a separate server. The applications running in a vPar run independently of applications and activity running in other vPars.

All applications in a vPar require startup scripts to be run as they would on any system (please see the non-vPar-specific section of this chapter if you need information on how HP-UX startup and shutdown operates.)

In the vPar used in this example we have a variety of applications running, including Broadvision. Let's take a look at /etc/rc.config.d, where the configuration variable scripts are located, to see what bv files (those that relate to Broadvision) exist:

# ll | grep bv -rwxr-xr-x 1 root sys 9 Sep 26 09:31 bv # cat bv BV_CTL=1 #

This listing shows the bv file and its contents. The BV_CTL=1 variable indicates that Broadvision is to be started when the system boots.

Starting the bv application processes results in several Broadvision-related daemons being started, including those shown in the following listing:

# ps -ef | grep bv1 pbcombv 3111 3096 0 Sep 26 ? 0:04 bvconf_srv p_1221_3 -f -install_name bv1to1/bvconf_srv_a pbcombv 3404 3096 0 Sep 26 ? 1:19 cntdb p_1221_5 -install_name bv1to1/cntdb_1 pbcombv 3707 3096 0 Sep 26 ? 0:20 genericdb p_1221_8 -install_name bv1to1/genericdb_1 pbcombv 34793096 0 Sep26 ? 0:05cntdbp_1221_7 -install_name bv1to1/ DiscussionForum_cntdb_1 root 7572 7232 0 13:17:33 pts/0 0:00 grep bv1 #

You can see that there are many processes related to the bv1to1 application running on this system. These are started automatically as part of the startup structure of HP-UX. The following listing shows the link in /sbin/ rc1.d, for run level one, and /sbin/rc2.d, for run level two, for bv.

# ll /sbin/rc1.d | grep bv lrwxr-xr-x 1 root sys 15 Sep 26 10:42 K105bv -> /sbin/init.d/bv # ll /sbin/rc2.d | grep bv lrwxr-xr-x 1 root sys 15 Sep 26 10:41 S930bv -> /sbin/init.d/bv #

The bv kill script, as indicated by the "K" preceding the link, is shown in /sbin/rc1.d, and the start script, as indicated by the "S" preceding the link, is shown in /sbin/rc2.d.

The script /sbin/init.d/bv, which is shown in the links, runs a variety of commands at both startup and shutdown of the Virtual Partition. The following listing shows the /sbin/init.d/bv script:

# # <Insert comment about your script here> # # 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. # 4 = background; causes "BG" to show up in the checklist. # Use this value if this script starts a process in background mode. # Input and output: # stdin is redirected from /dev/null # # 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. rval=0 # Check the exit value of a command run by this script. If non-zero, the # exit code is echoed to the log file and the return value of this script # is set to indicate failure. set_return() { x=$? if [ $x -ne 0 ]; then echo "EXIT CODE: $x" rval=1 # script FAILed fi } # Kill the named process(es). # $1=<search pattern for your process> killproc() { pid=`ps -el | awk '( ($NF ~ /'"$1"'/) && ($4 != mypid) && ($5 != mypid) ){ print $4 }' mypid=$$ ` 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') # Emit a _short_ message relating to running this script with # the "start" argument; this message appears as part of the checklist. echo "Starting the BroadVision subsystem" ;; 'stop_msg') # Emit a _short_ message relating to running this script with # the "stop" argument; this message appears as part of the checklist. echo "Stopping the BroadVision subsystem" ;; 'start') # source the system configuration variables if [ -f /etc/rc.config.d/bv];then . /etc/rc.config.d/bv else echo "ERROR: /etc/rc.config.d/bv defaults file MISSING" fi # Check to see if this script is allowed to run... if [ "$BV_CTL" != 1 ]; then rval=2 else # Execute the commands to start your subsystem su - pbcombv -c "/opt/bv1to1/bin/bvconf execute" : fi ;; 'stop') # source the system configuration variables if [ -f /etc/rc.config.d/bv] ; then . /etc/rc.config.d/bv else echo "ERROR: /etc/rc.config.d/bv defaults file MISSING" fi # Check to see if this script is allowed to run... if [ "$BV_CTL" != 1 ]; then rval=2 else : # Execute the commands to stop your subsystem su - pbcombv -c "/opt/bv1to1/bin/bvconf shutdown" fi ;; *) echo "usage: $0 {start|stop|start_msg|stop_msg}" rval=1 ;; esac exit $rval

Note that all of the start and stop information related to the Broadvision is present in this file because this script is run for both kill (K) and start (S.) Note also the line

if [ "$BV_CTL" != 1 ]; then

which checks to see if the variable we viewed earlier in /etc/rc.config.d/bv is equal to one as it was when we checked the file.

The installation and startup of Broadvision is required in all Virtual Partitions in which you want to run this application. What is taking place in vPar used in this example is what you would see in every vPar running Broadvision.


       
    Top
     

    Категории