Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # installsbbs - a barebone installation script for Synchronet BBS
- # on linux.
- #
- # author: mark lewis (aka wkitty42 and waldo kitty)
- # BBS: The SouthEast Star (sestar)
- # BBS domain: sestar.synchro.net
- #
- # this script is targeted at debian-based linux distributions.
- # it does all that is needed to pull the sbbs source code and
- # build it on a new installation. all you need to do is create
- # the base directory where sbbs will live, place the script in
- # that directory, make it executable, and then run it. when it
- # completes you should be able to go into sbbs/ctrl and run
- # scfg to configure the software for execution on your system.
- #
- # this script will create a log file of the same name as this
- # script plus the date and time.
- # eg: installsbbs_201810251345.log
- ###################################################
- # ensure you have the prerequesits in place first!
- #
- # sudo aptitude install build-essential /
- # linux-libc-dev xorg-dev libsdl1.2-dev /
- # libgtk-3-dev libglade2-dev libncurses5-dev /
- # libnspr4-dev perl python-minimal cvs /
- # libcap2-dev gdb zip unzip lrzsz dosemu
- ###################################################
- # first set the variables
- # set this to the base directory of your sbbs; this directory
- # generally contains everything, even the src directory
- SBBSDIR=$HOME/bbs
- # if your src directory is in a different place, set it here
- SRCDIR="$SBBSDIR/src"
- # the user and group that your sbbs will execute as
- SUSER="SBBSUSER=sbbs"
- SGRP="SBBSGROUP=sbbs"
- # use CLASSIC for binary files OR
- # use SYMLINK for symlinks to the compiled binaries
- INSTALLOPT="INSTALL=CLASSIC"
- # this is where your sbbs is installed to; generally it is in
- # the same directory as where all your sbbs files are located
- INSTDIR="SBBSDIR=$SBBSDIR"
- # leave these here and alone; they are used in one of the
- # BUILDOPTS lines selected below
- DOSEMUOPT="USE_DOSEMU=1"
- DEBUGOPT="DEBUG=1"
- RELEASEOPT="RELEASE=1"
- # choose one of the following four BUILDOPTS lines based on if
- # you want a DEBUG or a RELEASE build and DOSEMU or not.
- # make sure you select the same BUILDOPTS line in the updatesbbs
- # script available from the same author.
- #
- # debug without DOSEMU
- #BUILDOPTS="$DEBUGOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
- #
- # debug with DOSEMU
- BUILDOPTS="$DEBUGOPT $DOSEMUOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
- #
- # release without DOSEMU
- #BUILDOPTS="$RELEASEOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
- #
- # release with DOSEMU
- #BUILDOPTS="$RELEASEOPT $DOSEMUOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
- # you should not need to edit below this line
- CWD="$PWD"
- SDATE1=$(date +"%s")
- SCRIPTNAME=$(basename "$0")
- EXECDATE=$(date --date="@$SDATE1" '+%Y%m%d%H%M')
- LOGFILE="$SBBSDIR"/"$SCRIPTNAME"_"$EXECDATE".log
- export SBBSCTRL="$SBBSDIR/ctrl"
- export SBBSEXEC="$SBBSDIR/exec"
- printf "\n"
- printf "*** %s logging to %s ***\n" "$SCRIPTNAME" "$LOGFILE"
- printf "\n"
- function elapsedtime () {
- local T=$1
- local D=$((T/60/60/24))
- local H=$((T/60/60%24))
- local M=$((T/60%60))
- local S=$((T%60))
- printf "** Total Elapsed Time: %s day" $D
- if [[ $D = 0 ]] || [[ $D -gt 1 ]]; then printf "s"
- fi
- printf " %s hour" $H
- if [[ $H = 0 ]] || [[ $H -gt 1 ]]; then printf "s"
- fi
- printf " %s minute" $M
- if [[ $M = 0 ]] || [[ $M -gt 1 ]]; then printf "s"
- fi
- printf " %s second" $S
- if [[ $S = 0 ]] || [[ $S -gt 1 ]]; then printf "s"
- fi
- printf " **\n"
- }
- promptyn () {
- if [ "$#" -ne 2 ]; then
- printf "\nIllegal number of parameters: %s\n" $#
- printf "promptyn requires two parameters, the prompt string and the default response\n"
- printf "eg:\n"
- printf " promptyn \"do something? Y/n\" \"Yes\"\n"
- printf "\nAborting...\n"
- # we should break out of the script completely here but exit 1 is not working for some reason
- #exit 1
- return 1
- else
- while true; do
- printf "\n"
- read -r -t 30 -n 1 -p "$1 " ANSWER
- RSLT=$?
- if [ -n "$ANSWER" ] || [ $RSLT -gt 128 ]; then
- if [ $RSLT -gt 128 ]; then
- printf "timed out"
- fi
- printf "\n"
- fi
- [ -z "$ANSWER" ] && ANSWER="$2" # force second parameter to be the default choice
- case ${ANSWER:0:1} in
- [Yy]* ) return 0;;
- [Nn]* ) return 1;;
- * ) printf "Please answer yes or no.\n";;
- esac
- done
- fi
- }
- # Redirect stdout ( > ) into a named pipe ( >() ) running "tee"
- exec > >(tee "$LOGFILE")
- # Without this, only stdout would be captured - i.e. your
- # log file would not contain any error messages.
- exec 2>&1
- printf "* starting in %s\n" "$CWD"
- printf "* Start Date: %s\n" "$(date --date="@$SDATE1" +'%Y-%m-%d %H:%M:%S')"
- printf "\n"
- cd "$SBBSDIR" || exit
- printf "* retrieving GNUmakefile\n"
- wget 'http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/install/GNUmakefile'
- printf "make %s install\n" "$BUILDOPTS"
- make "$BUILDOPTS" install
- printf "initial SBBS CVS compile and install complete!\n"
- printf "you may now configure sbbs by entering the following commands:\n"
- printf "\n"
- printf "cd $SBBSDIR/ctrl\n"
- printf "$SBBSDIR/exec/scfg\n"
- printf "\n"
- printf "there are two methods of automatically running your sbbs system.\n"
- printf "which method you use depends on your OS installation.\n"
- printf "\n"
- printf "1.traditional SYSV method:\n"
- printf " http://wiki.synchro.net/install:nix?s[]=init#daemon_mode\n"
- printf "\n"
- printf "2.modern systemd method:\n"
- printf " http://wiki.synchro.net/howto:systemd\n"
- printf "\n"
- printf "for more information, you should visit the Synchronet BBS wiki at\n"
- printf " http://wiki.synchro.net/\n"
- printf "\n"
- printf "* returning to %s\n" "$CWD"
- cd "$CWD" || exit
- EDATE1=$(date +"%s")
- printf "* End Date: %s*\n" "$(date --date="@$EDATE1" +'%Y-%m-%d %H:%M:%S')"
- DIFF=$((EDATE1-SDATE1))
- elapsedtime $DIFF
- printf "\n"
- unset EDATE1
- unset SDATE1
- unset DIFF
- unset CMD
- unset SCRIPTNAME
- unset SBBSDIR
- unset EXECDATE
- unset LOGFILE
- unset BUILDOPTS
- unset CWD
- unset ECODE
Add Comment
Please, Sign In to add comment