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/SETUP.sh

551 lines
15 KiB
Bash
Raw Normal View History

2001-08-25 19:53:11 +00:00
#!/bin/bash
2001-08-17 05:46:24 +00:00
#
# $Id$
#
2001-08-17 05:46:24 +00:00
# Basic setup script for MBSE BBS
#
# (C) Michiel Broek
2001-08-17 05:46:24 +00:00
#
# Customisation section, change the next variables to your need.
# However, all docs refer to the setup below.
#
# Basic bbs root directory.
clear
MHOME=/opt/mbse
PATH=/bin:/sbin:/usr/bin:/usr/sbin:
DISTNAME=
DISTVERS=
2001-08-25 19:53:11 +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 >> SETUP.log
}
#------------------------------------------------------------------------
#
cat << EOF
2003-01-11 21:46:27 +00:00
MBSE BBS for Unix, first time setup. Checking your system..."
2001-08-17 05:46:24 +00:00
If anything goes wrong with this script, look at the output of
the file SETUP.log that is created by this script in this
directory. If you can't get this script to run on your system,
mail this logfile to Michiel Broek at 2:280/2802 or email it
2004-09-25 12:22:44 +00:00
to mbroek@mbse.dds.nl
2001-08-17 05:46:24 +00:00
EOF
echo -n "Press ENTER to start the basic checks "
read junk
log "+" "MBSE BBS $0 started by `whoami`"
log "+" "Current directory is `pwd`"
2001-08-25 19:53:11 +00:00
# Check the OS type, only Linux for now.
#
2004-02-22 12:51:42 +00:00
if [ "$OSTYPE" != "Linux" ] && [ "$OSTYPE" != "FreeBSD" ] && [ "$OSTYPE" != "NetBSD" ] && [ "$OSTYPE" != "Darwin" ]; then
2001-08-25 19:53:11 +00:00
cat << EOF
Your are trying to install MBSE BBS on a $OSTYPE system, however
2004-02-22 12:51:42 +00:00
at this time only Linux, FreeBSD, NetBSD and Darwin (OS X) is supported.
2002-01-10 21:36:24 +00:00
2001-08-25 19:53:11 +00:00
EOF
log "!" "Aborted, OS is $OSTYPE"
exit 2
fi
2001-08-17 05:46:24 +00:00
#
# First do various tests to see which Linux distribution this is.
#
2001-08-25 19:53:11 +00:00
if [ "$OSTYPE" = "Linux" ]; then
PW=
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 19:53:11 +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
DISTVERS=`cat /etc/mandrake-release | awk '{ print $4 }'`
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
2004-02-22 12:51:42 +00:00
if [ -f /etc/gentoo-release ]; then
DISTNAME="Gentoo"
DISTVERS=`cat /etc/gentoo-release | awk '{ print $5 }'`
else
DISTNAME="Unknown"
fi
2001-08-17 05:46:24 +00:00
fi
2001-08-25 19:53:11 +00:00
fi
2001-08-17 05:46:24 +00:00
fi
2001-08-25 19:53:11 +00:00
fi
2001-08-17 05:46:24 +00:00
fi
2001-08-25 19:53:11 +00:00
fi # Linux
if [ "$OSTYPE" = "FreeBSD" ]; then
DISTNAME="FreeBSD"
DISTVERS=`uname -r`
PW="pw "
2001-08-17 05:46:24 +00:00
fi
2002-01-10 21:36:24 +00:00
if [ "$OSTYPE" = "NetBSD" ]; then
DISTNAME="NetBSD"
DISTVERS=`uname -r`
fi
2004-02-22 12:51:42 +00:00
if [ "$OSTYPE" = "Darwin" ]; then
DISTNAME="Darwin"
DISTVERS=`uname -r`
fi
2001-08-25 19:53:11 +00:00
log "+" "Detected \"${OSTYPE}\" (${HOSTTYPE}) \"${DISTNAME}\" version \"${DISTVERS}\""
2001-08-17 05:46:24 +00:00
# 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 variable exists: $MBSE_ROOT ***"
echo "*** SETUP aborted ***"
log "!" "Aborted, MBSE_ROOT variable exists: ${MBSE_ROOT}"
exit 2
fi
2001-12-02 16:07:00 +00:00
if [ "`grep -w mbse: /etc/passwd`" != "" ]; then
2001-08-17 05:46:24 +00:00
echo "*** User 'mbse' already exists on this system ***"
echo "*** SETUP aborted ***"
log "!" "Aborted, user 'mbse' already exists on this system"
exit 2
fi
2001-12-02 16:07:00 +00:00
if [ "`grep -w bbs: /etc/group`" != "" ]; then
2001-08-17 05:46:24 +00:00
echo "*** Group 'bbs' already exists on this system ***"
echo "*** SETUP aborted ***"
log "!" "Aborted, group 'bbs' already exists on this system"
exit 2
fi
if [ -f /etc/passwd.lock ]; then
echo "*** The password file is locked, make sure that nobody"
echo " is using any password utilities. ***"
echo "*** SETUP aborted ***"
log "!" "Aborted, password file is locked"
exit 2
fi
clear
2001-08-25 19:53:11 +00:00
if [ "$OSTYPE" = "Linux" ]; then
if [ -d /opt ]; then
log "+" "Directory /opt already present"
else
mkdir /opt
log "+" "[$?] Directory /opt created"
2001-08-17 05:46:24 +00:00
echo "Directory /opt created."
2001-08-25 19:53:11 +00:00
fi
fi
2004-02-22 12:51:42 +00:00
if [ "$OSTYPE" = "FreeBSD" ] || [ "$OSTYPE" = "NetBSD" ] || [ "$OSTYPE" = "Darwin" ]; then
2001-08-25 19:53:11 +00:00
#
2004-02-22 12:51:42 +00:00
# FreeBSD/NetBSD/Darwin uses /usr/local for extra packages
# and doesn't use /opt.
2001-08-25 19:53:11 +00:00
# Also using /opt means that we are in the root partition which
# by default is very small. We put everything in /usr/local/opt
# and create symlinks to it.
#
if [ -d /opt ]; then
log "+" "Directory /opt already present"
else
if [ -d /usr/local/opt ]; then
log "+" "Directory /usr/local/opt already present"
else
mkdir -p /usr/local/opt
log "+" "[$?] Directory /usr/local/opt created"
echo "Directory /usr/local/opt created."
fi
ln -s /usr/local/opt /opt
log "+" "[$?] Link /opt to /usr/local/opt created"
echo "Link /opt to /usr/local/opt created."
fi
2001-08-17 05:46:24 +00:00
fi
cat << EOF
Basic checks done.
2001-08-25 19:53:11 +00:00
The detected $OSTYPE distribution is $DISTNAME $DISTVERS
2001-08-17 05:46:24 +00:00
Everything looks allright to start the installation now.
Next the script will install a new group 'bbs' and two new
users, 'mbse' which is the bbs system account, and 'bbs' which
is the login account for bbs users. This account will have no
password! The shell for this account is the main bbs program.
One final important note: This script will make changes to some
of your system files. Because I don't have access to all kinds of
distributions and configurations there is no garantee that this
script is perfect. Please make sure you have a recent system backup.
Also make sure you have resque boot disks and know how to repair
your system. It might also be wise to login as root on another
virtual console incase something goes wrong with system login.
2004-02-22 12:51:42 +00:00
Darwin (OS X) Users must install the .dmg image of user utils
available on Version Tracker and within this archive prior
to continuing the installation.
2001-08-17 05:46:24 +00:00
If you are not sure, or forgot something, hit Control-C now or
EOF
echo -n " press Enter to start the installation "
read junk
clear
#------------------------------------------------------------------------
#
# The real work starts here
#
log "+" "Starting installation"
echo "Installing MBSE BBS for the first time..."
echo ""
echo -n "Adding group 'bbs'"
2001-08-25 19:53:11 +00:00
$PW groupadd bbs
2001-08-17 05:46:24 +00:00
log "+" "[$?] Added group bbs"
2001-08-17 05:46:24 +00:00
echo -n ", user 'mbse'"
2001-08-25 19:53:11 +00:00
if [ "$OSTYPE" = "Linux" ]; then
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G uucp -m -s /bin/bash mbse
fi
if [ "$OSTYPE" = "FreeBSD" ]; then
2001-12-22 22:42:59 +00:00
pw useradd mbse -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/local/bin/bash
2001-08-25 19:53:11 +00:00
fi
2002-01-10 21:36:24 +00:00
if [ "$OSTYPE" = "NetBSD" ]; then
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/pkg/bin/bash mbse
fi
2004-02-22 12:51:42 +00:00
if [ "$OSTYPE" = "Darwin" ]; then
useradd mbse -c "MBSE BBS Admin" -d $MHOME -g bbs -s /bin/bash
fi
2001-08-17 05:46:24 +00:00
log "+" "[$?] Added user mbse"
2004-09-25 13:17:23 +00:00
chmod 755 $MHOME
log "+" "[$?] chmod 755 $MHOME"
2001-08-17 05:46:24 +00:00
echo -n " writing '$MHOME/.profile'"
cat << EOF >$MHOME/.profile
# profile for mbse
#
export PATH=\$HOME/bin:\$PATH
export MBSE_ROOT=\$HOME
export GOLDED=\$HOME/etc
# For xterm on the Gnome desktop:
cd \$HOME
EOF
echo ""
log "+" "Created $MHOME/.profile"
# On some systems there is a .bashrc file in the users homedir.
# It must be removed.
if [ -f $MHOME/.bashrc ] || [ -f $MHOME/.bash_profile ]; then
echo "Removing '$MHOME/.bash*'"
rm -f $MHOME/.bash*
log "+" "Removed $MHOME/.bash* files"
fi
echo ""
echo "Now set the login password for user 'mbse'"
passwd mbse
log "+" "[$?] Password is set for user mbse"
2001-08-25 19:53:11 +00:00
2001-08-17 05:46:24 +00:00
echo -n "Adding user 'bbs'"
2001-08-25 19:53:11 +00:00
if [ ! -d $MHOME/home ]; then
mkdir $MHOME/home
log "+" "[$?] Created directory $MHOME/home"
fi
2003-01-11 21:46:27 +00:00
chown mbse $MHOME/home
log "+" "[$?] chown mbse $MHOME/home"
chgrp bbs $MHOME/home
log "+" "[$?] chgrp bbs $MHOME/home"
2002-01-10 21:36:24 +00:00
chmod 770 $MHOME/home
2002-02-08 15:38:32 +00:00
log "+" "[$?] chmod 770 $MHOME/home"
2001-08-25 19:53:11 +00:00
if [ "$OSTYPE" = "Linux" ]; then
useradd -c "MBSE BBS Login" -d $MHOME/home/bbs -g bbs -s $MHOME/bin/mbnewusr bbs
2001-08-25 19:53:11 +00:00
log "+" "[$?] Added user bbs"
fi
if [ "$OSTYPE" = "FreeBSD" ]; then
pw useradd bbs -c "MBSE BBS Login" -d $MHOME/home/bbs -g bbs -s $MHOME/bin/mbnewusr
2001-08-25 19:53:11 +00:00
log "+" "[$?] Added user bbs"
fi
2002-01-10 21:36:24 +00:00
if [ "$OSTYPE" = "NetBSD" ]; then
useradd -c "MBSE BBS Login" -d $MHOME/home/bbs -m -g bbs -s $MHOME/bin/mbnewusr bbs
log "+" "[$?] Added user bbs"
fi
2004-02-22 12:51:42 +00:00
if [ "$OSTYPE" = "Darwin" ]; then
useradd bbs -c "MBSE BBS Login" -d $MHOME/home/bbs -g bbs -s $MHOME/bin/mbnewuser
log "+" "[$?] Added user bbs"
fi
2001-08-17 05:46:24 +00:00
# Some systems (RedHat and Mandrake) insist on creating a users homedir.
2002-01-10 21:36:24 +00:00
# NetBSD gives errormessages when not creating a homedir, so we let it create.
2001-08-17 05:46:24 +00:00
# These are full of garbage we don't need. Kill it first.
if [ -d $MHOME/home/bbs ]; then
rm -Rf $MHOME/home/bbs
log "+" "[$?] Removed $MHOME/home/bbs"
fi
2001-08-25 19:53:11 +00:00
mkdir -m 0770 $MHOME/home/bbs
2001-08-17 05:46:24 +00:00
log "+" "[$?] mkdir $MHOME/home/bbs"
2003-01-11 21:46:27 +00:00
chown mbse $MHOME/home/bbs
log "+" "[$?] chown mbse $MHOME/home/bbs"
chgrp bbs $MHOME/home/bbs
log "+" "[$?] chgrp bbs $MHOME/home/bbs"
2001-08-17 05:46:24 +00:00
echo ", removing password:"
2001-08-25 19:53:11 +00:00
if [ "$OSTYPE" = "Linux" ]; then
echo -n "$$" >/etc/passwd.lock
if [ -f /etc/shadow ]; then
log "+" "Standard shadow password system"
2001-08-17 05:46:24 +00:00
# Not all systems are the same...
2002-01-13 14:07:43 +00:00
if [ "`grep bbs:\!\!: /etc/shadow`" != "" ]; then
2001-08-17 05:46:24 +00:00
sed /bbs:\!\!:/s/bbs:\!\!:/bbs::/ /etc/shadow >/etc/shadow.bbs
else
sed /bbs:\!:/s/bbs:\!:/bbs::/ /etc/shadow >/etc/shadow.bbs
fi
log "+" "[$?] removed password from user bbs"
mv /etc/shadow /etc/shadow.mbse
log "+" "[$?] made backup of /etc/shadow"
mv /etc/shadow.bbs /etc/shadow
log "+" "[$?] moved new /etc/shadow in place"
if [ "$DISTNAME" = "Debian" ] || [ "$DISTNAME" = "SuSE" ]; then
# Debian and SuSE use other ownership of /etc/shadow
chmod 640 /etc/shadow
chgrp shadow /etc/shadow
log "+" "[$?] Debian/SuSE style owner of /etc/shadow (0640 root.shadow)"
else
chmod 600 /etc/shadow
log "+" "[$?] Default style owner of /etc/shadow (0600 root.root)"
fi
echo " File /etc/shadow.mbse is your backup of /etc/shadow"
2001-08-25 19:53:11 +00:00
else
2001-08-17 05:46:24 +00:00
log "+" "Not a shadow password system"
2001-12-02 16:07:00 +00:00
if [ "`grep -w bbs:\!\!: /etc/passwd`" != "" ]; then
2001-08-17 05:46:24 +00:00
sed /bbs:\!\!:/s/bbs:\!\!:/bbs::/ /etc/passwd >/etc/passwd.bbs
else
sed /bbs:\!:/s/bbs:\!:/bbs::/ /etc/passwd >/etc/passwd.bbs
fi
log "+" "[$?] Removed password of user bbs"
mv /etc/passwd /etc/passwd.mbse
log "+" "[$?] Made backup of /etc/passwd"
mv /etc/passwd.bbs /etc/passwd
log "+" "[$?] Moved new /etc/passwd in place"
chmod 644 /etc/passwd
log "+" "[$?] Changed owner of /etc/passwd"
echo " File /etc/passwd.mbse is your backup of /etc/passwd"
2001-08-25 19:53:11 +00:00
fi
rm /etc/passwd.lock
fi
2004-02-22 12:51:42 +00:00
if [ "$OSTYPE" = "NetBSD" ] || [ "$OSTYPE" = "Darwin" ]; then
2002-01-10 21:36:24 +00:00
cat << EOF
READ THIS CAREFULLY NOW READ THIS CAREFULLY NOW
I don't know how to automatic remove the password for the "bbs"
2004-02-22 12:51:42 +00:00
user account in NetBSD/Darwin. You have to do this for me!
2002-01-10 21:36:24 +00:00
Next I start the editor you need to use, remove all the stars"
after the word Password, then save the file with "wq!"
EOF
echo -n "Press Enter when ready "
read junk
chpass bbs
fi
2001-08-25 19:53:11 +00:00
if [ "$OSTYPE" = "FreeBSD" ]; then
#
# FreeBSD has a util to remove a password
#
chpass -p "" bbs
log "+" "[$?] Removed password of user bbs"
2001-08-17 05:46:24 +00:00
fi
echo ""
2001-08-25 19:53:11 +00:00
2001-08-17 05:46:24 +00:00
if [ "`grep binkp /etc/services`" = "" ]; then
BINKD=TRUE
else
BINKD=FALSE
fi
if [ "`grep fido /etc/services`" = "" ]; then
FIDO=TRUE
else
FIDO=FALSE
fi
log "+" "Services: binkp=$BINKD fido=$FIDO"
if [ "$FIDO" = "TRUE" ] || [ "$BINKD" = "TRUE" ]; then
echo -n "Modifying /etc/services"
log "+" "Modifying /etc/services"
mv /etc/services /etc/services.mbse
cat /etc/services.mbse >/etc/services
echo "#" >>/etc/services
echo "# Unofficial for MBSE BBS" >>/etc/services
echo "#" >>/etc/services
if [ "$BINKD" = "TRUE" ]; then
echo -n ", binkp at port 24554"
echo "binkp 24554/tcp # mbcico IBN mode">>/etc/services
fi
if [ "$FIDO" = "TRUE" ]; then
2003-11-22 21:42:44 +00:00
echo -n ", fido at ports 60177, 60179"
2003-11-25 20:04:43 +00:00
echo "tfido 60177/tcp # mbcico ITN mode (alternate port)">>/etc/services
2001-08-17 05:46:24 +00:00
echo "fido 60179/tcp # mbcico IFC mode">>/etc/services
fi
chmod 644 /etc/services
echo ", done."
fi
2002-01-13 14:07:43 +00:00
if [ -f /etc/inetd.conf ]; then
log "+" "/etc/inetd.conf found, inetd system"
if [ "`grep mbcico /etc/inetd.conf`" = "" ]; then
2001-08-17 05:46:24 +00:00
echo -n "Modifying /etc/inetd.conf"
log "+" "Modifying /etc/inetd.conf"
mv /etc/inetd.conf /etc/inetd.conf.mbse
cat /etc/inetd.conf.mbse >/etc/inetd.conf
cat << EOF >>/etc/inetd.conf
#:MBSE-BBS: bbs service
binkp stream tcp nowait mbse $MHOME/bin/mbcico mbcico -t ibn
fido stream tcp nowait mbse $MHOME/bin/mbcico mbcico -t ifc
2004-02-01 15:27:05 +00:00
tfido stream tcp nowait mbse $MHOME/bin/mbcico mbcico -t itn
2001-08-17 05:46:24 +00:00
EOF
chmod 644 /etc/inetd.conf
if [ -f /var/run/inetd.pid ]; then
echo -n ", restarting inetd"
kill -HUP `cat /var/run/inetd.pid`
log "+" "[$?] restarted inetd"
else
log "!" "Warning: no inetd.pid file found"
fi
echo ", done."
2002-01-13 14:07:43 +00:00
fi
2001-08-17 05:46:24 +00:00
fi
2004-09-25 21:23:21 +00:00
if [ -f /etc/xinetd.conf ] || [ -d /etc/xinetd.d ]; then
log "+" "/etc/xinetd.conf or /etc/xinetd.d found, xinetd system"
2002-01-13 14:07:43 +00:00
if [ -d /etc/xinetd.d ]; then
log "+" "has xinetd.d subdir, writing files"
XINET="/etc/xinetd.d/mbsebbs"
else
log "+" "appending to xinetd.conf"
XINET="/etc/xinetd.conf"
fi
cat << EOF >> $XINET
#:MBSE BBS services are defined here.
2002-01-20 20:43:40 +00:00
#
2004-02-01 15:27:05 +00:00
# Author: Michiel Broek <mbse@mbse.dds.nl>, 01-Feb-2004
2002-01-13 14:07:43 +00:00
service binkp
{
socket_type = stream
protocol = tcp
wait = no
user = mbse
instances = 10
server = $MHOME/bin/mbcico
2002-01-20 20:26:30 +00:00
server_args = -t ibn
2002-01-13 14:07:43 +00:00
}
service fido
{
socket_type = stream
protocol = tcp
wait = no
user = mbse
instances = 10
server = $MHOME/bin/mbcico
2002-01-20 20:26:30 +00:00
server_args = -t ifc
2002-01-13 14:07:43 +00:00
}
2003-11-22 21:42:44 +00:00
service tfido
{
socket_type = stream
protocol = tcp
wait = no
user = mbse
instances = 10
2004-02-01 15:27:05 +00:00
server = $MHOME/bin/mbcico
server_args = -t itn
2003-11-22 21:42:44 +00:00
}
2002-01-13 14:07:43 +00:00
EOF
fi
2001-08-17 05:46:24 +00:00
# We made it, copy the logfile to mbse's homedir so that when the
# /tmp directory is cleaned, we still have it.
cat SETUP.log >> $MHOME/SETUP.log
2001-08-17 05:46:24 +00:00
echo ""
echo -n "Press Enter to continue"
read junk
clear
cat << EOF
The script made it to the end, that looks good. Before you logout do some
sanity checks;
1. Can you still login as a normal user.
2. Login on another virtual console, network or whatever as user 'mbse'.
Then type 'echo \$MBSE_ROOT'. Does this show the path to
'$MHOME' or nothing.
3. Login on another virtual console as user 'bbs'. It should not ask for
a password, but should direct try to start the bbs. This is not
installed yet but you should see error messages and then be logged out.
If these three tests weren't successfull, restore /etc/passwd and
or /etc/shadow, the backup copies have the extension '.mbse'.
Then issue (as root of course) the following commands:
EOF
2002-01-10 21:36:24 +00:00
if [ "$OSTYPE" = "Linux" ] || [ "$OSTYPE" = "NetBSD" ]; then
2001-08-25 19:53:11 +00:00
echo " userdel bbs"
echo " userdel -r mbse"
echo " groupdel bbs"
fi
if [ "$OSTYPE" = "FreeBSD" ]; then
echo " pw userdel bbs -r"
echo " pw userdel mbse -r"
echo " pw groupdel bbs"
fi
2001-08-17 05:46:24 +00:00