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: mbpasswd:
Fixed a small memory leak. 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 v0.39.2 21-Nov-2003 - 26-Nov-2003

View File

@ -652,6 +652,7 @@ int checktasks(int onsig)
void die(int onsig) void die(int onsig)
{ {
int i, count; int i, count;
time_t now;
T_Shutdown = TRUE; T_Shutdown = TRUE;
signal(onsig, SIG_IGN); signal(onsig, SIG_IGN);
@ -692,7 +693,12 @@ void die(int onsig)
if (cmd_run || ping_run) if (cmd_run || ping_run)
Syslog('+', "Waiting for threads to stop"); 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); sleep(1);
} }

View File

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

View File

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

View File

@ -50,12 +50,27 @@ start() {
stop() { stop() {
ebegin "Stopping mbse" ebegin "Stopping mbse"
if [ -f $MBSE_ROOT/etc/config.data ]; then if [ -f $MBSE_ROOT/var/run/mbtask ]; then
echo -n "logoff users " echo -n "logoff users "
su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null su mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
fi echo -n " stopping mbtask"
kill `pidof mbtask` kill `cat $MBSE_ROOT/var/run/mbtask`
sleep 3 i=10
eend $? "Stopping error." 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" = "" ] if [ "$MBSE_ROOT" = "" ]
then then
echo "MBSE BBS: No 'mbse' user in the password file." echo "MBSE BBS: No 'mbse' user in the password file."
exit 1 exit 1
fi fi
if [ ! -d $MBSE_ROOT ] if [ ! -d $MBSE_ROOT ]
then then
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found." echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1 exit 1
fi fi
export MBSE_ROOT export MBSE_ROOT
@ -65,33 +65,36 @@ fi
# See how we were called. # See how we were called.
case "$1" in case "$1" in
start) start)
echo -n "Starting MBSE BBS: " echo -n "Starting MBSE BBS: "
rm -f $MBSE_ROOT/sema/* if [ -f $MBSE_ROOT/var/run/mbtask ]; then
rm -f $MBSE_ROOT/var/*.LCK echo "already started"
rm -f $MBSE_ROOT/tmp/mb* else
$SU mbse -c '$MBSE_ROOT/bin/mbtask' >/dev/null rm -f $MBSE_ROOT/sema/*
echo -n "mbtask " rm -f $MBSE_ROOT/var/*.LCK
sleep 2 rm -f $MBSE_ROOT/tmp/mb*
if [ -f $MBSE_ROOT/etc/config.data ]; then $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' $SU mbse -c '$MBSE_ROOT/bin/mbstat open -quiet'
echo "opened" echo "opened"
fi
touch /var/lock/subsys/mbsed
fi fi
touch /var/lock/subsys/mbsed
;; ;;
stop) stop)
echo -n "Shutting down MBSE BBS: " 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 " echo -n "logoff users "
$SU mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null $SU mbse -c '$MBSE_ROOT/bin/mbstat close wait -quiet' >/dev/null
echo -n "done, " echo -n "done, "
echo -n "stop mbtask: "
killproc mbtask -15
rm -f /var/lock/subsys/mbsed
sleep 3
fi fi
echo -n "stop mbtask: "
killproc mbtask -15
rm -f /var/lock/subsys/mbsed
sleep 3
echo "" echo ""
# echo "done."
;; ;;
status) status)
status mbtask status mbtask

View File

@ -12,54 +12,73 @@ MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
if [ "$MBSE_ROOT" = "" ] if [ "$MBSE_ROOT" = "" ]
then then
echo "MBSE BBS: No 'mbse' user in the password file." echo "MBSE BBS: No 'mbse' user in the password file."
exit 1 exit 1
fi fi
if [ ! -d $MBSE_ROOT ] if [ ! -d $MBSE_ROOT ]
then then
echo "MBSE BBS: Home directory '$MBSE_ROOT' not found." echo "MBSE BBS: Home directory '$MBSE_ROOT' not found."
exit 1 exit 1
fi fi
export MBSE_ROOT export MBSE_ROOT
# See how we were called. # See how we were called.
case "$1" in case "$1" in
start) start)
echo -n "MBSE BBS starting:" echo -n "MBSE BBS starting:"
rm -f $MBSE_ROOT/sema/* if [ -f $MBSE_ROOT/var/run/mbtask ]; then
rm -f $MBSE_ROOT/var/*.LCK echo " already started"
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"
else 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 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 stop
$0 start $0 start
;; ;;

View File

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

View File

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