new debian start script and config file contributed by Ovidiu Sas.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@569 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Raphael Coeffic 19 years ago
parent 80461b82c6
commit 3572e0c018

@ -0,0 +1,151 @@
#! /bin/sh
#
# INSTRUCTIONS:
# - Copy this file to /etc/init.d/sems
# - Don't forget to copy the default file for this script to work properly
#
### BEGIN INIT INFO
# Provides: sems
# Required-Start: $syslog $network $local_fs $time
# Required-Stop: $syslog $network $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the SEMS server
# Description: Start the SEMS server
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/sems
NAME=sems
DESC=sems
HOMEDIR=/var/run/sems
PIDFILE=$HOMEDIR/$NAME.pid
DEFAULTS=/etc/default/sems
RUN_SEMS=no
# Do not start sems if fork=no is set in the config file
# otherwise the boot process will just stop
check_fork ()
{
if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /usr/local/etc/sems/sems.conf; then
echo "Not starting $DESC: fork=no specified in config file; run /etc/init.d/sems debug instead"
exit 1
fi
}
create_radius_seqfile ()
{
# Create a radius sequence file to be used by the radius client if
# radius accounting is enabled. This is needed to avoid any issue
# with the file not being writable if sems first starts as user
# root because DUMP_CORE is enabled and creates this file as user
# root and then later it switches back to user sems and cannot
# write to the file. If the file exists before sems starts, it
# won't change it's ownership and will be writable for both root
# and sems, no matter what options are chosen at install time
RADIUS_SEQ_FILE=/var/run/sems/sems_radius.seq
if [ -d /var/run/sems ]; then
chown ${USER}:${GROUP} /var/run/sems
if [ ! -f $RADIUS_SEQ_FILE ]; then
touch $RADIUS_SEQ_FILE
fi
chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
chmod 660 $RADIUS_SEQ_FILE
fi
}
test -f $DAEMON || exit 0
# Load startup options if available
if [ -f $DEFAULTS ]; then
. $DEFAULTS || true
fi
if [ "$RUN_SEMS" != "yes" ]; then
echo "SEMS not yet configured. Edit /etc/default/sems first."
exit 0
fi
set -e
[ -z "$USER" ] && USER=sems
[ -z "$GROUP" ] && GROUP=sems
if test "$DUMP_CORE" = "yes" ; then
# set proper ulimit
ulimit -c unlimited
# directory for the core dump files
# COREDIR=/home/corefiles
# [ -d $COREDIR ] || mkdir $COREDIR
# chmod 777 $COREDIR
# echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern
fi
OPTIONS="-P $PIDFILE -u $USER -g $GROUP"
case "$1" in
start|debug)
create_radius_seqfile
DBG_OPTIONS=""
if [ "$1" != "debug" ]; then
check_fork
else
DBG_OPTIONS="-D 3 -E"
fi
# FIXME
# This is a small hack to prevent some broken apps to be loaded
rm -f /usr/local/lib/sems/plug-in/py_sems.so /usr/local/lib/sems/plug-in/sw_prepaid_sip.so
echo "$DAEMON $OPTIONS $DBG_OPTIONS"
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--exec $DAEMON -- $OPTIONS $DBG_OPTIONS || echo -n " already running"
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
--exec $DAEMON
echo "."
;;
restart|force-reload)
create_radius_seqfile
echo -n "Restarting $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile \
$PIDFILE --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
$PIDFILE --exec $DAEMON -- $OPTIONS
echo "."
;;
status)
echo -n "Status of $DESC: "
if [ ! -r "$PIDFILE" ]; then
echo "$NAME is not running."
exit 3
fi
pid=`cat "$PIDFILE"`
if ps -p "$pid" > /dev/null 2>&1; then
echo "$NAME is running."
exit 0
else
echo "$NAME is not running but $PIDFILE exists."
exit 1
fi
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|debug|status}" >&2
exit 1
;;
esac
exit 0

@ -0,0 +1,20 @@
#
# SEMS startup options:
# INSTRUCTIONS:
# - copy this file to /etc/default/sems
#
# Set to yes to enable openser, once configured properly.
RUN_SEMS=no
# User to run as
USER=openser
#USER=ser
# Group to run as
GROUP=openser
#GROUP=ser
# Enable the server to leave a core file when it crashes.
DUMP_CORE=no
Loading…
Cancel
Save