Advertisement
quixadhal

get_gurba.sh

Sep 9th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.20 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Fetch and Installation script by Quixadhal <quixadhal@shadowlord.org>
  4. #
  5.  
  6. GURBA_GIT="git@github.com:sirdude/gurbalib.git"
  7. DGD_GIT="git@github.com:dworkin/dgd.git"
  8. TOP_DIR="$PWD"
  9. LIB_DIR="$TOP_DIR/gurba/lib"
  10. TELNET_PORT=4000 # default value
  11. BIN_PORT=$[ $TELNET_PORT + 1 ]
  12. FTP_PORT=$[ $TELNET_PORT + 1 ]
  13. MUD_NAME=""
  14. EMAIL=""
  15. URL=""
  16.  
  17. function get_config {
  18.     while :
  19.     do
  20.         read -e -i "$MUD_NAME" -p "Please enter your MUD name> " MUD_NAME
  21.         read -e -i "$TELNET_PORT" -p "Please enter a PORT number for the MAIN TELNET port> " TELNET_PORT
  22.         BIN_PORT=$[ $TELNET_PORT + 1 ]
  23.         FTP_PORT=$[ $TELNET_PORT + 1 ]
  24.         read -e -i "$BIN_PORT" -p "Please enter a PORT number for the BINARY port> " BIN_PORT
  25.         read -e -i "$EMAIL" -p "Please enter your EMAIL address> " EMAIL
  26.         read -e -i "$URL" -p "Please enter your WEB server URL> " URL
  27.  
  28.         echo -en "You specified the following options -- \n"
  29.         echo -en "\t\tMUD Name:    $MUD_NAME\n"
  30.         echo -en "\t\tMUD PORT:    $TELNET_PORT\n"
  31.         echo -en "\t\tBINARY PORT: $BIN_PORT\n"
  32.         echo -en "\t\tEMAIL:       $EMAIL\n"
  33.         echo -en "\t\tURL:         $URL\n"
  34.  
  35.         read -e -p "Is that correct? (Y/N): " OK
  36.  
  37.         case "$OK" in
  38.             [yY] | [yY][eE][sS] )
  39.                 break
  40.                 ;;
  41.         esac
  42.     done
  43.     echo -en "\n"
  44.     return 0
  45. }
  46.  
  47. function fetch_gurba {
  48.     echo -en "Fetching gurba distribution..."
  49.     git clone -q $GURBA_GIT gurba >$TOP_DIR/fetch.log 2>&1
  50.     if [ -d gurba ]; then
  51.         echo -en "done.\n"
  52.         return 0
  53.     else
  54.         echo -en "\n\nFailed to retrieve Gurbalib!\n\n"
  55.         cat $TOP_DIR/fetch.log
  56.         echo -en "\n\nFailed to retrieve Gurbalib!\n\n"
  57.         exit 1
  58.     fi
  59. }
  60.  
  61. function setup_dirs {
  62.     echo -en "Creating missing data directories..."
  63.     cd gurba
  64.     cat <<EOM | perl scripts/create_data_dirs.pl >>$TOP_DIR/fetch.log 2>&1
  65. y
  66. y
  67. y
  68. EOM
  69.     cd ..
  70.     echo -en "done.\n"
  71.     return 0
  72. }
  73.  
  74. function fetch_dgd {
  75.     echo -en "Fetching DGD distribution..."
  76.     cd gurba/src
  77.     git clone -q $DGD_GIT dgd >>$TOP_DIR/fetch.log 2>&1
  78.     if [ -d dgd ]; then
  79.         cd ../..
  80.         echo -en "done.\n"
  81.         return 0
  82.     else
  83.         echo -en "\n\nFailed to retrieve DGD!\n\n"
  84.         cat $TOP_DIR/fetch.log
  85.         echo -en "\n\nFailed to retrieve DGD!\n\n"
  86.         exit 1
  87.     fi
  88. }
  89.  
  90. function setup_makefile {
  91.     echo -en "Configuring Makefile..."
  92.     cd gurba/src/dgd/src
  93.     patch >$TOP_DIR/make.log 2>&1 <<EOM
  94. --- Makefile.orig   2013-09-09 11:32:42.298783919 -0400
  95. +++ Makefile    2013-09-09 11:39:48.540900428 -0400
  96. @@ -39,7 +39,7 @@
  97.    \$(error HOST is undefined)
  98.  endif
  99.  
  100. -DEFINES=-D\$(HOST) # -DSLASHSLASH -DNETWORK_EXTENSIONS -DNOFLOAT -DCLOSURES -DCO_THROTTLE=50
  101. +DEFINES=-D\$(HOST) -DSLASHSLASH -DNETWORK_EXTENSIONS # -DNOFLOAT -DCLOSURES -DCO_THROTTLE=50
  102.  DEBUG= -g
  103.  CCFLAGS=\$(DEFINES) \$(DEBUG)
  104.  CFLAGS=    -I. -Icomp -Ilex -Ied -Iparser -Ikfun \$(CCFLAGS)
  105. EOM
  106.     cd ../../../..
  107.     echo -en "done.\n"
  108.     return 0
  109. }
  110.  
  111. function build_dgd {
  112.     echo -en "Building DGD driver..."
  113.     cd gurba/src/dgd/src
  114.     make >>$TOP_DIR/make.log 2>&1 && make install >>$TOP_DIR/make.log 2>&1
  115.     if [ -f ../bin/driver ]; then
  116.         cp -p ../bin/driver ../../../bin/
  117.         cd ../../../..
  118.         echo -en "done.\n"
  119.         return 0
  120.     else
  121.         echo -en "\n\nFailed to build DGD!\n\n"
  122.         cat $TOP_DIR/make.log
  123.         echo -en "\n\nFailed to build DGD!\n\n"
  124.         exit 1
  125.     fi
  126. }
  127.  
  128. function setup_config {
  129.     echo -en "Setting up configuration files..."
  130.     cd gurba
  131.     cp -p mud.dgd.examp mud.dgd
  132.     patch >$TOP_DIR/config.log 2>&1 <<EOM
  133. --- mud.dgd.examp   2013-09-09 13:06:33.616248233 -0400
  134. +++ mud.dgd 2013-09-09 13:06:50.971847581 -0400
  135. @@ -1,6 +1,6 @@
  136. -telnet_port    = 4000;         /* telnet port number */
  137. -binary_port = 4001;
  138. -directory  = "/gurbalib/lib/";/* base directory (MUST be absolute) */
  139. +telnet_port    = $TELNET_PORT;         /* telnet port number */
  140. +binary_port = $BIN_PORT;
  141. +directory  = "$LIB_DIR/";/* base directory (MUST be absolute) */
  142.  users      = 40;           /* max # of users */
  143.  editors        = 40;           /* max # of editor sessions */
  144.  ports      = 16;           /* max # of open ports
  145. EOM
  146.  
  147.     cp -p scripts/startmud bin/startmud
  148.     cd bin
  149.     patch >>$TOP_DIR/config.log 2>&1 <<EOM
  150. --- startmud.orig   2013-09-09 13:06:33.616248233 -0400
  151. +++ startmud    2013-09-09 13:06:50.971847581 -0400
  152. @@ -1,6 +1,6 @@
  153.  #!/bin/bash
  154.  
  155. -ROOT=/Users/mein/mud/dgd/gurbalib
  156. +ROOT=$LIB_DIR
  157.  LOG=\$ROOT/lib/logs/gurba-driver.log
  158.  
  159.  rm -rf \$LOG
  160. EOM
  161.     cd ..
  162.  
  163.     cd lib/kernel/include
  164.     cp -p local_config.h.default local_config.h
  165.     patch >>$TOP_DIR/config.log 2>&1 <<EOM
  166. --- local_config.h.default  2013-09-09 13:06:33.608248418 -0400
  167. +++ local_config.h  2013-09-09 13:06:50.975847489 -0400
  168. @@ -10,16 +10,16 @@
  169.  */
  170.  
  171.  /* What you want your mud to be called (avoid spaces) */
  172. -#define MUD_NAME  "GurbaLib"
  173. +#define MUD_NAME  "$MUD_NAME"
  174.  
  175.  /* Name for your mud on Intermud (avoid spaces) */
  176. -#define IMUD_NAME "GurbaLib"
  177. +#define IMUD_NAME "$MUD_NAME"
  178.  
  179.  /* To define your email address: */
  180. -#define ADMIN_EMAIL             "you@some.place"
  181. +#define ADMIN_EMAIL             "$EMAIL"
  182.  
  183.  /* Website for the mud if you have one */
  184. -#define WEBSITE "https://github.com/sirdude/gurbalib"
  185. +#define WEBSITE "$URL"
  186.  
  187.  /* To set the linkdeadth timeout (after this linkdead players will be
  188.     disconnected) */
  189. EOM
  190.     cd ../../../..
  191.     echo -en "done.\n"
  192.     return 0
  193. }
  194.  
  195. get_config
  196. fetch_gurba
  197. setup_dirs
  198. fetch_dgd
  199. setup_makefile
  200. build_dgd
  201. setup_config
  202.  
  203. cat <<EOM
  204.  
  205. It looks like everything worked, but you might want to double-check
  206. the log files that were created in this directory.
  207.  
  208. If they look ok, you can launch the MUD by running the startmud script
  209.  
  210. ./gurba/bin/startmud
  211.  
  212. If all went well, you can now connect to the telnet port of your local
  213. machine.
  214.  
  215. telnet localhost $TELNET_PORT
  216.  
  217. The first character logging in will automatically get the
  218. admin role, so be sure its you.
  219.  
  220. Gurbalib ships with an ftp server which is enabled by default,
  221. on whatever port you select + 1, currently $FTP_PORT.
  222.  
  223. For more information, please read the documentation in ./gurba/doc/
  224.  
  225. EOM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement