#!/bin/sh # # Synchronet BBS daemonized init script # # User definable options. Edit these as necessary. # # For now, the location of the sbbs install. PREFIX=/usr/local/sbbs # The location of the sbbs executable. SBBSEXEC=$PREFIX/exec # Location of the ctrl directory (where sbbs.ini can be found) export SBBSCTRL=$PREFIX/ctrl # The username for the bbs to change to once it has started. USER=bbs # The group to change to GROUP=bbs # Set this to the home directory of the user that the BBS runs as. export HOME=/home/bbs # # Don't edit anything below this line. # PATH=$SBBSEXEC:/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin EXEC=$SBBSEXEC/sbbs NAME=sbbs DESC="Synchronet BBS Server" PIDFILE=/var/run/sbbs.pid set -e test -f $EXEC || exit 0 if [ -z `grep ^$USER /etc/passwd` ]; then echo "User \"$USER\" does not exist in /etc/passwd" exit 1; fi if [ ! -z "$USER" ]; then USER=un$USER; fi if [ ! -z "$GROUP" ]; then GROUP=ug$GROUP; fi case "$1" in start) echo -n "Starting $DESC: " $EXEC $USER $GROUP d 2>&1 > /dev/null & # echo $! > $PIDFILE echo "$NAME." ;; stop) echo -n "Stopping $DESC: " if [ ! -f $PIDFILE ]; then echo "None found running." exit 1; fi PID=`cat $PIDFILE` kill -TERM `expr $PID + 2` 2>&1 > /dev/null echo "$NAME." ;; force-stop) echo -n "Killing all $DESC: " if [ -f $PIDFILE ]; then kill -KILL `cat $PIDFILE` 2>&1 > /dev/null; fi killall -KILL $EXEC 2>&1 > /dev/null rm -f $PIDFILE echo "$NAME." ;; force-reload) echo -n "Reloading $DESC config: " if [ ! -f $PIDFILE ]; then echo "None found running." exit 1; fi kill -HUP `cat $PIDFILE` 2>&1 > /dev/null echo "$NAME." ;; restart) echo -n "Restarting $DESC: " $0 stop sleep 5 if [ ! $(ps -ef | grep $EXEC | grep -v grep | grep -c $EXEC) -eq 0 ]; then $0 force-stop; fi sleep 1 $0 start echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|force-stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0