From 32300e69df188486c6757fc3dc708f67116325e8 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 26 Dec 2003 11:28:15 +0000 Subject: [PATCH] Changed init scripts to start after a power failure --- ChangeLog | 3 +++ script/README | 8 ++++++++ script/init.Debian | 25 +++++++++++------------- script/init.FreeBSD | 41 +++++++++++++++++++-------------------- script/init.Gentoo | 35 +++++++++++++++++---------------- script/init.NetBSD | 26 ++++++++++++------------- script/init.RedHat | 35 +++++++++++++++------------------ script/init.Slackware | 45 ++++++++++++++++++++----------------------- script/init.SuSE | 39 ++++++++++++++++--------------------- script/installinit.sh | 8 ++++---- 10 files changed, 130 insertions(+), 135 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf0020c1..0d14e37e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ v0.39.5 24-Dec-2003 script: Fixed NetBSD init script + All init scripts now clean the ~/var/run directory and start + the bbs allways so that the bbs will try to start after a power + failure. v0.39.4 08-Dec-2003 - 24-Dec-2003 diff --git a/script/README b/script/README index c34b6ca6..507c17e0 100644 --- a/script/README +++ b/script/README @@ -1,7 +1,15 @@ +$Id$ + + MBSE BBS Script files. If you want to make any changes to the scripts, do it here and not in the ~/etc and ~/bin directories. After making the changes do a 'make install' as root and the scripts are in place with the right permissions and owners. +Also, if you use a distribution which is not supported here and want to +have it added, then send the file installinit.log found in this directory, +SETUP.log (if exists) from the mbse main directory and a possible written +inew init script you may have written. + Michiel diff --git a/script/init.Debian b/script/init.Debian index cb1de8f0..9ca0d05a 100644 --- a/script/init.Debian +++ b/script/init.Debian @@ -31,21 +31,18 @@ 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* - 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." + rm -f $MBSE_ROOT/var/run/* + 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." ;; stop) echo -n "Stopping $DESC: " diff --git a/script/init.FreeBSD b/script/init.FreeBSD index 5e585381..0b19266b 100644 --- a/script/init.FreeBSD +++ b/script/init.FreeBSD @@ -10,13 +10,13 @@ # Find the MBSE_ROOT from the /etc/passwd file. MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'` -if [ "$MBSE_ROOT" = "" ] +if [ "${MBSE_ROOT}" = "" ] then echo "MBSE BBS: No 'mbse' user in the password file." exit 1 fi -if [ ! -d $MBSE_ROOT ] +if [ ! -d ${MBSE_ROOT} ] then echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found." exit 1 @@ -27,39 +27,38 @@ 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* - 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 + rm -f ${MBSE_ROOT}/var/run/* + 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 ;; stop) - if [ -f $MBSE_ROOT/var/run/mbtask ]; 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` + su mbse -c '${MBSE_ROOT}/bin/mbstat close wait -quiet' >/dev/null + kill -15 `cat ${MBSE_ROOT}/var/run/mbtask` sleep 1 - if [ -f $MBSE_ROOT/var/run/mbtask ]; then + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then echo -n "." sleep 1 fi - if [ -f $MBSE_ROOT/var/run/mbtask ]; then + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then echo -n "." sleep 1 fi - if [ -f $MBSE_ROOT/var/run/mbtask ]; then + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then echo -n "." sleep 1 fi - if [ -f $MBSE_ROOT/var/run/mbtask ]; then - kill -9 `cat $MBSE_ROOT/var/run/mbtask` + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then + kill -9 `cat ${MBSE_ROOT}/var/run/mbtask` fi echo -n " done" fi diff --git a/script/init.Gentoo b/script/init.Gentoo index 7c067970..e27a7a05 100644 --- a/script/init.Gentoo +++ b/script/init.Gentoo @@ -10,18 +10,18 @@ MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'` -if [ "$MBSE_ROOT" = "" ]; then +if [ "${MBSE_ROOT}" = "" ]; then 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." +if [ ! -d ${MBSE_ROOT} ]; then + echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found." exit 1 fi -PATH=/sbin:/bin:/usr/sbin:/usr/bin:$MBSE_ROOT/bin -DAEMON=$MBSE_ROOT/bin/mbtask +PATH=/sbin:/bin:/usr/sbin:/usr/bin:${MBSE_ROOT}/bin +DAEMON=${MBSE_ROOT}/bin/mbtask NAME=mbsebbs DESC="MBSE BBS" @@ -34,14 +34,15 @@ depend() { start() { ebegin "Starting mbse" - 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 + rm -f ${MBSE_ROOT}/var/run/* + 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' + if [ -f ${MBSE_ROOT}/etc/config.data ]; then + su mbse -c '${MBSE_ROOT}/bin/mbstat open -quiet' echo -n "opened " fi eend $? "Loading error." @@ -51,16 +52,16 @@ start() { stop() { ebegin "Stopping mbse" - if [ -f $MBSE_ROOT/var/run/mbtask ]; 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 + su mbse -c '${MBSE_ROOT}/bin/mbstat close wait -quiet' >/dev/null echo -n " stopping mbtask" - kill `cat $MBSE_ROOT/var/run/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 + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then echo -n "." sleep 1 let i=i-1 @@ -68,8 +69,8 @@ stop() { doit=0 fi done - if [ -f $MBSE_ROOT/var/run/mbtask ]; then - kill -9 `cat $MBSE_ROOT/var/run/mbtask` + 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.NetBSD b/script/init.NetBSD index 35bd3678..042588ad 100644 --- a/script/init.NetBSD +++ b/script/init.NetBSD @@ -39,22 +39,20 @@ mbsebbs_start() export MBSE_ROOT - 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 2>&1 - echo -n " mbtask" - sleep 2 - if [ -f ${MBSE_ROOT}/etc/config.data ]; then - su mbse -c '${MBSE_ROOT}/bin/mbstat open -quiet' - echo ", opened bbs" - fi - else - echo " is already running" + rm -f ${MBSE_ROOT}/var/run/* + 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 2>&1 + echo -n " mbtask" + sleep 2 + if [ -f ${MBSE_ROOT}/etc/config.data ]; then + su mbse -c '${MBSE_ROOT}/bin/mbstat open -quiet' + echo ", opened bbs" fi } + mbsebbs_stop() { echo -n "Stopping mbsebbs:" @@ -77,7 +75,7 @@ mbsebbs_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 + su mbse -c '${MBSE_ROOT}/bin/mbstat close wait -quiet' >/dev/null kill -15 `cat ${MBSE_ROOT}/var/run/mbtask` sleep 1 if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then diff --git a/script/init.RedHat b/script/init.RedHat index e43551b6..f6cc4f1a 100644 --- a/script/init.RedHat +++ b/script/init.RedHat @@ -18,15 +18,15 @@ # Find the MBSE_ROOT from the /etc/passwd file. MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'` -if [ "$MBSE_ROOT" = "" ] +if [ "${MBSE_ROOT}" = "" ] then echo "MBSE BBS: No 'mbse' user in the password file." exit 1 fi -if [ ! -d $MBSE_ROOT ] +if [ ! -d ${MBSE_ROOT} ] then - echo "MBSE BBS: Home directory '$MBSE_ROOT' not found." + echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found." exit 1 fi @@ -67,27 +67,24 @@ 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* - $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 + rm -f ${MBSE_ROOT}/var/run/* + 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 ;; stop) echo -n "Shutting down MBSE BBS: " - if [ -f $MBSE_ROOT/var/run/mbtask ]; 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 + $SU mbse -c '${MBSE_ROOT}/bin/mbstat close wait -quiet' >/dev/null echo -n "done, " echo -n "stop mbtask: " killproc mbtask -15 diff --git a/script/init.Slackware b/script/init.Slackware index b626a8ef..65b005a1 100644 --- a/script/init.Slackware +++ b/script/init.Slackware @@ -10,15 +10,15 @@ # Find the MBSE_ROOT from the /etc/passwd file. MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'` -if [ "$MBSE_ROOT" = "" ] +if [ "${MBSE_ROOT}" = "" ] then echo "MBSE BBS: No 'mbse' user in the password file." exit 1 fi -if [ ! -d $MBSE_ROOT ] +if [ ! -d ${MBSE_ROOT} ] then - echo "MBSE BBS: Home directory '$MBSE_ROOT' not found." + echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found." exit 1 fi @@ -28,32 +28,29 @@ 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* - 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 + rm -f ${MBSE_ROOT}/var/run/* + 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/var/run/mbtask ]; 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 + su mbse -c '${MBSE_ROOT}/bin/mbstat close wait -quiet' >/dev/null echo -n "done, stopping mbtask" - kill -15 `cat $MBSE_ROOT/var/run/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 + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then echo -n "." sleep 1 let i=i-1 @@ -61,8 +58,8 @@ case "$1" in doit=0 fi done - if [ -f $MBSE_ROOT/var/run/mbtask ]; then - kill -9 `cat $MBSE_ROOT/var/run/mbtask` + if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then + kill -9 `cat ${MBSE_ROOT}/var/run/mbtask` fi echo " done." else @@ -71,10 +68,10 @@ case "$1" in ;; status) echo -n "MBSE BBS status: " - if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then + 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`" + echo "mbtask running with pid `cat ${MBSE_ROOT}/var/run/mbtask`" fi ;; restart|reload) diff --git a/script/init.SuSE b/script/init.SuSE index ccc6f91c..1709ea64 100644 --- a/script/init.SuSE +++ b/script/init.SuSE @@ -14,15 +14,15 @@ # Find the MBSE_ROOT from the /etc/passwd file. MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'` -if [ "$MBSE_ROOT" = "" ] +if [ "${MBSE_ROOT}" = "" ] then echo "MBSE BBS: No 'mbse' user in the password file." exit 1 fi -if [ ! -d $MBSE_ROOT ] +if [ ! -d ${MBSE_ROOT} ] then - echo "MBSE BBS: Home directory '$MBSE_ROOT' not found." + echo "MBSE BBS: Home directory '${MBSE_ROOT}' not found." exit 1 fi @@ -31,31 +31,26 @@ 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* - 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 + rm -f ${MBSE_ROOT}/var/run/* + 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/var/run/mbtask ]; 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 + 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 + killproc `cat ${MBSE_ROOT}/var/run/mbtask` -15 sleep 3 echo "done." else @@ -68,7 +63,7 @@ case "$1" in ;; status) echo -n "MBSE BBS status: " - if [ ! -f $MBSE_ROOT/var/run/mbtask ]; then + if [ ! -f ${MBSE_ROOT}/var/run/mbtask ]; then echo "mbtask is NOT running" else echo "mbtask Ok" diff --git a/script/installinit.sh b/script/installinit.sh index 3a806fe3..2607981d 100644 --- a/script/installinit.sh +++ b/script/installinit.sh @@ -3,7 +3,7 @@ # # Installation script to install bootscripts. # -PATH=/bin:/sbin:/usr/bin:/usr/sbin:$MBSE_ROOT/bin +PATH=/bin:/sbin:/usr/bin:/usr/sbin:${MBSE_ROOT}/bin DISTNAME= DISTVERS= DISTINIT= @@ -39,7 +39,7 @@ EOF exit 2 fi -if [ "$MBSE_ROOT" = "" ]; then +if [ "${MBSE_ROOT}" = "" ]; then echo "*** The MBSE_ROOT doesn't exist ***" log "!" "Aborted, MBSE_ROOT variable doesn't exist" exit 2 @@ -154,9 +154,9 @@ if [ "$DISTNAME" = "Slackware" ]; then log "+" "Adding SystemV Slackware $DISTVERS MBSE BBS start/stop scripts" cp init.Slackware $DISTINIT chmod 755 $DISTINIT - if [ -f $MBSE_ROOT/bin/mbse.start ]; then + if [ -f ${MBSE_ROOT}/bin/mbse.start ]; 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 + 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