2002-02-04 15:18:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# /sbin/init.d/mbsed for SuSE
|
2002-05-10 14:23:24 +00:00
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: mbsed
|
|
|
|
# Default-Start: 2 3 5
|
|
|
|
# Default-Stop:
|
|
|
|
# Description: Start MBSE BBS
|
|
|
|
### END INIT INFO
|
2002-02-04 15:18:06 +00:00
|
|
|
|
|
|
|
# Find the MBSE_ROOT from the /etc/passwd file.
|
2007-07-09 18:46:51 +00:00
|
|
|
MBSE_ROOT=`cat /etc/passwd | grep ^mbse: | awk -F ':' '{ print $6}'`
|
2002-02-04 15:18:06 +00:00
|
|
|
|
2003-12-26 11:28:15 +00:00
|
|
|
if [ "${MBSE_ROOT}" = "" ]
|
2002-02-04 15:18:06 +00:00
|
|
|
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
|
|
|
|
|
2003-12-26 11:28:15 +00:00
|
|
|
if [ ! -d ${MBSE_ROOT} ]
|
2002-02-04 15:18:06 +00:00
|
|
|
then
|
2003-12-26 11:28:15 +00:00
|
|
|
echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found."
|
2003-12-06 20:52:58 +00:00
|
|
|
exit 1
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export MBSE_ROOT
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo -n "MBSE BBS starting:"
|
2003-12-26 11:28:15 +00:00
|
|
|
rm -f ${MBSE_ROOT}/var/run/*
|
2004-09-14 20:37:57 +00:00
|
|
|
rm -f ${MBSE_ROOT}/var/sema/*
|
2003-12-26 11:28:15 +00:00
|
|
|
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."
|
2003-12-06 20:52:58 +00:00
|
|
|
fi
|
2002-02-04 15:18:06 +00:00
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "MBSE BBS shutdown:"
|
2003-12-26 11:28:15 +00:00
|
|
|
if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then
|
2003-12-06 20:52:58 +00:00
|
|
|
echo -n " logoff users "
|
2003-12-26 11:28:15 +00:00
|
|
|
su mbse -c '${MBSE_ROOT}/bin/mbstat close wait -quiet' >/dev/null
|
2003-12-06 20:52:58 +00:00
|
|
|
echo -n "done,"
|
|
|
|
echo -n " stopping mbtask "
|
2003-12-26 11:28:15 +00:00
|
|
|
killproc `cat ${MBSE_ROOT}/var/run/mbtask` -15
|
2003-12-06 20:52:58 +00:00
|
|
|
sleep 3
|
|
|
|
echo "done."
|
|
|
|
else
|
|
|
|
echo "already stopped."
|
|
|
|
fi
|
2002-02-04 15:18:06 +00:00
|
|
|
;;
|
|
|
|
restart|reload)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
echo -n "MBSE BBS status: "
|
2003-12-26 11:28:15 +00:00
|
|
|
if [ ! -f ${MBSE_ROOT}/var/run/mbtask ]; then
|
2003-12-06 20:52:58 +00:00
|
|
|
echo "mbtask is NOT running"
|
2002-02-04 15:18:06 +00:00
|
|
|
else
|
2003-12-06 20:52:58 +00:00
|
|
|
echo "mbtask Ok"
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|status|reload|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
exit 0
|