Seon Core init script
From Seon
For runlevel scripts, this script can be used as a basis for further needs. It works good in an SeonBox environment.
#! /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'" | mysql --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; }
SeonCLIENTD_BIN=$Seon_BINDIR/seonclientd
test -x $SeonCLIENTD_BIN || { echo "$SeonCLIENTD_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
case "$1" in
start)
echo -n "Starting Seon "
echo -n "seonrd... "
$SeonRD_BIN
echo -n "seonsqd... "
$SeonSQD_BIN
echo -n "seondebugd... "
$SeonDEBUGD_BIN
echo -n "seonclientd... "
$SeonCLIENTD_BIN
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
echo -n "seonclientd... "
killall seonclientd 1> /dev/null 2>1
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
pidof seonclientd > /dev/null
if [ $? -ne 0 ]
then
echo "... seondebugd is not running"
else
echo "... seondebugd OK "
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
# rc_exit