Changed start/stop scripts

This commit is contained in:
Michiel Broek 2003-12-06 20:52:58 +00:00
parent df0e9ee03f
commit 1af9935914
10 changed files with 266 additions and 149 deletions

View File

@ -68,6 +68,9 @@ v0.39.3 26-Nov-2003
mbpasswd:
Fixed a small memory leak.
script:
Changed all init scripts to allow the slower stopping of mbtask
v0.39.2 21-Nov-2003 - 26-Nov-2003

View File

@ -652,6 +652,7 @@ int checktasks(int onsig)
void die(int onsig)
{
int i, count;
time_t now;
T_Shutdown = TRUE;
signal(onsig, SIG_IGN);
@ -692,7 +693,12 @@ void die(int onsig)
if (cmd_run || ping_run)
Syslog('+', "Waiting for threads to stop");
while (cmd_run || ping_run) {
/*
* Wait at most 2 seconds for the threads, internal they are
* build to stop within a second.
*/
now = time(NULL) + 2;
while ((cmd_run || ping_run) && (time(NULL) < now)) {
sleep(1);
}

View File

@ -31,27 +31,48 @@ export MBSE_ROOT
case "$1" in
start)
echo -n "Starting $DESC: "
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
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
echo "already running"
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 -n "opened "
fi
echo "done."
fi
echo "done."
;;
stop)
echo -n "Stopping $DESC: "
if [ -f $MBSE_ROOT/etc/config.data ]; then
echo -n "logoff users "
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
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 " stopping mbtask"
kill `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 "$NAME done."
else
echo "already stopped."
fi
kill `pidof mbtask`
sleep 3
echo "$NAME done."
;;
force-reload|restart)
$0 stop

View File

@ -12,43 +12,58 @@ 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
echo "MBSE BBS: No 'mbse' user in the password file."
exit 1
fi
if [ ! -d $MBSE_ROOT ]
then
echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found."
exit 1
echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found."
exit 1
fi
export MBSE_ROOT
# See how we were called.
case "$1" in
start)
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 -n ", opened bbs"
start)
if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then
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 -n ", opened bbs"
fi
fi
;;
stop)
if [ -f ${MBSE_ROOT}/etc/config.data ]; then
echo -n " logoff users"
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
stop)
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
echo -n " logoff users"
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
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 -n " done"
fi
kill -15 `/usr/local/bin/pidof mbtask`
echo -n " mbtask"
sleep 3
echo -n " done"
;;
*)
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac

View File

@ -50,12 +50,27 @@ start() {
stop() {
ebegin "Stopping mbse"
if [ -f $MBSE_ROOT/etc/config.data ]; then
echo -n "logoff users "
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
fi
kill `pidof mbtask`
sleep 3
eend $? "Stopping error."
ebegin "Stopping mbse"
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 " stopping mbtask"
kill `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
fi
eend $? "Stopping error."
}

View File

@ -20,14 +20,14 @@ 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
echo "MBSE BBS: No 'mbse' user in the password file."
exit 1
fi
if [ ! -d $MBSE_ROOT ]
then
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1
fi
export MBSE_ROOT
@ -65,33 +65,36 @@ fi
# See how we were called.
case "$1" in
start)
start)
echo -n "Starting MBSE BBS: "
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
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 "opened"
fi
touch /var/lock/subsys/mbsed
fi
touch /var/lock/subsys/mbsed
;;
stop)
stop)
echo -n "Shutting down MBSE BBS: "
if [ -f $MBSE_ROOT/etc/config.data ]; then
echo -n "logoff users "
$SU mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
echo -n "done, "
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
fi
echo -n "stop mbtask: "
killproc mbtask -15
rm -f /var/lock/subsys/mbsed
sleep 3
echo ""
# echo "done."
;;
status)
status mbtask

View File

@ -12,54 +12,73 @@ 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
echo "MBSE BBS: No 'mbse' user in the password file."
exit 1
fi
if [ ! -d $MBSE_ROOT ]
then
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1
fi
export MBSE_ROOT
# See how we were called.
case "$1" in
start)
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."
fi
;;
stop)
echo -n "MBSE BBS shutdown:"
if [ -f $MBSE_ROOT/etc/config.data ]; then
echo -n " logoff users "
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
echo -n "done,"
fi
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"
if [ -f $MBSE_ROOT/var/run/mbtask ]; then
echo " already started"
else
echo "mbtask Ok"
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
fi
;;
restart|reload)
stop)
echo -n "MBSE BBS shutdown:"
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 " stopping mbtask"
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."
fi
;;
status)
echo -n "MBSE BBS status: "
if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then
echo "mbtask is NOT running"
else
echo "mbtask running with pid `cat $MBSE_ROOT/var/run/mbtask`"
fi
;;
restart|reload)
$0 stop
$0 start
;;

