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,6 +31,9 @@ export MBSE_ROOT
case "$1" in
start)
echo -n "Starting $DESC: "
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*
@ -42,16 +45,34 @@ case "$1" in
echo -n "opened "
fi
echo "done."
fi
;;
stop)
echo -n "Stopping $DESC: "
if [ -f $MBSE_ROOT/etc/config.data ]; then
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
kill `pidof mbtask`
sleep 3
echo "$NAME done."
else
echo "already stopped."
fi
;;
force-reload|restart)
$0 stop

View File

@ -27,6 +27,7 @@ export MBSE_ROOT
# See how we were called.
case "$1" in
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*
@ -37,16 +38,30 @@ case "$1" in
su mbse -c '${MBSE_ROOT}/bin/mbstat open -quiet'
echo -n ", opened bbs"
fi
fi
;;
stop)
if [ -f ${MBSE_ROOT}/etc/config.data ]; then
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
kill -15 `/usr/local/bin/pidof mbtask`
echo -n " mbtask"
sleep 3
echo -n " done"
fi
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2

View File

@ -51,11 +51,26 @@ start() {
stop() {
ebegin "Stopping mbse"
if [ -f $MBSE_ROOT/etc/config.data ]; then
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
kill `pidof mbtask`
sleep 3
eend $? "Stopping error."
}

View File

@ -67,6 +67,9 @@ fi
case "$1" in
start)
echo -n "Starting MBSE 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*
@ -78,20 +81,20 @@ case "$1" in
echo "opened"
fi
touch /var/lock/subsys/mbsed
fi
;;
stop)
echo -n "Shutting down MBSE BBS: "
if [ -f $MBSE_ROOT/etc/config.data ]; then
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, "
fi
echo -n "stop mbtask: "
killproc mbtask -15
rm -f /var/lock/subsys/mbsed
sleep 3
fi
echo ""
# echo "done."
;;
status)
status mbtask

View File

@ -28,6 +28,9 @@ export MBSE_ROOT
case "$1" in
start)
echo -n "MBSE BBS starting:"
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*
@ -38,25 +41,41 @@ case "$1" in
su mbse -c '$MBSE_ROOT/bin/mbstat open -quiet'
echo " and opened the bbs."
fi
fi
;;
stop)
echo -n "MBSE BBS shutdown:"
if [ -f $MBSE_ROOT/etc/config.data ]; then
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,"
fi
echo -n " stopping mbtask"
kill -15 `pidof $MBSE_ROOT/bin/mbtask`
sleep 3
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 [ "`/sbin/pidof mbtask`" = "" ]; then
if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then
echo "mbtask is NOT running"
else
echo "mbtask Ok"
echo "mbtask running with pid `cat $MBSE_ROOT/var/run/mbtask`"
fi
;;
restart|reload)

View File

@ -31,6 +31,9 @@ export MBSE_ROOT
case "$1" in
start)
echo -n "MBSE BBS starting:"
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*
@ -43,18 +46,21 @@ case "$1" in
else
echo ""
fi
fi
;;
stop)
echo -n "MBSE BBS shutdown:"
if [ -f $MBSE_ROOT/etc/config.data ]; then
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,"
fi
echo -n " stopping mbtask "
killproc $MBSE_ROOT/bin/mbtask -15
killproc `cat $MBSE_ROOT/var/run/mbtask` -15
sleep 3
echo "done."
else
echo "already stopped."
fi
;;
restart|reload)
$0 stop
@ -62,7 +68,7 @@ case "$1" in
;;
status)
echo -n "MBSE BBS status: "
if [ "`/sbin/pidof mbtask`" = "" ]; then
if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then
echo "mbtask is NOT running"
else
echo "mbtask Ok"

View File

@ -220,6 +220,12 @@ 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
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
@ -242,6 +248,7 @@ if [ "$DISTNAME" = "Slackware" ]; then
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