This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-mbse/script/installinit.sh

403 lines
12 KiB
Bash
Raw Normal View History

2001-08-17 05:46:24 +00:00
#
2001-12-22 22:42:59 +00:00
# $Id$
2001-08-17 05:46:24 +00:00
#
2001-12-22 22:42:59 +00:00
# Installation script to install bootscripts.
2001-08-17 05:46:24 +00:00
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin:$MBSE_ROOT/bin
DISTNAME=
DISTVERS=
DISTINIT=
SU="su"
2001-08-25 20:37:27 +00:00
OSTYPE=`uname -s`
2001-08-17 05:46:24 +00:00
#------------------------------------------------------------------------
#
# Logging procedure, needs two parameters.
#
log() {
/bin/echo `date +%d-%b-%y\ %X ` $1 $2 >> installinit.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"
}
#------------------------------------------------------------------------
#
log "+" "installinit started"
# Basic checks.
if [ `whoami` != "root" ]; then
cat << EOF
*** Run $0 as root only! ***
Because some of the system files must be changed, you must be root
to use this script.
*** SETUP aborted ***
EOF
log "!" "Aborted, not root"
exit 2
fi
if [ "$MBSE_ROOT" = "" ]; then
echo "*** The MBSE_ROOT doesn't exist ***"
log "!" "Aborted, MBSE_ROOT variable doesn't exist"
exit 2
fi
# First do various tests to see which Linux distribution this is.
#
2001-08-25 20:37:27 +00:00
if [ "$OSTYPE" = "Linux" ]; then
if [ -f /etc/slackware-version ]; then
# Slackware 7.0 and later
DISTNAME="Slackware"
DISTVERS=`cat /etc/slackware-version`
2001-08-17 05:46:24 +00:00
else
2001-08-25 20:37:27 +00:00
if [ -f /etc/debian_version ]; then
# Debian, at least since version 2.2
DISTNAME="Debian"
DISTVERS=`cat /etc/debian_version`
else
if [ -f /etc/SuSE-release ]; then
DISTNAME="SuSE"
DISTVERS=`cat /etc/SuSE-release | grep VERSION | awk '{ print $3 }'`
2001-08-17 05:46:24 +00:00
else
2002-01-13 14:07:43 +00:00
# Mandrake test before RedHat, Mandrake has a redhat-release
# file also which is a symbolic link to mandrake-release.
if [ -f /etc/mandrake-release ]; then
DISTNAME="Mandrake"
# Format: Linux Mandrake release 8.0 (Cooker) for i586
2002-01-20 20:26:30 +00:00
DISTVERS="`cat /etc/mandrake-release | awk '{ print $4 }'`"
2002-01-13 14:07:43 +00:00
else
if [ -f /etc/redhat-release ]; then
DISTNAME="RedHat"
if [ -z "`grep e-smith /etc/redhat-release`" ]; then
DISTVERS=`cat /etc/redhat-release | awk '{ print $5 }'`
else
DISTVERS=`cat /etc/redhat-release | awk '{ print $13 }' | tr -d \)`
fi
2001-08-17 05:46:24 +00:00
else
2001-08-25 20:37:27 +00:00
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
2003-11-10 19:06:32 +00:00
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
2001-08-25 20:37:27 +00:00
fi
2001-08-17 05:46:24 +00:00
fi
2001-08-25 20:37:27 +00:00
fi
2001-08-17 05:46:24 +00:00
fi
2001-08-25 20:37:27 +00:00
fi
2001-08-17 05:46:24 +00:00
fi
fi
2001-08-25 20:37:27 +00:00
if [ "$OSTYPE" = "FreeBSD" ]; then
DISTNAME="FreeBSD"
DISTVERS=`uname -r`
PW="pw "
fi
if [ "$OSTYPE" = "NetBSD" ]; then
DISTNAME="NetBSD"
DISTVERS=`uname -r`
fi
2001-08-17 05:46:24 +00:00
2001-08-25 20:37:27 +00:00
log "+" "Distribution $OSTYPE $DISTNAME $DISTVERS"
2001-08-17 05:46:24 +00:00
#--------------------------------------------------------------------------
#
2002-05-06 18:53:17 +00:00
# Adding scripts for SuSE, from 7.1 and later in /etc/init.d
2001-08-17 05:46:24 +00:00
#
if [ "$DISTNAME" = "SuSE" ]; then
2002-05-06 18:53:17 +00:00
if [ "$DISTVERS" '>' "7.1" ]; then
DISTDIR="/etc"
else
DISTDIR="/sbin"
fi
DISTINIT="$DISTDIR/init.d/mbsed"
echo "Installing SystemV init scripts for SuSE $DISTVERS"
log "+" "Installing SystemV init scripts for SuSE $DISTVERS"
2001-08-17 05:46:24 +00:00
echo "Adding $DISTINIT"
2002-02-04 15:18:06 +00:00
cp init.SuSE $DISTINIT
chmod 755 $DISTINIT
2001-08-17 05:46:24 +00:00
echo "Making links for start/stop in runlevel 2"
2002-05-06 18:53:17 +00:00
ln -s ../mbsed $DISTDIR/init.d/rc2.d/K05mbsed
ln -s ../mbsed $DISTDIR/init.d/rc2.d/S99mbsed
2001-08-17 05:46:24 +00:00
echo "Making links for start/stop in runlevel 3"
2002-05-06 18:53:17 +00:00
ln -s ../mbsed $DISTDIR/init.d/rc3.d/K05mbsed
ln -s ../mbsed $DISTDIR/init.d/rc3.d/S99mbsed
echo "Making links for start/stop in runlevel 5"
ln -s ../mbsed $DISTDIR/init.d/rc5.d/K05mbsed
ln -s ../mbsed $DISTDIR/init.d/rc5.d/S99mbsed
echo "SuSE $DISTVERS SystemV init configured"
log "+" "SuSE $DISTVERS SystemV init configured"
2001-08-17 05:46:24 +00:00
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
else
DISTINIT="/etc/rc.d/init.d/mbsed"
2003-11-10 19:06:32 +00:00
echo "Adding SystemV Slackware $DISTVERS MBSE BBS start/stop scripts"
log "+" "Adding SystemV Slackware $DISTVERS MBSE BBS start/stop scripts"
2001-08-17 05:46:24 +00:00
checkrcdir
2002-02-04 15:18:06 +00:00
cp init.Slackware $DISTINIT
2001-08-17 05:46:24 +00:00
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
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
#--------------------------------------------------------------------------
#
# Adding scripts for RedHat, e-smith and Mandrake
2001-08-17 05:46:24 +00:00
#
if [ "$DISTNAME" = "RedHat" ] || [ "$DISTNAME" = "Mandrake" ]; then
log "+" "Adding RedHat/E-Smith/Mandrake SystemV init scripts"
2001-08-17 05:46:24 +00:00
DISTINIT="/etc/rc.d/init.d/mbsed"
#
# Extra tests are added for the RedHat e-smith server distribution,
# this is a special distribution based on RedHat.
2001-08-17 05:46:24 +00:00
#
2002-01-20 20:26:30 +00:00
if [ -f /etc/mandrake-release ]; then
RHN="Mandrake"
2001-08-17 05:46:24 +00:00
else
2002-01-20 20:26:30 +00:00
if [ -f /etc/redhat-release ]; then
if [ -z "`grep e-smith /etc/redhat-release`" ]; then
RHN="RedHat"
else
RHN="e-smith based on RedHat"
fi
2001-08-17 05:46:24 +00:00
else
echo "You are in big trouble."
fi
fi
echo "Adding startup file $DISTINIT"
2002-02-04 15:18:06 +00:00
cp init.RedHat $DISTINIT
chmod 755 $DISTINIT
echo "Making links for stop in runlevels 0 and 6"
if [ -f /etc/rc.d/rc0.d/K05mbsed ]; then
rm /etc/rc.d/rc0.d/K05mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc0.d/K05mbsed
if [ -f /etc/rc.d/rc6.d/K05mbsed ]; then
rm /etc/rc.d/rc6.d/K05mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc6.d/K05mbsed
echo "Making links for start in runlevels 3 and 5"
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
if [ -f /etc/rc.d/rc5.d/S95mbsed ]; then
rm /etc/rc.d/rc5.d/S95mbsed
fi
ln -s ../init.d/mbsed /etc/rc.d/rc5.d/S95mbsed
if [ "$RHN" = "e-smith based on RedHat" ]; then
echo "Making link for start in runlevel 7"
if [ -f /etc/rc.d/rc7.d/S95mbsed ]; then
rm /etc/rc.d/rc7.d/S95mbsed
fi
2002-02-04 15:18:06 +00:00
ln -s ../init.d/mbsed /etc/rc.d/rc7.d/S95mbsed
fi
2001-08-17 05:46:24 +00:00
fi
#--------------------------------------------------------------------------
#
# Adding scripts for Debian
#
#
if [ "$DISTNAME" = "Debian" ]; then
echo "You are running Debian Linux $DISTVERS"
log "+" "Adding Debian SystemV init script"
DISTINIT="/etc/init.d/mbsebbs"
2002-02-04 15:18:06 +00:00
cp init.Debian $DISTINIT
2001-08-17 05:46:24 +00:00
chmod 755 $DISTINIT
update-rc.d mbsebbs defaults
echo "Debian install ready."
log "+" "Debian SystemV init script installed"
fi
2001-08-25 20:37:27 +00:00
2003-11-10 19:06:32 +00:00
#-------------------------------------------------------------------------
#
# Adding scripts for Gentoo
#
#
if [ "$DISTNAME" = "Gentoo" ]; then
echo "You are running Gentoo Linux $DISTVERS"
log "+" "Adding Gentoo init script"
DISTINIT="/etc/init.d/mbsebbs"
cp init.Gentoo $DISTINIT
chmod 755 $DISTINIT
rc-update add mbsebbs default
2003-11-10 19:06:32 +00:00
echo "Gentoo install ready."
log "+" "Gentoo init script installed"
fi
2001-08-25 20:37:27 +00:00
#--------------------------------------------------------------------------
#
2003-01-11 21:46:27 +00:00
# Adding scripts for NetBSD
2001-08-25 20:37:27 +00:00
#
#
2003-01-11 21:46:27 +00:00
if [ "$DISTNAME" = "NetBSD" ]; then
2001-08-25 20:37:27 +00:00
#
2003-01-11 21:46:27 +00:00
# NetBSD init
2001-08-25 20:37:27 +00:00
#
DISTINIT="$MBSE_ROOT/etc/rc"
echo "Adding $DISTNAME style MBSE BBS start/stop scripts"
log "+" "Adding $DISTNAME style MBSE BBS start/stop scripts"
2001-12-22 22:42:59 +00:00
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 ""
2001-08-25 20:37:27 +00:00
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
fi
2003-01-11 21:46:27 +00:00
#--------------------------------------------------------------------------
#
# Adding scripts for FreeBSD
#
#
if [ "$DISTNAME" = "FreeBSD" ]; then
#
# FreeBSD init
#
2003-01-11 22:25:47 +00:00
DISTINIT="/usr/local/etc/rc.d/mbse.sh"
2003-01-11 21:46:27 +00:00
echo "Adding $DISTNAME style MBSE BBS start/stop script"
log "+" "Adding $DISTNAME style MBSE BBS start/stop script"
cp init.FreeBSD $DISTINIT
chmod 0755 $DISTINIT
fi
2001-08-25 20:37:27 +00:00
2001-08-17 05:46:24 +00:00
echo
echo "Please note, your MBSE BBS startup file is \"$DISTINIT\""
echo