View File

@ -16,14 +16,14 @@ 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
echo "MBSE BBS: No 'mbse' user in the password file."
exit 1
fi
if [ ! -d $MBSE_ROOT ]
then
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1
fi
export MBSE_ROOT
@ -31,30 +31,36 @@ export MBSE_ROOT
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."
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."
else
echo ""
fi
fi
fi
;;
stop)
echo -n "MBSE BBS shutdown:"
if [ -f $MBSE_ROOT/etc/config.data ]; then
echo -n " logoff users "
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
echo -n "done,"
fi
echo -n " stopping mbtask "
killproc $MBSE_ROOT/bin/mbtask -15
sleep 3
echo "done."
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 " stopping mbtask "
killproc `cat $MBSE_ROOT/var/run/mbtask` -15
sleep 3
echo "done."
else
echo "already stopped."
fi
;;
restart|reload)
$0 stop
@ -62,10 +68,10 @@ case "$1" in
;;
status)
echo -n "MBSE BBS status: "
if [ "`/sbin/pidof mbtask`" = "" ]; then
echo "mbtask is NOT running"
if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then
echo "mbtask is NOT running"
else
echo "mbtask Ok"
echo "mbtask Ok"
fi
;;
*)

View File

@ -220,26 +220,33 @@ if [ "$DISTNAME" = "Slackware" ]; then
echo "Removing old startup scripts"
rm $MBSE_ROOT/bin/mbse.start $MBSE_ROOT/bin/mbse.stop $MBSE_ROOT/etc/rc $MBSE_ROOT/etc/rc.shutdown
fi
echo "Making links for start/stop in runlevel 3"
if [ -f /etc/rc.d/rc3.d/K05mbsed ]; then
rm /etc/rc.d/rc3.d/K05mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc3.d/K05mbsed
if [ -f /etc/rc.d/rc3.d/S95mbsed ]; then
rm /etc/rc.d/rc3.d/S95mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc3.d/S95mbsed
echo "Making links for start/stop in runlevel 4"
if [ -f /etc/rc.d/rc4.d/K05mbsed ]; then
rm /etc/rc.d/rc4.d/K05mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc4.d/K05mbsed
if [ -f /etc/rc.d/rc4.d/S95mbsed ]; then
rm /etc/rc.d/rc4.d/S95mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc4.d/S95mbsed
echo "Slackware SystemV init configured"
log "+" "Slackware SystemV init configured"
if [ -d /var/log/setup ]; then
cp setup.mbse /var/log/setup
chmod 755 /var/log/setup/setup.mbse
echo "Added setup script, as root use 'pkgtool' Setup to enable MBSE at boot"
log "+" "Added Slackware setup script for use with pkgtool"
else
echo "Making links for start/stop in runlevel 3"
if [ -f /etc/rc.d/rc3.d/K05mbsed ]; then
rm /etc/rc.d/rc3.d/K05mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc3.d/K05mbsed
if [ -f /etc/rc.d/rc3.d/S95mbsed ]; then
rm /etc/rc.d/rc3.d/S95mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc3.d/S95mbsed
echo "Making links for start/stop in runlevel 4"
if [ -f /etc/rc.d/rc4.d/K05mbsed ]; then
rm /etc/rc.d/rc4.d/K05mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc4.d/K05mbsed
if [ -f /etc/rc.d/rc4.d/S95mbsed ]; then
rm /etc/rc.d/rc4.d/S95mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc4.d/S95mbsed
echo "Slackware SystemV init configured"
log "+" "Slackware SystemV init configured"
fi
fi
fi

22
script/setup.mbse Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
#BLURB="Enable/disable MBSE BBS at boot"
#
# System setup script for Slackware
#
# $Id$
#
T_PX=$1
TMP=/var/log/setup/tmp
if [ "$COLOR" = "on" -o -r $TMP/SeTcolor ]; then
dialog --title "ENABLE MBSE BBS AT BOOT?" --yesno \
"MBSE BBS is the bulletin board system and Fidonet (r) mailer for Unix." 6 70
if [ $? = 0 ]; then
mkdir -p /etc/rc.d/rc3.d /etc/rc.d/rc3.d
ln -s /etc/rc.d/init.d/mbsed /etc/rc.d/rc3.d/K05mbsed
ln -s /etc/rc.d/init.d/mbsed /etc/rc.d/rc3.d/S95mbsed
ln -s /etc/rc.d/init.d/mbsed /etc/rc.d/rc4.d/K05mbsed
ln -s /etc/rc.d/init.d/mbsed /etc/rc.d/rc4.d/S95mbsed
else
rm -f /etc/rc.d/rc3.d/K05mbsed /etc/rc.d/rc3.d/S95mbsed /etc/rc.d/rc4.d/K05mbsed /etc/rc.d/rc4.d/S95mbsed
fi
fi