[hobbit] hobbit client - startup script for hpux

Hobbit User hobbit at epperson.homelinux.net
Fri Jun 22 14:20:54 CEST 2007


On Fri, June 22, 2007 03:26, Marco Avvisano wrote:
> Hi all,
>
> someone have startup script for client on hpux?
>

Here's the one for 11.11 from the depot at razorsedge.org:


#!/sbin/sh
#
# hobbit-client   This shell script takes care of starting and stopping
#                 the hobbit client.
#

#
# NOTE:    This script is not configurable!  Any changes made to this
#          script will be overwritten when you upgrade.
#

PATH=/usr/sbin:/usr/bin:/sbin
export PATH

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
}

RE_check() {
        if [ "$HOBBIT_SERVERS" = "" ]; then
                echo "Please configure HOBBIT_SERVERS in
/etc/rc.config.d/hobbit-client"
                exit 1
        fi
}

RE_prestart() {
        DMNOPTS=""
        set $HOBBIT_SERVERS
        if [ $# -eq 1 ]; then
                echo "BBDISP=\"$HOBBIT_SERVERS\""
>${HOBBIT_PREFIX}/var/run/hobbitclient-runtime.cfg
                echo "BBDISPLAYS=\"\""
>>${HOBBIT_PREFIX}/var/run/hobbitclient-runtime.cfg
        else
                echo "BBDISP=\"0.0.0.0\""
>${HOBBIT_PREFIX}/var/run/hobbitclient-runtime.cfg
                echo "BBDISPLAYS=\"$HOBBIT_SERVERS\""
>>${HOBBIT_PREFIX}/var/run/hobbitclient-runtime.cfg
        fi
        if [ "$HOBBIT_CLIENTHOSTNAME" != "" ]; then
                DMNOPTS="${DMNOPTS} --hostname=${HOBBIT_CLIENTHOSTNAME}"
        fi
        if [ "$HOBBIT_CLIENTOS" != "" ]; then
                DMNOPTS="${DMNOPTS} --os=${HOBBIT_CLIENTOS}"
        fi
}

RE_start() {
        RE_check
        RE_prestart
        # Start daemons.
        su $HOBBIT_USER -c "$HOBBIT_DAEMON $DMNOPTS start"
        set_return
        return $rval
}

RE_stop() {
        RE_check
        # Stop daemons.
        su $HOBBIT_USER -c "$HOBBIT_DAEMON stop"
        set_return
        return $rval
}

RE_restart() {
        RE_check
        RE_prestart
        # Restart daemons.
        su $HOBBIT_USER -c "$HOBBIT_DAEMON $DMNOPTS restart"
        set_return
        return $rval
}


case $1 in
'start_msg')
        echo "Starting the Hobbit Monitoring Client"
        ;;

'stop_msg')
        echo "Stopping the Hobbit Monitoring Client"
        ;;

'start')

        # source the system configuration variables
        if [ -f /etc/rc.config ] ; then
                . /etc/rc.config
        else
                echo "ERROR: /etc/rc.config defaults file MISSING"
        fi

        # Check to see if this script is allowed to run...
        if [ "$HOBBIT_CLIENT_START" != 1 ]; then
                rval=2
        else
                # Execute the commands to start your subsystem
                RE_start
                rval=$?
        fi
        ;;

'stop')
        # source the system configuration variables
        if [ -f /etc/rc.config ] ; then
                . /etc/rc.config
        else
                echo "ERROR: /etc/rc.config defaults file MISSING"
        fi

        # Check to see if this script is allowed to run...
        if [ "$HOBBIT_CLIENT_START" != 1 ]; then
                rval=2
        else
                # Execute the commands to stop your subsystem
                RE_stop
                rval=$?
        fi
        ;;

'restart')
        # source the system configuration variables
        if [ -f /etc/rc.config ] ; then
                . /etc/rc.config
        else
                echo "ERROR: /etc/rc.config defaults file MISSING"
        fi

        # Check to see if this script is allowed to run...
        if [ "$HOBBIT_CLIENT_START" != 1 ]; then
                rval=2
        else
                # Execute the commands to restart your subsystem
                RE_restart
                rval=$?
        fi
        ;;

'condrestart')
        # source the system configuration variables
        if [ -f /etc/rc.config ] ; then
                . /etc/rc.config
        else
                echo "ERROR: /etc/rc.config defaults file MISSING"
        fi

        # Check to see if this script is allowed to run...
        if [ "$HOBBIT_CLIENT_START" != 1 ]; then
                rval=2
        else
                # Execute the commands to restart your subsystem
                if ps -fu $HOBBIT_USER | grep -q
[h]obbit/client/bin/hobbitlaunch; then
                        RE_restart
                        rval=$?
                fi
        fi
        ;;

*)
        echo "usage: $0 {start|stop|start_msg|stop_msg|restart|condrestart}"
        rval=1
        ;;
esac

exit $rval




More information about the Xymon mailing list