Dropped support for Slackware pre 7.0 and changed NetBSD startup

This commit is contained in:
Michiel Broek
2003-12-19 22:29:25 +00:00
parent e2bf92cb27
commit f3b74ad244
8 changed files with 175 additions and 244 deletions

111
script/init.NetBSD Normal file
View File

@@ -0,0 +1,111 @@
#!/bin/sh
#
# $Id$
#
# PROVIDE: mbsebbs
# REQUIRE: root beforenetlkm mountcritlocal tty
# it does not really require beforenetlkm.
. /etc/rc.subr
name="mbsebbs"
rcvar=$name
start_cmd="mbsebbs_start"
stop_cmd="mbsebbs_stop"
reload_cmd="mbsebbs_reload"
extra_commands="reload"
mbsebbs_start()
{
echo -n "Starting mbsebbs:"
# Find the MBSE_ROOT from the /etc/passwd file.
MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
if [ "${MBSE_ROOT}" = "" ]
then
echo " no 'mbse' user in the password file."
return
fi
if [ ! -d ${MBSE_ROOT} ]
then
echo " home directory '${MBSE_ROOT}' not found."
return
fi
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
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
else
echo " is already running"
fi
}
mbsebbs_stop()
{
echo -n "Stopping mbsebbs:"
# Find the MBSE_ROOT from the /etc/passwd file.
MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
if [ "${MBSE_ROOT}" = "" ]; then
echo " no 'mbse' user in the password file."
return
fi
if [ ! -d ${MBSE_ROOT} ]
then
echo " home directory '${MBSE_ROOT}' not found."
return
fi
export MBSE_ROOT
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`
sleep 1
if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then
echo -n "."
sleep 1
fi
if [ -f ${MBSE_ROOT}/var/run/mbtask ]; then
echo -n "."
sleep 1
fi
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`
fi
echo " done"
else
echo " was not running"
fi
}
mbsebbs_reload()
{
mbsebbs_start
mbsebbs_stop
}
load_rc_config $name
run_rc_command "$1"

View File

