Changes between Initial Version and Version 1 of Solaris_Autostart_Procedure


Ignore:
Timestamp:
01/30/12 08:31:00 (9 years ago)
Author:
branden
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Solaris_Autostart_Procedure

    v1 v1  
     1{{{Earthworm Solaris Autostart 
     2 
     3(last revised 13 March, 2001) 
     4Following are steps needed to have earthworm (EW) start up automatically when a Sun workstation running Solaris boots up. 
     5 
     6Overview of the steps: 
     7 
     8Create and customize the startup script 
     9Install the script in the startup directories 
     10Can Earthworm be started automatically, but not run as superuser? 
     11 
     12The following is an example script which can be used to start earthworm 
     13automatically whenever the system boots up: 
     14 
     15 
     16--------- /etc/init.d/earthworm --------- 
     17#!/bin/sh 
     18# /etc/init.d script to start/stop earthworm under Solaris 
     19 
     20 
     21# 
     22# Change the value of PARAM_DIR to reflect the earthworm 
     23# configuration which is to be started at boot time 
     24# 
     25PARAM_DIR=/home/earthworm/run_test/params 
     26 
     27case "$1" in 
     28'start') 
     29 
     30        # Verify processes not already running 
     31 
     32        PROCESS_LIST="startstop" 
     33        for PROC in $PROCESS_LIST; do 
     34        id=`/usr/bin/ps -ef | /usr/bin/grep $PROC | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}'` 
     35        if test -n "$id" 
     36        then 
     37                echo "$PROC already running" 
     38                exit 1 
     39        fi 
     40        done 
     41 
     42        # Start up from a known location 
     43        cd /tmp 
     44        echo "starting earthworm" 
     45 
     46        # Source the CTS configuration 
     47        if [ -f $PARAM_DIR/ew_sol_sparc.cmd ] ; then 
     48                csh -c "source $PARAM_DIR/ew_sol_sparc.cmd >& /dev/null; startstop >& /dev/null &" 
     49        else 
     50                echo  "$PARAM_DIR/ew_sol_sparc.cmd file not found. Exitting." 
     51        fi 
     52 
     53        # Start the processes 
     54 
     55        ;; 
     56 
     57'stop') 
     58 
     59        # Stop from a known location 
     60        cd /tmp 
     61        echo "Stopping earthworm" 
     62 
     63        # Source the CTS configuration 
     64        if [ -f $PARAM_DIR/ew_sol_sparc.cmd ] ; then 
     65                csh -c "source $PARAM_DIR/ew_sol_sparc.cmd >& /dev/null; pau >& /dev/null" 
     66        else 
     67                echo  "$PARAM_DIR/ew_sol_sparc.cmd file not found. Exitting." 
     68        fi 
     69 
     70        ;; 
     71 
     72'status') 
     73 
     74        # Go to a known location 
     75        cd /tmp 
     76        echo "Getting earthworm status" 
     77 
     78        # Source the CTS configuration 
     79        if [ -f $PARAM_DIR/ew_sol_sparc.cmd ] ; then 
     80                csh -c "source $PARAM_DIR/ew_sol_sparc.cmd >& /dev/null; status" 
     81        else 
     82                echo  "$PARAM_DIR/ew_sol_sparc.cmd file not found. Exitting." 
     83        fi 
     84 
     85        ;; 
     86*) 
     87        echo "Usage: /etc/init.d/earthworm { start | stop | status }" 
     88        ;; 
     89esac 
     90 
     91 
     92After the value of the PARAM_DIR has been changed to reflect the path 
     93to the local configuration directory, the script should be installed as 
     94/etc/init.d/earthworm on the target machine. Make sure that the 
     95permissions on it are 755. 
     96 
     97Now, create the following soft links. You will need to be logged in as 
     98superuser to do this: 
     99 
     100# ln -s /etc/init.d/earthworm /etc/rc3.d/S99earthworm 
     101# ln -s /etc/init.d/earthworm /etc/rc2.d/K10earthworm 
     102# ln -s /etc/init.d/earthworm /etc/rc0.d/K10earthworm 
     103 
     104Just FYI: the first link tells Solaris to start earthworm when booting 
     105into multi-user state (run level 3). The next two links tell it to 
     106gracefully quit earthworm when going either into single user mode or 
     107shutting down completely. 
     108 
     109Once this is done, earthworm will start automatically at boot time. 
     110Also, the /etc/init.d/earthworm command can be used to start, stop, or 
     111get status from, earthworm: 
     112 
     113 > /etc/init.d/earthworm start 
     114 > /etc/init.d/earthworm stop 
     115 > /etc/init.d/earthworm status 
     116 
     117 
     118 
     119 
     120RUNNING AS NON-ROOT USER 
     121 
     122The procedure above is fairly simple -- it makes earthworm start 
     123automatically at boot time. In addition, the /etc/init.d/earthworm 
     124script can be a useful tool for all users on the system to quickly 
     125start, stop or get status from Earthworm. 
     126 
     127The major drawback of this procedure is that Earthworm runs as root 
     128(superuser) when it is started at boot time. Some sites find this 
     129inconvenient. Unfortunately, there is not an easy and elegent way to 
     130have Solaris start up a process during boot time without that process 
     131being run by root.  The version of the /etc/init.d/earthworm script 
     132below gets around this problem.  It introduces another variable USER 
     133which should be set to the username under which Earthworm should be 
     134started: 
     135 
     136--------- /etc/init.d/earthworm --------- 
     137#!/bin/sh 
     138# /etc/init.d script to start/stop earthworm under Solaris 
     139 
     140# Change USER to the user you want earthworm to run as. 
     141# Change the value of PARAM_DIR to reflect the earthworm 
     142# configuration which is to be started at boot time. 
     143# 
     144USER=ppicker 
     145PARAM_DIR=/home/earthworm/run/params 
     146ENV_FILE=ew_sol_sparc.cmd 
     147 
     148case "$1" in 
     149'start') 
     150 
     151        # Verify processes not already running 
     152 
     153        PROCESS_LIST="startstop" 
     154        for PROC in $PROCESS_LIST; do 
     155        id=`/usr/bin/ps -ef | /usr/bin/grep $PROC | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}'` 
     156        if test -n "$id" 
     157        then 
     158                echo "$PROC already running" 
     159                exit 1 
     160        fi 
     161        done 
     162 
     163        # Start up from a known location 
     164        cd /tmp 
     165        echo "starting earthworm as $USER" 
     166 
     167        # Source the CTS configuration 
     168        if [ -f $PARAM_DIR/$ENV_FILE ] ; then 
     169                su $USER -c "source $PARAM_DIR/$ENV_FILE >& /dev/null; startstop >& /dev/null &" 
     170        else 
     171                echo "$PARAM_DIR/$ENV_FILE file not found. Exiting." 
     172        fi 
     173 
     174        # Start the processes 
     175 
     176        ;; 
     177 
     178'stop') 
     179 
     180        # Stop from a known location 
     181        cd /tmp 
     182        echo "Stopping earthworm as $USER" 
     183 
     184        # Source the CTS configuration 
     185        if [ -f $PARAM_DIR/$ENV_FILE ] ; then 
     186                su $USER -c "source $PARAM_DIR/$ENV_FILE >& /dev/null; pau >& /dev/null" 
     187        else 
     188                echo  "$PARAM_DIR/$ENV_FILE file not found. Exiting." 
     189        fi 
     190 
     191        ;; 
     192 
     193'status') 
     194 
     195        # Go to a known location 
     196        cd /tmp 
     197        echo "Getting earthworm status" 
     198 
     199        # Source the CTS configuration 
     200        if [ -f $PARAM_DIR/ew_sol_sparc.cmd ] ; then 
     201                csh -c "source $PARAM_DIR/ew_sol_sparc.cmd >& /dev/null; status" 
     202        else 
     203                echo  "$PARAM_DIR/ew_sol_sparc.cmd file not found. Exiting." 
     204        fi 
     205 
     206        ;; 
     207*) 
     208        echo "Usage: /etc/init.d/earthworm { start | stop | status }" 
     209        ;; 
     210esac 
     211 
     212 
     213 
     214 
     215The main advantage of the script above is that it will run Earthworm as 
     216the user defined by the USER variable, whenever it is invoked. One 
     217major drawback of this scheme, however, is that the 
     218/etc/init.d/earthworm script, when executed by a non-superuser, will 
     219prompt for the password of the user defined by the USER variable. 
     220 
     221Some sites may want to use this quirk as a "security feature." For 
     222example, if a "dummy account" is created (say, username earthworm) and 
     223the USER variable is set to earthworm, then only those users on the 
     224system who know the password for the user earthworm will be able to 
     225start and stop earthworm using the /etc/init.d/earthworm script. This 
     226may server as a very rudimentary security feature on a multi-user 
     227Solaris system. 
     228 
     229 
     230 
     231CHANGING THE CONFIGURATION DIRECTORY 
     232 
     233Whenever a new configuration directory is desired, the 
     234/etc/init.d/earthworm script must be edited, and the value of the 
     235PARAM_DIR variable updated to reflect the new path to the configuration 
     236directory. 
     237}}}