Difference between revisions of "Seon Core init script"

From Seon
Jump to: navigation, search
Line 1: Line 1:
For runlevel scripts, this script can be used as a basis for further needs. It works good in an SeonBox environment.
+
For runlevel scripts, this script can be used as a basis for further needs. It works good in an SeonBox environment. Actual versions of init-scripts can be found here: http://www.seon.de/downloads/init-scripts/
 
<pre>
 
<pre>
 
#! /bin/sh
 
#! /bin/sh

Revision as of 20:17, 11 April 2007

For runlevel scripts, this script can be used as a basis for further needs. It works good in an SeonBox environment. Actual versions of init-scripts can be found here: http://www.seon.de/downloads/init-scripts/

#! /bin/sh
### BEGIN INIT INFO
# Provides:          Seon
# Required-Start:    mysql
# Should-Start: mysql
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Seon
# Description:       Start and stop Seon daemons
### END INIT INFO

# Check for existence of needed config file and read it
Seon_CONFIG=/etc/seon.conf
test -r $Seon_CONFIG || { echo "$Seon_CONFIG not existing";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 6; fi; }  

# first, source the config file for database parameters
. $Seon_CONFIG

# retrieve backup directory
Seon_BINDIR=`echo "SELECT value FROM ${TABLEPREFIX}configuration WHERE name='bin_directory'" | $MYSQLCLIENT --silent --user=$DB_USER --password=$DB_PASS --host=$DB_HOST $DB_NAME`
Seon_ENTERPRISE=`echo "SELECT value FROM ${TABLEPREFIX}configuration WHERE name='seon_enterprise'" | $MYSQLCLIENT --silent --user=$DB_USER --password=$DB_PASS --host=$DB_HOST $DB_NAME`

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
SeonRD_BIN=$Seon_BINDIR/seonrd
test -x $SeonRD_BIN || { echo "$SeonRD_BIN not installed"; 
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }

SeonSQD_BIN=$Seon_BINDIR/seonsqd
test -x $SeonSQD_BIN || { echo "$SeonSQD_BIN not installed";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }  

SeonDEBUGD_BIN=$Seon_BINDIR/seondebugd
test -x $SeonDEBUGD_BIN || { echo "$SeonDEBUGD_BIN not installed";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }  

if [ $Seon_ENTERPRISE -gt 0 ]
then
        SeonCLIENTD_BIN=$Seon_BINDIR/seonclientd
        test -x $SeonCLIENTD_BIN || { echo "$SeonCLIENTD_BIN not installed";
                if [ "$1" = "stop" ]; then exit 0;
                else exit 5; fi; }
fi

case "$1" in
    start)
        echo -n "Starting Seon "
        echo -n "seonrd... "
        $SeonRD_BIN
        echo -n "seonsqd... "
        $SeonSQD_BIN
        echo -n "seondebugd... "
        $SeonDEBUGD_BIN
        if [ $Seon_ENTERPRISE -gt 0 ]
        then
                echo -n "seonclientd... "
                $SeonCLIENTD_BIN
        fi
        echo "OK"
        ;;
    stop)
        echo -n "Shutting down Seon "
        echo -n "seonrd... "
        killall seonrd 1> /dev/null 2>1
        echo -n "seonsqd... "
        killall seonsqd 1> /dev/null 2>1
        echo -n "seondebugd... "
        killall seondebugd 1> /dev/null 2>1
        if [ $Seon_ENTERPRISE -gt 0 ]
        then 
                echo -n "seonclientd... "
                killall seonclientd 1> /dev/null 2>1
        fi
        echo OK
        ;;
    status)
        echo -n "Checking for service Seon "
        pidof seonrd > /dev/null
        if [ $? -ne 0 ]
        then
          echo -n "... seonrd is not running"
        else
          echo -n "... seonrd OK "
        fi 
        pidof seonsqd > /dev/null
        if [ $? -ne 0 ]
        then
          echo -n "... seonsqd is not running"
        else
          echo -n "... seonsqd OK "
        fi
        pidof seondebugd > /dev/null
        if [ $? -ne 0 ]
        then
          echo "... seondebugd is not running"
        else
          echo -n "... seondebugd OK "
        fi
        if [ $Seon_ENTERPRISE -gt 0 ]
        then
                pidof seonclientd > /dev/null
                if [ $? -ne 0 ]
                then
                   echo "... seonclientd is not running"
                else
                   echo "... seonclientd OK "
                fi
        else
                echo ""
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;;
esac
# rc_exit