diff --git a/ChangeLog b/ChangeLog index e9b7c9b5..1981b266 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/mbtask/mbtask.c b/mbtask/mbtask.c index d3dcdb10..02ef23eb 100644 --- a/mbtask/mbtask.c +++ b/mbtask/mbtask.c @@ -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); } diff --git a/script/init.Debian b/script/init.Debian index e7508c15..027aa252 100644 --- a/script/init.Debian +++ b/script/init.Debian @@ -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 diff --git a/script/init.FreeBSD b/script/init.FreeBSD index 3c810040..199b5f10 100644 --- a/script/init.FreeBSD +++ b/script/init.FreeBSD @@ -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 diff --git a/script/init.Gentoo b/script/init.Gentoo index e6821225..7c067970 100644 --- a/script/init.Gentoo +++ b/script/init.Gentoo @@ -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." } diff --git a/script/init.RedHat b/script/init.RedHat index 245f046d..e43551b6 100644 --- a/script/init.RedHat +++ b/script/init.RedHat @@ -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 diff --git a/script/init.Slackware b/script/init.Slackware index 9bf5d5e9..1d2dd4b5 100644 --- a/script/init.Slackware +++ b/script/init.Slackware @@ -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 ;; diff --git a/script/init.SuSE b/script/init.SuSE index 771da426..ccc6f91c 100644 --- a/script/init.SuSE +++ b/script/init.SuSE @@ -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 ;; *) diff --git a/script/installinit.sh b/script/installinit.sh index 2e38a08a..e3938101 100644 --- a/script/installinit.sh +++ b/script/installinit.sh @@ -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 diff --git a/script/setup.mbse b/script/setup.mbse new file mode 100644 index 00000000..97b35cd8 --- /dev/null +++ b/script/setup.mbse @@ -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