@@ -20,31 +20,6 @@ log() {
# Check one subdirectory
#
checkdir() {
if [ ! -d $1 ]; then
mkdir $1
log "+" "[$?] created directory $1"
fi
}
# Check /etc/rc.d subdirs
#
checkrcdir() {
checkdir "/etc/rc.d/init.d"
checkdir "/etc/rc.d/rc0.d"
checkdir "/etc/rc.d/rc1.d"
checkdir "/etc/rc.d/rc2.d"
checkdir "/etc/rc.d/rc3.d"
checkdir "/etc/rc.d/rc4.d"
checkdir "/etc/rc.d/rc5.d"
checkdir "/etc/rc.d/rc6.d"
}
#------------------------------------------------------------------------
#
@@ -103,26 +78,20 @@ if [ "$OSTYPE" = "Linux" ]; then
DISTVERS=`cat /etc/redhat-release | awk '{ print $13 }' | tr -d \)`
fi
else
if [ -f /etc/rc.d/rc.0 ] && [ -f /etc/rc.d/rc.local ]; then
# If Slackware wasn't detected yet it is version 4.0 or older.
DISTNAME="Slackware"
DISTVERS="Old"
else
if [ -f /etc/gentoo-release ]; then
DISTNAME="Gentoo"
DISTVERS=`cat /etc/gentoo-release | awk '{ print $5 }'`
else
DISTNAME="Unknown"
log "!" "unknown distribution, collecting data"
log "-" "`uname -a`"
log "-" "`ls -la /etc`"
echo "Failed to install bootscripts, unknown Linux distribution."
echo "Please mail the file `pwd`/script/installinit.log to mbroek@users.sourceforge.net"
echo "or send it as file attach to Michiel Broek at 2:280/2802@Fidonet."
echo "Add information about the distribution you use in the message."
exit 1;
fi
fi
if [ -f /etc/gentoo-release ]; then
DISTNAME="Gentoo"
DISTVERS=`cat /etc/gentoo-release | awk '{ print $5 }'`
else
DISTNAME="Unknown"
log "!" "unknown distribution, collecting data"
log "-" "`uname -a`"
log "-" "`ls -la /etc`"
echo "Failed to install bootscripts, unknown Linux distribution."
echo "Please mail the file `pwd`/script/installinit.log to mbroek@users.sourceforge.net"
echo "or send it as file attach to Michiel Broek at 2:280/2802@Fidonet."
echo "Add information about the distribution you use in the message."
exit 1;
fi
fi
fi
fi
@@ -179,74 +148,43 @@ fi
# Adding scripts for Slackware
#
if [ "$DISTNAME" = "Slackware" ]; then
if [ "$DISTVERS" = "Old" ] || [ "$DISTVERS" = "7.0.0" ]; then
#
# Slackware before version 7.1
#
DISTINIT="$MBSE_ROOT/etc/rc"
echo "Adding old style Slackware MBSE BBS start/stop scripts"
log "+" "Adding old style Slackware MBSE BBS start/stop scripts"
if [ "`grep MBSE /etc/rc.d/rc.local`" = "" ]; then
log "+" "Adding $MBSE_ROOT/etc/rc to /etc/rc.d/rc.local"
mv /etc/rc.d/rc.local /etc/rc.d/rc.local.mbse
cat /etc/rc.d/rc.local.mbse >/etc/rc.d/rc.local
echo "# Start MBSE BBS" >>/etc/rc.d/rc.local
echo "$MBSE_ROOT/etc/rc" >>/etc/rc.d/rc.local
chmod 755 /etc/rc.d/rc.local
echo " Added $MBSE_ROOT/etc/rc to /etc/rc.d/rc.local"
echo " /etc/rc.d/rc.local.mbse is a backup file."
echo ""
echo " You must manualy insert the lines '$MBSE_ROOT/etc/rc.shutdown'"
echo " into /etc/rc.d/rc.0 and /etc/rc.d/rc.K If you don't do it"
echo " everything will work also, but MBSE BBS isn't proper closed"
echo " if you halt or reboot your system."
fi
cp mbse.start $MBSE_ROOT/bin
cp mbse.stop $MBSE_ROOT/bin
cp rc $MBSE_ROOT/etc
cp rc.shutdown $MBSE_ROOT/etc
chown mbse.bbs $MBSE_ROOT/bin/mbse.start $MBSE_ROOT/bin/mbse.stop
chmod 755 $MBSE_ROOT/bin/mbse.start $MBSE_ROOT/bin/mbse.stop
chown root.root $MBSE_ROOT/etc/rc $MBSE_ROOT/etc/rc.shutdown
chmod 744 $MBSE_ROOT/etc/rc $MBSE_ROOT/etc/rc.shutdown
mkdir -p /etc/rc.d/init.d
DISTINIT="/etc/rc.d/init.d/mbsed"
echo "Adding SystemV Slackware $DISTVERS MBSE BBS start/stop scripts"
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
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
DISTINIT="/etc/rc.d/init.d/mbsed"
echo "Adding SystemV Slackware $DISTVERS MBSE BBS start/stop scripts"
log "+" "Adding SystemV Slackware $DISTVERS MBSE BBS start/stop scripts"
checkrcdir
cp init.Slackware $DISTINIT
chmod 755 $DISTINIT
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
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
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"
echo "Making links for start/stop in runlevel 3"
mkdir -p /etc/rc.d/rc3.d /etc/rc.d/rc4.d
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
@@ -352,37 +290,11 @@ if [ "$DISTNAME" = "NetBSD" ]; then
#
# NetBSD init
#
DISTINIT="$MBSE_ROOT/etc/rc"
echo "Adding $DISTNAME style MBSE BBS start/stop scripts"
log "+" "Adding $DISTNAME style MBSE BBS start/stop scripts"
if [ -f /etc/rc.local ]; then
if [ "`grep MBSE /etc/rc.local`" = "" ]; then
log "+" "Adding $MBSE_ROOT/etc/rc to existing /etc/rc.local"
mv /etc/rc.local /etc/rc.local.mbse
cat /etc/rc.local.mbse >/etc/rc.local
echo "# Start MBSE BBS" >>/etc/rc.local
echo "$MBSE_ROOT/etc/rc" >>/etc/rc.local
chmod 644 /etc/rc.local
echo " Added $MBSE_ROOT/etc/rc to /etc/rc.local"
echo " /etc/rc.local.mbse is a backup file."
echo ""
fi
else
log "+" "Adding $MBSE_ROOT/etc/rc to new /etc/rc.local"
echo "# Start MBSE BBS" >/etc/rc.local
echo "$MBSE_ROOT/etc/rc" >>/etc/rc.local
chmod 644 /etc/rc.local
echo " Added $MBSE_ROOT/etc/rc to /etc/rc.local"
echo ""
fi
cp mbse.start $MBSE_ROOT/bin
cp mbse.stop $MBSE_ROOT/bin
cp rc $MBSE_ROOT/etc
cp rc.shutdown $MBSE_ROOT/etc
chown mbse.bbs $MBSE_ROOT/bin/mbse.start $MBSE_ROOT/bin/mbse.stop
chmod 755 $MBSE_ROOT/bin/mbse.start $MBSE_ROOT/bin/mbse.stop
chown `id -un`.`id -gn` $MBSE_ROOT/etc/rc $MBSE_ROOT/etc/rc.shutdown
chmod 744 $MBSE_ROOT/etc/rc $MBSE_ROOT/etc/rc.shutdown
DISTINIT="/etc/rc.d/mbsebbs"
echo "Adding $DISTNAME style MBSE BBS start/stop script"
log "+" "Adding $DISTNAME style MBSE BBS start/stop script"
cp init.NetBSD $DISTINIT
chmod 0755 $DISTINIT
fi

View File

@@ -1,33 +0,0 @@
#
# BBS Startup script, should be run as BBS owner.
# Note: This is only used on Slackware systems until 7.0.0 and NetBSD.
#
# $Id$
#
if [ "$MBSE_ROOT" = "" ]; then
export MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
fi
# If installed, start the BBS.
#
if [ -f $MBSE_ROOT/bin/mbtask ]; then
echo -n "Starting MBSE BBS: "
rm -f $MBSE_ROOT/sema/*
rm -f $MBSE_ROOT/var/*.LCK
rm -f $MBSE_ROOT/tmp/mb*
cd $MBSE_ROOT
$MBSE_ROOT/bin/mbtask >/dev/null
echo -n "mbtask "
sleep 2
if [ -f $MBSE_ROOT/etc/config.data ]; then
$MBSE_ROOT/bin/mbstat open -quiet
echo -n "opened "
fi
echo "done"
else
echo "mbtask not available!"
exit 1
fi

View File

@@ -1,40 +0,0 @@
#
# BBS Shutdown script, should be run as BBS owner.
# Note: this is only used on old Slackware and NetBSD systems.
#
# On FreeBSD it needs the psmisc package.
#
# $Id$
#
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:$MBSE_ROOT/bin:"
if [ "$MBSE_ROOT" = "" ]; then
export MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
fi
if [ -f $MBSE_ROOT/bin/mbtask ]; then
echo -n "Shutdown MBSE BBS: "
if [ -f $MBSE_ROOT/etc/config.data ]; then
echo -n "closing the bbs "
cd $MBSE_ROOT
$MBSE_ROOT/bin/mbstat close wait -quiet
echo -n "done, "
fi
# Now kill the daemons
echo -n "kill "
base=`basename mbtask`
pid=`pidof $base`
echo -n "mbtask "
if ps h $pid >/dev/null 2>&1; then
kill $pid
RC=$?
[ $RC -eq 0 ] && echo -n "ok " || echo -n "failed "
fi
echo ""
else
echo "mbtask not available!"
fi
#

View File

@@ -1,15 +0,0 @@
#!/bin/sh
#
# $MBSE_ROOT/etc/rc: BBS Startup script for old Slackware and NetBSD
#
# $Id$
# Remove stale tempfiles from cron.
rm -f /tmp/cron.mbse.*
if [ "$MBSE_ROOT" = "" ]; then
export MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
fi
su - mbse -c $MBSE_ROOT/bin/mbse.start

View File

@@ -1,14 +0,0 @@
#!/bin/sh
#
# /opt/mbse/etc/rc.shutdown: BBS Shutdown script for Slackware and NetBSD.
#
# $Id$
if [ "$MBSE_ROOT" = "" ]; then
export MBSE_ROOT=`cat /etc/passwd | grep mbse: | awk -F ':' '{ print $6}'`
fi
su mbse -c $MBSE_ROOT/bin/mbse.stop
sleep 2
#