#!/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
echo "MBSE BBS: No 'mbse' user in the password file."
exit 1
fi
if [ ! -d $MBSE_ROOT ]
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
export MBSE_ROOT
# See how we were called.
case "$1" in
start)
echo -n "MBSE BBS starting:"
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."
;;
stop)
echo -n "MBSE BBS shutdown:"
echo -n " logoff users "
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
echo -n "done,"
echo -n " stopping mbtask "
kill -15 `pidof $MBSE_ROOT/bin/mbtask`
sleep 3
echo "done."
status)
echo -n "MBSE BBS status: "
if [ "`/sbin/pidof mbtask`" = "" ]; then
echo "mbtask is NOT running"
else
echo "mbtask Ok"
restart|reload)
$0 stop
$0 start
*)
echo "Usage: $0 {start|stop|reload|restart|status}"
esac
exit 0