2002-02-04 15:18:06 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# description: Starts and stops MBSE BBS.
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# /etc/rc.d/init.d for Slackware
|
|
|
|
#
|
|
|
|
|
|
|
|
# Find the MBSE_ROOT from the /etc/passwd file.
|
|
|
|
MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
|
|
|
|
|
|
|
|
if [ "$MBSE_ROOT" = "" ]
|
|
|
|
then
|
2003-12-06 20:52:58 +00:00
|
|
|
echo "MBSE BBS: No 'mbse' user in the password file."
|
|
|
|
exit 1
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $MBSE_ROOT ]
|
|
|
|
then
|
2003-12-06 20:52:58 +00:00
|
|
|
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
|
|
|
|
exit 1
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export MBSE_ROOT
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
2003-12-06 20:52:58 +00:00
|
|
|
start)
|
2002-02-04 15:18:06 +00:00
|
|
|
echo -n "MBSE BBS starting:"
|
2003-12-06 20:52:58 +00:00
|
|
|
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
|
|
|
|
echo " already started"
|
|
|
|
else
|
|
|
|
rm -f $MBSE_ROOT/sema/*
|
|
|
|
rm -f $MBSE_ROOT/var/*.LCK
|
|
|
|
rm -f $MBSE_ROOT/tmp/mb*
|
|
|
|
su mbse -c '$MBSE_ROOT/bin/mbtask' >/dev/null
|
|
|
|
echo -n " mbtask"
|
|
|
|
sleep 2
|
|
|
|
if [ -f $MBSE_ROOT/etc/config.data ]; then
|
|
|
|
su mbse -c '$MBSE_ROOT/bin/mbstat open -quiet'
|
|
|
|
echo " and opened the bbs."
|
|
|
|
fi
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
;;
|
2003-12-06 20:52:58 +00:00
|
|
|
stop)
|
2002-02-04 15:18:06 +00:00
|
|
|
echo -n "MBSE BBS shutdown:"
|
2003-12-06 20:52:58 +00:00
|
|
|
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
|
|
|
|
echo -n " logoff users "
|
|
|
|
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
|
2003-12-06 22:16:10 +00:00
|
|
|
echo -n "done, stopping mbtask"
|
2003-12-06 20:52:58 +00:00
|
|
|
kill -15 `cat $MBSE_ROOT/var/run/mbtask`
|
|
|
|
i=10; doit=1;
|
|
|
|
while let 'i > 0' && let 'doit != 0'
|
|
|
|
do
|
|
|
|
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
|
|
|
|
echo -n "."
|
|
|
|
sleep 1
|
|
|
|
let i=i-1
|
|
|
|
else
|
|
|
|
doit=0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
|
|
|
|
kill -9 `cat $MBSE_ROOT/var/run/mbtask`
|
|
|
|
fi
|
|
|
|
echo " done."
|
|
|
|
else
|
|
|
|
echo " not running."
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
;;
|
2003-12-06 20:52:58 +00:00
|
|
|
status)
|
2002-02-04 15:18:06 +00:00
|
|
|
echo -n "MBSE BBS status: "
|
2003-12-06 20:52:58 +00:00
|
|
|
if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then
|
|
|
|
echo "mbtask is NOT running"
|
2002-02-04 15:18:06 +00:00
|
|
|
else
|
2003-12-06 20:52:58 +00:00
|
|
|
echo "mbtask running with pid `cat $MBSE_ROOT/var/run/mbtask`"
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
;;
|
2003-12-06 20:52:58 +00:00
|
|
|
restart|reload)
|
2002-02-04 15:18:06 +00:00
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|reload|restart|status}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
exit 0
|