2002-02-04 15:18:06 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# chkconfig: 345 95 05
|
|
|
|
# description: Starts and stops MBSE BBS.
|
|
|
|
#
|
|
|
|
# For RedHat, E-Smith and Mandrake SYSV init style.
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ ${NETWORKING} = "no" ] && exit 1
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
SU="su"
|
|
|
|
#
|
|
|
|
# From RedHat version 6.1 and up the behaviour of "su" has changed.
|
|
|
|
# Extra tests are added for the RedHat e-smith server distribution,
|
|
|
|
# this is a special distribution based on RedHat.
|
|
|
|
# For Mandrake we follow the same behaviour.
|
|
|
|
#
|
|
|
|
if [ -f /etc/mandrake-release ]; then
|
|
|
|
#
|
|
|
|
# Mandrake 6.0 and newer, use "su -"
|
|
|
|
#
|
|
|
|
RHR="`cat /etc/mandrake-release | awk '{ print $4 }' | tr -d .`"
|
|
|
|
if [ $RHR -gt 60 ]; then
|
|
|
|
SU="su -"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -f /etc/redhat-release ]; then
|
|
|
|
if [ -z "`grep e-smith /etc/redhat-release`" ]; then
|
|
|
|
# Standard RedHat
|
|
|
|
RHR=`cat /etc/redhat-release | awk '{ print $5 }' | tr -d .`
|
|
|
|
else
|
|
|
|
# E-Smith server based on RedHat
|
|
|
|
RHR=`cat /etc/redhat-release | awk '{ print $13 }' | tr -d . | tr -d \)`
|
|
|
|
fi
|
|
|
|
if [ $RHR -gt 60 ]; then
|
|
|
|
SU="su -"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# 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 "Starting MBSE BBS: "
|
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
|
2002-02-04 15:18:06 +00:00
|
|
|
$SU mbse -c '$MBSE_ROOT/bin/mbstat open -quiet'
|
|
|
|
echo "opened"
|
2003-12-06 20:52:58 +00:00
|
|
|
fi
|
|
|
|
touch /var/lock/subsys/mbsed
|
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 "Shutting down MBSE BBS: "
|
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
|
|
|
|
echo -n "done, "
|
|
|
|
echo -n "stop mbtask: "
|
|
|
|
killproc mbtask -15
|
|
|
|
rm -f /var/lock/subsys/mbsed
|
|
|
|
sleep 3
|
2002-02-04 15:18:06 +00:00
|
|
|
fi
|
2002-02-04 16:14:47 +00:00
|
|
|
echo ""
|
2002-02-04 15:18:06 +00:00
|
|
|
;;
|
|
|
|
status)
|
2002-02-04 16:14:47 +00:00
|
|
|
status mbtask
|
2002-02-04 15:18:06 +00:00
|
|
|
;;
|
|
|
|
restart|reload)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart|reload|status}"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
exit 0
|