Changed for Ubuntu

This commit is contained in:
Michiel Broek 2007-09-01 15:28:42 +00:00
parent 3ca09dda5b
commit 3fabf9777a

204
SETUP.sh
View File

@ -15,14 +15,14 @@ MHOME=/opt/mbse
PATH=/bin:/sbin:/usr/bin:/usr/sbin: PATH=/bin:/sbin:/usr/bin:/usr/sbin:
DISTNAME= DISTNAME=
DISTVERS= DISTVERS=
OSTYPE=`uname -s` OSTYPE=$( uname -s )
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Logging procedure, needs two parameters. # Logging procedure, needs two parameters.
# #
log() { log() {
/bin/echo `date +%d-%b-%y\ %X ` $1 $2 >> SETUP.log /bin/echo $( date +%d-%b-%y\ %X ) $1 $2 >> SETUP.log
} }
@ -42,8 +42,8 @@ EOF
echo -n "Press ENTER to start the basic checks " echo -n "Press ENTER to start the basic checks "
read junk read junk
log "+" "MBSE BBS $0 started by `whoami`" log "+" "MBSE BBS $0 started by $(whoami)"
log "+" "Current directory is `pwd`" log "+" "Current directory is $(pwd)"
# Check the OS type, only Linux for now. # Check the OS type, only Linux for now.
# #
@ -69,66 +69,75 @@ if [ "$OSTYPE" = "Linux" ]; then
if [ -f /etc/slackware-version ]; then if [ -f /etc/slackware-version ]; then
# Slackware 7.0 and later # Slackware 7.0 and later
DISTNAME="Slackware" DISTNAME="Slackware"
DISTVERS=`cat /etc/slackware-version` # There are two styles, newer releases are like "Slackware 12.0.0"
if grep -q Slackware /etc/slackware-version ; then
DISTVERS=$( cat /etc/slackware-version | awk '{ print $2 }' )
else else
if [ -f /etc/debian_version ]; then DISTVERS=$( cat /etc/slackware-version )
fi
elif [ -f /etc/debian_version ]; then
# Debian, at least since version 2.2 # Debian, at least since version 2.2
DISTNAME="Debian" DISTNAME="Debian"
DISTVERS=`cat /etc/debian_version` DISTVERS=$( cat /etc/debian_version )
else # Ubuntu is based on Debian
if [ -f /etc/SuSE-release ]; then if grep -q "Ubuntu" /etc/issue ; then
DISTNAME="Ubuntu"
DISTVERS=$( cat /etc/issue | awk '{ print $2 }' )
fi
elif [ -f /etc/SuSE-release ]; then
DISTNAME="SuSE" DISTNAME="SuSE"
DISTVERS=`cat /etc/SuSE-release | grep VERSION | awk '{ print $3 }'` DISTVERS=$( cat /etc/SuSE-release | grep VERSION | awk '{ print $3 }' )
else
# Mandrake test before RedHat, Mandrake has a redhat-release # Mandrake test before RedHat, Mandrake has a redhat-release
# file also which is a symbolic link to mandrake-release. # file also which is a symbolic link to mandrake-release.
if [ -f /etc/mandrake-release ]; then elif [ -f /etc/mandrake-release ]; then
DISTNAME="Mandrake" DISTNAME="Mandrake"
# Format: Linux Mandrake release 8.0 (Cooker) for i586 # Format: Linux Mandrake release 8.0 (Cooker) for i586
DISTVERS=`cat /etc/mandrake-release | awk '{ print $4 }'` DISTVERS=$( cat /etc/mandrake-release | awk '{ print $4 }' )
else elif [ -f /etc/redhat-release ]; then
if [ -f /etc/redhat-release ]; then
DISTNAME="RedHat" DISTNAME="RedHat"
if [ -z "`grep e-smith /etc/redhat-release`" ]; then if grep -q e-smith /etc/redhat-release ; then
DISTVERS=`cat /etc/redhat-release | awk '{ print $5 }'` DISTVERS=$( cat /etc/redhat-release | awk '{ print $13 }' | tr -d \) )
else else
DISTVERS=`cat /etc/redhat-release | awk '{ print $13 }' | tr -d \)` DISTVERS=$( cat /etc/redhat-release | awk '{ print $5 }' )
fi fi
else elif [ -f /etc/gentoo-release ]; then
if [ -f /etc/gentoo-release ]; then
DISTNAME="Gentoo" DISTNAME="Gentoo"
DISTVERS=`cat /etc/gentoo-release | awk '{ print $5 }'` DISTVERS=$( cat /etc/gentoo-release | awk '{ print $5 }' )
else else
DISTNAME="Unknown" DISTNAME="Unknown"
fi fi
fi elif [ "$OSTYPE" = "FreeBSD" ]; then
fi
fi
fi
fi
fi # Linux
if [ "$OSTYPE" = "FreeBSD" ]; then
DISTNAME="FreeBSD" DISTNAME="FreeBSD"
DISTVERS=`uname -r` DISTVERS=$(uname -r)
PW="pw " PW="pw "
fi elif [ "$OSTYPE" = "NetBSD" ]; then
if [ "$OSTYPE" = "NetBSD" ]; then
DISTNAME="NetBSD" DISTNAME="NetBSD"
DISTVERS=`uname -r` DISTVERS=$(uname -r)
fi elif [ "$OSTYPE" = "OpenBSD" ]; then
if [ "$OSTYPE" = "OpenBSD" ]; then
DISTNAME="OpenBSD" DISTNAME="OpenBSD"
DISTVERS=`uname -r` DISTVERS=$(uname -r)
fi elif [ "$OSTYPE" = "Darwin" ]; then
if [ "$OSTYPE" = "Darwin" ]; then
DISTNAME="Darwin" DISTNAME="Darwin"
DISTVERS=`uname -r` DISTVERS=$(uname -r)
else
DISTNAME="Unknown"
fi fi
log "+" "Detected \"${OSTYPE}\" (${HOSTTYPE}) \"${DISTNAME}\" version \"${DISTVERS}\"" log "+" "Detected \"${OSTYPE}\" (${HOSTTYPE}) \"${DISTNAME}\" version \"${DISTVERS}\""
# Basic checks. # Basic checks.
if [ `whoami` != "root" ]; then if [ "$DISTNAME" = "Unknown" ]; then
cat << EOF
Your are trying to install MBSE BBS on $OSTYPE system, however
the distribution is unknown.
EOF
log "!" "Aborted, OS is $OSTYPE, distribution is unknown"
exit 2
fi
if [ $( whoami ) != "root" ]; then
cat << EOF cat << EOF
*** Run $0 as root only! *** *** Run $0 as root only! ***
@ -148,14 +157,14 @@ if [ "$MBSE_ROOT" != "" ]; then
exit 2 exit 2
fi fi
if [ "`grep -w mbse: /etc/passwd`" != "" ]; then if grep -q ^mbse: /etc/passwd ; then
echo "*** User 'mbse' already exists on this system ***" echo "*** User 'mbse' already exists on this system ***"
echo "*** SETUP aborted ***" echo "*** SETUP aborted ***"
log "!" "Aborted, user 'mbse' already exists on this system" log "!" "Aborted, user 'mbse' already exists on this system"
exit 2 exit 2
fi fi
if [ "`grep -w bbs: /etc/group`" != "" ]; then if grep -q ^bbs: /etc/group ; then
echo "*** Group 'bbs' already exists on this system ***" echo "*** Group 'bbs' already exists on this system ***"
echo "*** SETUP aborted ***" echo "*** SETUP aborted ***"
log "!" "Aborted, group 'bbs' already exists on this system" log "!" "Aborted, group 'bbs' already exists on this system"
@ -169,6 +178,20 @@ if [ -f /etc/passwd.lock ]; then
log "!" "Aborted, password file is locked" log "!" "Aborted, password file is locked"
exit 2 exit 2
fi fi
#
# Check if this is Ubuntu. Ubuntu by default has no xinetd installed.
#
if [ "$DISTNAME" = "Ubuntu" ]; then
if [ ! -f /etc/xinetd.d/echo ]; then
echo "*** You seem to be using Ubuntu but have not yet installed xinetd."
echo " 'sudo apt-get install xinetd' will install that for you. ***"
echo "*** SETUP aborted ***"
log "!" "Aborted, Ubuntu without xinetd package"
exit 2
fi
fi
clear clear
if [ "$OSTYPE" = "Linux" ]; then if [ "$OSTYPE" = "Linux" ]; then
@ -176,7 +199,7 @@ if [ "$OSTYPE" = "Linux" ]; then
log "+" "Directory /opt already present" log "+" "Directory /opt already present"
else else
mkdir /opt mkdir /opt
log "+" "[$?] Directory /opt created" log "+" "Directory /opt created"
echo "Directory /opt created." echo "Directory /opt created."
fi fi
fi fi
@ -196,11 +219,11 @@ if [ "$OSTYPE" = "FreeBSD" ] || [ "$OSTYPE" = "NetBSD" ] || [ "$OSTYPE" = "OpenB
log "+" "Directory /usr/local/opt already present" log "+" "Directory /usr/local/opt already present"
else else
mkdir -p /usr/local/opt mkdir -p /usr/local/opt
log "+" "[$?] Directory /usr/local/opt created" log "+" "Directory /usr/local/opt created"
echo "Directory /usr/local/opt created." echo "Directory /usr/local/opt created."
fi fi
ln -s /usr/local/opt /opt ln -s /usr/local/opt /opt
log "+" "[$?] Link /opt to /usr/local/opt created" log "+" "Link /opt to /usr/local/opt created"
echo "Link /opt to /usr/local/opt created." echo "Link /opt to /usr/local/opt created."
fi fi
fi fi
@ -247,24 +270,31 @@ echo -n "Adding group 'bbs'"
$PW groupadd bbs $PW groupadd bbs
log "+" "[$?] Added group bbs" log "+" "[$?] Added group bbs"
echo -n ", user 'mbse'" echo -n ", user 'mbse' $OSTYPE "
if [ "$OSTYPE" = "Linux" ]; then if [ "$OSTYPE" = "Linux" ]; then
if [ "`grep wheel /etc/group`" = "" ]; then # Different distros have different needs...
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G uucp -m -s /bin/bash mbse GRPS="uucp"
else if grep -q ^wheel /etc/group ; then
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,uucp -m -s /bin/bash mbse GRPS=${GRPS}",wheel"
fi fi
fi if [ "$DISTNAME" = "Ubuntu" ]; then
if [ "$OSTYPE" = "FreeBSD" ]; then GRPS=${GRPS}",adm,admin"
fi
if grep -q ^dialout /etc/group ; then
GRPS=${GRPS}",dialout"
fi
if grep -q ^dip /etc/group ; then
GRPS=${GRPS}",dip"
fi
log "+" "useradd -c \"MBSE BBS Admin\" -d $MHOME -g bbs -G $GRPS -m -s /bin/bash mbse"
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G $GRPS -m -s /bin/bash mbse
elif [ "$OSTYPE" = "FreeBSD" ]; then
pw useradd mbse -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/local/bin/bash pw useradd mbse -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/local/bin/bash
fi elif [ "$OSTYPE" = "NetBSD" ]; then
if [ "$OSTYPE" = "NetBSD" ]; then
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/pkg/bin/bash mbse useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/pkg/bin/bash mbse
fi elif [ "$OSTYPE" = "OpenBSD" ]; then
if [ "$OSTYPE" = "OpenBSD" ]; then
useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/local/bin/bash mbse useradd -c "MBSE BBS Admin" -d $MHOME -g bbs -G wheel,dialer -m -s /usr/local/bin/bash mbse
fi elif [ "$OSTYPE" = "Darwin" ]; then
if [ "$OSTYPE" = "Darwin" ]; then
useradd mbse -c "MBSE BBS Admin" -d $MHOME -g bbs -s /bin/bash useradd mbse -c "MBSE BBS Admin" -d $MHOME -g bbs -s /bin/bash
fi fi
log "+" "[$?] Added user mbse" log "+" "[$?] Added user mbse"
@ -353,7 +383,7 @@ if [ "$OSTYPE" = "Linux" ]; then
if [ -f /etc/shadow ]; then if [ -f /etc/shadow ]; then
log "+" "Standard shadow password system" log "+" "Standard shadow password system"
# Not all systems are the same... # Not all systems are the same...
if [ "`grep bbs:\!\!: /etc/shadow`" != "" ]; then if grep -q ^bbs:\!\!: /etc/shadow ; then
sed /bbs:\!\!:/s/bbs:\!\!:/bbs::/ /etc/shadow >/etc/shadow.bbs sed /bbs:\!\!:/s/bbs:\!\!:/bbs::/ /etc/shadow >/etc/shadow.bbs
else else
sed /bbs:\!:/s/bbs:\!:/bbs::/ /etc/shadow >/etc/shadow.bbs sed /bbs:\!:/s/bbs:\!:/bbs::/ /etc/shadow >/etc/shadow.bbs
@ -363,11 +393,11 @@ if [ "$OSTYPE" = "Linux" ]; then
log "+" "[$?] made backup of /etc/shadow" log "+" "[$?] made backup of /etc/shadow"
mv /etc/shadow.bbs /etc/shadow mv /etc/shadow.bbs /etc/shadow
log "+" "[$?] moved new /etc/shadow in place" log "+" "[$?] moved new /etc/shadow in place"
if [ "$DISTNAME" = "Debian" ] || [ "$DISTNAME" = "SuSE" ]; then if [ "$DISTNAME" = "Debian" ] || [ "$DISTNAME" = "Ubuntu" ] || [ "$DISTNAME" = "SuSE" ]; then
# Debian and SuSE use other ownership of /etc/shadow # Debian, Ubuntu and SuSE use other ownership of /etc/shadow
chmod 640 /etc/shadow chmod 640 /etc/shadow
chgrp shadow /etc/shadow chgrp shadow /etc/shadow
log "+" "[$?] Debian/SuSE style owner of /etc/shadow (0640 root.shadow)" log "+" "[$?] Debian/Ubuntu/SuSE style owner of /etc/shadow (0640 root.shadow)"
else else
chmod 600 /etc/shadow chmod 600 /etc/shadow
log "+" "[$?] Default style owner of /etc/shadow (0600 root.root)" log "+" "[$?] Default style owner of /etc/shadow (0600 root.root)"
@ -375,7 +405,7 @@ if [ "$OSTYPE" = "Linux" ]; then
echo " File /etc/shadow.mbse is your backup of /etc/shadow" echo " File /etc/shadow.mbse is your backup of /etc/shadow"
else else
log "+" "Not a shadow password system" log "+" "Not a shadow password system"
if [ "`grep -w bbs:\!\!: /etc/passwd`" != "" ]; then if grep -q ^bbs:\!\!: /etc/passwd ; then
sed /bbs:\!\!:/s/bbs:\!\!:/bbs::/ /etc/passwd >/etc/passwd.bbs sed /bbs:\!\!:/s/bbs:\!\!:/bbs::/ /etc/passwd >/etc/passwd.bbs
else else
sed /bbs:\!:/s/bbs:\!:/bbs::/ /etc/passwd >/etc/passwd.bbs sed /bbs:\!:/s/bbs:\!:/bbs::/ /etc/passwd >/etc/passwd.bbs
@ -416,20 +446,30 @@ fi
echo "" echo ""
if [ "`grep binkp /etc/services`" = "" ]; then if grep -q ^binkp /etc/services ; then
BINKD=TRUE
else
BINKD=FALSE BINKD=FALSE
fi
if [ "`grep fido /etc/services`" = "" ]; then
FIDO=TRUE
else else
FIDO=FALSE BINKD=TRUE
fi
if grep -q 60179\/tcp /etc/services ; then
FIDO_TCP=FALSE
else
FIDO_TCP=TRUE
fi
if grep -q 60179\/udp /etc/services ; then
FIDO_UDP=FALSE
else
FIDO_UDP=TRUE
fi
if grep -q ^tfido /etc/services ; then
TFIDO=FALSE
else
TFIDO=TRUE
fi fi
log "+" "Services: binkp=$BINKD fido=$FIDO" log "+" "Services: binkp=$BINKD fido_tcp=$FIDO_TCP fido_udp=$FIDO_UDP tfido=$TFIDO"
if [ "$FIDO" = "TRUE" ] || [ "$BINKD" = "TRUE" ]; then if [ "$FIDO_TCP" = "TRUE" ] || [ "$FIDO_UDP" = "TRUE" ] || [ "$TFIDO" = "TRUE" ] || [ "$BINKD" = "TRUE" ]; then
echo -n "Modifying /etc/services" echo -n "Modifying /etc/services"
log "+" "Modifying /etc/services" log "+" "Modifying /etc/services"
mv /etc/services /etc/services.mbse mv /etc/services /etc/services.mbse
@ -441,10 +481,16 @@ if [ "$FIDO" = "TRUE" ] || [ "$BINKD" = "TRUE" ]; then
echo -n ", binkp at port 24554" echo -n ", binkp at port 24554"
echo "binkp 24554/tcp # mbcico IBN mode">>/etc/services echo "binkp 24554/tcp # mbcico IBN mode">>/etc/services
fi fi
if [ "$FIDO" = "TRUE" ]; then if [ "$TFIDO" = "TRUE" ]; then
echo -n ", fido at ports 60177, 60179" echo -n ", tfido at port 60177"
echo "tfido 60177/tcp # mbcico ITN mode (alternate port)">>/etc/services echo "tfido 60177/tcp # mbcico ITN mode (alternate port)">>/etc/services
fi
if [ "$FIDO_TCP" = "TRUE" ]; then
echo -n ", fido tcp at port 60179"
echo "fido 60179/tcp # mbcico IFC mode">>/etc/services echo "fido 60179/tcp # mbcico IFC mode">>/etc/services
fi
if [ "$FIDO_UDP" = "TRUE" ]; then
echo -n ", fido udp at port 60179"
echo "fido 60179/udp # Chatserver">>/etc/services echo "fido 60179/udp # Chatserver">>/etc/services
fi fi
chmod 644 /etc/services chmod 644 /etc/services
@ -454,7 +500,7 @@ fi
if [ -f /etc/inetd.conf ]; then if [ -f /etc/inetd.conf ]; then
log "+" "/etc/inetd.conf found, inetd system" log "+" "/etc/inetd.conf found, inetd system"
if [ "`grep mbcico /etc/inetd.conf`" = "" ]; then if ! grep -q mbcico /etc/inetd.conf ; then
echo -n "Modifying /etc/inetd.conf" echo -n "Modifying /etc/inetd.conf"
log "+" "Modifying /etc/inetd.conf" log "+" "Modifying /etc/inetd.conf"
mv /etc/inetd.conf /etc/inetd.conf.mbse mv /etc/inetd.conf /etc/inetd.conf.mbse
@ -478,7 +524,7 @@ EOF
chmod 644 /etc/inetd.conf chmod 644 /etc/inetd.conf
if [ -f /var/run/inetd.pid ]; then if [ -f /var/run/inetd.pid ]; then
echo -n ", restarting inetd" echo -n ", restarting inetd"
kill -HUP `cat /var/run/inetd.pid` kill -HUP $( cat /var/run/inetd.pid )
log "+" "[$?] restarted inetd" log "+" "[$?] restarted inetd"
else else
log "!" "Warning: no inetd.pid file found" log "!" "Warning: no inetd.pid file found"
@ -489,7 +535,7 @@ fi
if [ "$OSTYPE" = "NetBSD" ]; then if [ "$OSTYPE" = "NetBSD" ]; then
if [ -f /etc/gettytab ]; then if [ -f /etc/gettytab ]; then
if [ "`grep mbse /etc/gettytab`" = "" ]; then if ! grep mbsebbs /etc/gettytab ; then
log "+" "[$?] adding mbsebbs login to /etc/gettytab" log "+" "[$?] adding mbsebbs login to /etc/gettytab"
cat << EOF >>/etc/gettytab cat << EOF >>/etc/gettytab
@ -598,9 +644,15 @@ cat << EOF
EOF EOF
if [ "$OSTYPE" = "Linux" ] || [ "$OSTYPE" = "NetBSD" ] || [ "$OSTYPE" = "OpenBSD" ]; then if [ "$OSTYPE" = "Linux" ] || [ "$OSTYPE" = "NetBSD" ] || [ "$OSTYPE" = "OpenBSD" ]; then
if [ "$DISTNAME" = "Ubuntu" ]; then
echo " sudo userdel bbs"
echo " sudo userdel -r mbse"
echo " sudo groupdel bbs"
else
echo " userdel bbs" echo " userdel bbs"
echo " userdel -r mbse" echo " userdel -r mbse"
echo " groupdel bbs" echo " groupdel bbs"
fi
fi fi
if [ "$OSTYPE" = "FreeBSD" ]; then if [ "$OSTYPE" = "FreeBSD" ]; then
echo " pw userdel bbs -r" echo " pw userdel bbs -r"