wkitty42

bare-bones synchronet bbs install on linux script

Oct 21st, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.99 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # installsbbs - a barebone installation script for Synchronet BBS
  4. # on linux.
  5. #
  6. # author: mark lewis (aka wkitty42 and waldo kitty)
  7. # BBS: The SouthEast Star (sestar)
  8. # BBS domain: sestar.synchro.net
  9. #
  10. # this script is targeted at debian-based linux distributions.
  11. # it does all that is needed to pull the sbbs source code and
  12. # build it on a new installation. all you need to do is create
  13. # the base directory where sbbs will live, place the script in
  14. # that directory, make it executable, and then run it. when it
  15. # completes you should be able to go into sbbs/ctrl and run
  16. # scfg to configure the software for execution on your system.
  17. #
  18. # this script will create a log file of the same name as this
  19. # script plus the date and time.
  20. # eg: installsbbs_201810251345.log
  21.  
  22. ###################################################
  23. # ensure you have the prerequesits in place first!
  24. #
  25. # sudo aptitude install build-essential /
  26. #   linux-libc-dev xorg-dev libsdl1.2-dev /
  27. #   libgtk-3-dev libglade2-dev libncurses5-dev /
  28. #   libnspr4-dev perl python-minimal cvs /
  29. #   libcap2-dev gdb zip unzip lrzsz dosemu
  30. ###################################################
  31.  
  32. # first set the variables
  33. # set this to the base directory of your sbbs; this directory
  34. # generally contains everything, even the src directory
  35. SBBSDIR=$HOME/bbs
  36.  
  37. # if your src directory is in a different place, set it here
  38. SRCDIR="$SBBSDIR/src"
  39.  
  40. # the user and group that your sbbs will execute as
  41. SUSER="SBBSUSER=sbbs"
  42. SGRP="SBBSGROUP=sbbs"
  43.  
  44. # use CLASSIC for binary files OR
  45. # use SYMLINK for symlinks to the compiled binaries
  46. INSTALLOPT="INSTALL=CLASSIC"
  47.  
  48. # this is where your sbbs is installed to; generally it is in
  49. # the same directory as where all your sbbs files are located
  50. INSTDIR="SBBSDIR=$SBBSDIR"
  51.  
  52. # leave these here and alone; they are used in one of the
  53. # BUILDOPTS lines selected below
  54. DOSEMUOPT="USE_DOSEMU=1"
  55. DEBUGOPT="DEBUG=1"
  56. RELEASEOPT="RELEASE=1"
  57.  
  58. # choose one of the following four BUILDOPTS lines based on if
  59. # you want a DEBUG or a RELEASE build and DOSEMU or not.
  60. # make sure you select the same BUILDOPTS line in the updatesbbs
  61. # script available from the same author.
  62. #
  63. # debug without DOSEMU
  64. #BUILDOPTS="$DEBUGOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
  65. #
  66. # debug with DOSEMU
  67. BUILDOPTS="$DEBUGOPT $DOSEMUOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
  68. #
  69. # release without DOSEMU
  70. #BUILDOPTS="$RELEASEOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
  71. #
  72. # release with DOSEMU
  73. #BUILDOPTS="$RELEASEOPT $DOSEMUOPT $INSTALLOPT $INSTDIR $SRCDIR $SUSER $SGRP"
  74.  
  75.  
  76. # you should not need to edit below this line
  77.  
  78.  
  79. CWD="$PWD"
  80. SDATE1=$(date +"%s")
  81. SCRIPTNAME=$(basename "$0")
  82. EXECDATE=$(date --date="@$SDATE1" '+%Y%m%d%H%M')
  83. LOGFILE="$SBBSDIR"/"$SCRIPTNAME"_"$EXECDATE".log
  84.  
  85. export SBBSCTRL="$SBBSDIR/ctrl"
  86. export SBBSEXEC="$SBBSDIR/exec"
  87.  
  88. printf "\n"
  89. printf "*** %s logging to %s ***\n" "$SCRIPTNAME" "$LOGFILE"
  90. printf "\n"
  91.  
  92. function elapsedtime () {
  93.   local T=$1
  94.   local D=$((T/60/60/24))
  95.   local H=$((T/60/60%24))
  96.   local M=$((T/60%60))
  97.   local S=$((T%60))
  98.  
  99.   printf "** Total Elapsed Time: %s day" $D
  100.   if [[ $D = 0 ]] || [[ $D -gt 1 ]]; then printf "s"
  101.   fi
  102.   printf " %s hour" $H
  103.   if [[ $H = 0 ]] || [[ $H -gt 1 ]]; then printf "s"
  104.   fi
  105.   printf " %s minute" $M
  106.   if [[ $M = 0 ]] || [[ $M -gt 1 ]]; then printf "s"
  107.   fi
  108.   printf " %s second" $S
  109.   if [[ $S = 0 ]] || [[ $S -gt 1 ]]; then printf "s"
  110.   fi
  111.   printf " **\n"
  112. }
  113.  
  114. promptyn () {
  115.   if [ "$#" -ne 2 ]; then
  116.     printf "\nIllegal number of parameters: %s\n" $#
  117.     printf "promptyn requires two parameters, the prompt string and the default response\n"
  118.     printf "eg:\n"
  119.     printf "  promptyn \"do something? Y/n\" \"Yes\"\n"
  120.     printf "\nAborting...\n"
  121.     # we should break out of the script completely here but exit 1 is not working for some reason
  122.     #exit 1
  123.     return 1
  124.   else
  125.     while true; do
  126.       printf "\n"
  127.       read -r -t 30 -n 1 -p "$1 " ANSWER
  128.       RSLT=$?
  129.       if [ -n "$ANSWER" ] || [ $RSLT -gt 128 ]; then
  130.         if [ $RSLT -gt 128 ]; then
  131.           printf "timed out"
  132.         fi
  133.         printf "\n"
  134.       fi
  135.       [ -z "$ANSWER" ] && ANSWER="$2"  # force second parameter to be the default choice
  136.       case ${ANSWER:0:1} in
  137.         [Yy]* ) return 0;;
  138.         [Nn]* ) return 1;;
  139.         * ) printf "Please answer yes or no.\n";;
  140.       esac
  141.     done
  142.   fi
  143. }
  144.  
  145.  
  146. # Redirect stdout ( > ) into a named pipe ( >() ) running "tee"
  147. exec > >(tee "$LOGFILE")
  148.  
  149. # Without this, only stdout would be captured - i.e. your
  150. # log file would not contain any error messages.
  151. exec 2>&1
  152.  
  153.  
  154. printf "* starting in %s\n" "$CWD"
  155. printf "* Start Date: %s\n" "$(date --date="@$SDATE1" +'%Y-%m-%d %H:%M:%S')"
  156. printf "\n"
  157.  
  158. cd "$SBBSDIR" || exit
  159. printf "* retrieving GNUmakefile\n"
  160. wget 'http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/install/GNUmakefile'
  161.  
  162. printf "make %s install\n" "$BUILDOPTS"
  163. make "$BUILDOPTS" install
  164.  
  165. printf "initial SBBS CVS compile and install complete!\n"
  166. printf "you may now configure sbbs by entering the following commands:\n"
  167. printf "\n"
  168. printf "cd $SBBSDIR/ctrl\n"
  169. printf "$SBBSDIR/exec/scfg\n"
  170. printf "\n"
  171. printf "there are two methods of automatically running your sbbs system.\n"
  172. printf "which method you use depends on your OS installation.\n"
  173. printf "\n"
  174. printf "1.traditional SYSV method:\n"
  175. printf "  http://wiki.synchro.net/install:nix?s[]=init#daemon_mode\n"
  176. printf "\n"
  177. printf "2.modern systemd method:\n"
  178. printf "  http://wiki.synchro.net/howto:systemd\n"
  179. printf "\n"
  180. printf "for more information, you should visit the Synchronet BBS wiki at\n"
  181. printf "  http://wiki.synchro.net/\n"
  182. printf "\n"
  183. printf "* returning to %s\n" "$CWD"
  184. cd "$CWD" || exit
  185.  
  186. EDATE1=$(date +"%s")
  187. printf "* End Date: %s*\n" "$(date --date="@$EDATE1" +'%Y-%m-%d %H:%M:%S')"
  188. DIFF=$((EDATE1-SDATE1))
  189. elapsedtime $DIFF
  190. printf "\n"
  191. unset EDATE1
  192. unset SDATE1
  193. unset DIFF
  194. unset CMD
  195. unset SCRIPTNAME
  196. unset SBBSDIR
  197. unset EXECDATE
  198. unset LOGFILE
  199. unset BUILDOPTS
  200. unset CWD
  201. unset ECODE
Add Comment
Please, Sign In to add comment