Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • bootstrapper/bootstrap.sh

    r30 r7  
    11#!/bin/bash
    2 # Version 1
    3 
    4 if [ `id -u` -ne 0 ]; then
    5         echo "This script has to be run as root!"
    6         exit 1
    7 fi
    8 
    9 
     2
     3INSTALLOPTIONALDEPS=0
    104ADDCRONJOBS=0
    115RUNINSTALL=0
    126
    13 DEPENDENCIES="xvfb mono-runtime rsync xmlstarlet"
     7DEPENDENCIES="xvfb mono-runtime rsync libxml2-utils"
     8OPTDEPENDENCIES="sendemail sendxmpp"
    149
    1510if [ -n "$(command -v apt-get)" ]; then
     
    2520fi
    2621
    27 if [ $IS64BIT -eq 1 ]; then
     22if [[ $IS64BIT == 1 ]]; then
    2823        DEPENDENCIES="$DEPENDENCIES lib32gcc1 wine:i386"
    2924else
     
    3227
    3328showHelp() {
    34         echo "Usage: ./bootstrap.sh [-h] [-c] -i"
     29        echo "Usage: ./bootstrap.sh [-h] [-o] [-c] -i"
    3530        echo "Parameters:"
    3631        echo "  -h   Print this help screen and exit"
    37 #       echo "  -o   Install optional dependencies ($OPTDEPENDENCIES)"
     32        echo "  -o   Install optional dependencies ($OPTDEPENDENCIES)"
    3833        echo "  -c   Add cron jobs for save backups and memory checking"
    3934        echo "  -i   Required to actually start the installation"
     
    4641        echo "This will install a 7DtD server according to the information"
    4742        echo "given on:"
    48         echo "   https://7dtd.illy.bz/"
     43        echo "   http://7daystodie.gamepedia.com/Linux_Server"
    4944        echo
    5045        read -p "Press enter to continue"
     
    5348
    5449nonDebianWarning() {
    55         if [ $ISDEBIAN -eq 0 ]; then
     50        if [[ $ISDEBIAN == 0 ]]; then
    5651                echo "NOTE: It seems like this system is not based on Debian."
    5752                echo "Although installation of the scripts and SteamCMD/7dtd"
    5853                echo "will work the installed management scripts will probably"
    59                 echo "fail because of missing dependencies. Make sure you check"
    60                 echo "the website regarding the prerequisites"
    61                 echo "(https://7dtd.illy.bz)."
     54                echo "*NOT* work out of the box and installation of dependencies"
     55                echo "will fail too."
    6256                echo "Do you want to continue anyway?"
    6357                select yn in "Yes" "No"; do
     
    7872installAptDeps() {
    7973        echo -e "Installing dependencies\n"
    80         if [ $IS64BIT -eq 1 ]; then
     74        if [[ $IS64BIT == 1 ]]; then
    8175                dpkg --add-architecture i386
    8276        fi
     
    10195        echo -e "Downloading and installing management scripts\n"
    10296        wget -nv http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
    103         tar --touch -xzf /tmp/management_scripts.tar.gz -C /
    104 
    105         chown root.root /etc/7dtd.conf
    106         chmod 0600 /etc/7dtd.conf
    107 
    108         chown sdtd.sdtd /home/sdtd -R
    109 
    110         chown root.root /etc/init.d/7dtd.sh
    111         chown root.root /etc/bash_completion.d/7dtd
    112         chown root.root /usr/local/bin/7dtd.sh
    113         chown root.root /usr/local/lib/7dtd -R
    114         chmod 0755 /etc/init.d/7dtd.sh
    115         chmod 0755 /etc/bash_completion.d/7dtd
    116         chmod 0755 /usr/local/bin/7dtd.sh
    117         chmod 0755 /usr/local/lib/7dtd -R
    118 
    119         if [ $ISDEBIAN -eq 1 ]; then
     97        tar -xzf /tmp/management_scripts.tar.gz --no-same-owner --owner=root --group=root -C /
     98        chmod go-rwx /etc/7dtd.conf
     99        chmod +x /etc/init.d/7dtd.sh
     100        chmod +x /usr/local/bin/7dtd-*
     101        if [[ $ISDEBIAN == 1 ]]; then
    120102                update-rc.d 7dtd.sh defaults
    121         else
    122                 echo
    123                 echo "Compiling start-stop-daemon"
    124                 cd /usr/local/lib/7dtd/start-stop-daemon
    125                 make
    126                 make install
    127103        fi
    128104        echo -e "\n=============================================================\n\n"
     
    141117installSteamCmdAndSDTD() {
    142118        echo -e "Installing SteamCMD and 7DtD\n"
    143         7dtd.sh updateengine
     119        7dtd-update.sh
     120        cp -p /home/sdtd/7dtd/serverconfig.xml /home/sdtd/
     121        echo -e "\n=============================================================\n\n"
     122}
     123
     124setupServerConfig() {
     125        echo -e "Setting up basic 7DtD server config\n"
     126
     127        until [[ $public == "y" || $public == "n" ]]; do
     128                read -p "Should the server be public [yn]? " public
     129        done
     130        if [[ "$public" == "y" ]]; then public=true; else public=false; fi
     131        echo
     132
     133        read -p "Server name: " servername
     134        echo
     135        read -p "Server password (empty for none): " serverpassword
     136        echo
     137
     138        echo "Select world to play on:"
     139        select worldname in "Navezgane" "MP Forest Horde" "MP Forest Skirmish" "MP Wasteland Horde" "MP Wasteland Skirmish" "MP Wasteland War"; do
     140                if [[ -n $worldname ]]; then
     141                        break
     142                fi
     143        done
     144        echo
     145
     146        echo "Select game mode:"
     147        select gamemode in "GameModeSurvival" "GameModeZombieHorde" "GameModeDeathmatch"; do
     148                if [[ -n $gamemode ]]; then
     149                        break
     150                fi
     151        done
     152        echo
     153
     154        read -p "Game name: " gamename
     155        echo
     156        read -p "Difficulty (0-4): " difficulty
     157        echo
     158
     159        sed -i "s/name=\"ServerIsPublic\".*value=\"[^\"]*\"/name=\"ServerIsPublic\" value=\"$public\"/" /home/sdtd/serverconfig.xml
     160        sed -i "s/name=\"ServerName\".*value=\"[^\"]*\"/name=\"ServerName\" value=\"$servername\"/" /home/sdtd/serverconfig.xml
     161        sed -i "s/name=\"ServerPassword\".*value=\"[^\"]*\"/name=\"ServerPassword\" value=\"$serverpassword\"/" /home/sdtd/serverconfig.xml
     162        sed -i "s/name=\"GameWorld\".*value=\"[^\"]*\"/name=\"GameWorld\" value=\"$worldname\"/" /home/sdtd/serverconfig.xml
     163        sed -i "s/name=\"GameName\".*value=\"[^\"]*\"/name=\"GameName\" value=\"$gamename\"/" /home/sdtd/serverconfig.xml
     164        sed -i "s/name=\"GameDifficulty\".*value=\"[^\"]*\"/name=\"GameDifficulty\" value=\"$difficulty\"/" /home/sdtd/serverconfig.xml
     165        sed -i "s/name=\"GameMode\".*value=\"[^\"]*\"/name=\"GameMode\" value=\"$gamemode\"/" /home/sdtd/serverconfig.xml
     166        sed -i "s/name=\"TelnetPort\".*value=\"[^\"]*\"/name=\"TelnetPort\" value=\"25003\"/" /home/sdtd/serverconfig.xml
     167
    144168        echo -e "\n=============================================================\n\n"
    145169}
    146170
    147171addCronJobs() {
    148         echo -e "Enabling backup cron job\n"
     172        echo -e "Adding cron jobs\n"
    149173
    150174        echo -e "By default a backup of the save folder will be created once"
    151175        echo -e "  per hour. This can be changed in /etc/cron.d/7dtd-backup."
    152        
    153         cat /etc/cron.d/7dtd-backup | tr -d '#' > /tmp/7dtd-backup
    154         cp /tmp/7dtd-backup /etc/cron.d
    155 
     176        echo -e "Memory monitor will be run every five minutes by default."
     177        echo -e "  This can be changed in /etc/cron.d/7dtd-check_mem."
     178
     179        echo "0 *     * * *   root    /usr/local/bin/7dtd-backup.sh" > /etc/cron.d/7dtd-backup
     180        echo "*/5 *   * * *   root    /usr/local/bin/7dtd-check_mem.sh" > /etc/cron.d/7dtd-check_mem
     181
     182        echo -e "\nNOTE: Do not forget to edit /etc/7dtd.conf to match\nyour notification needs!"
    156183        echo -e "\n=============================================================\n\n"
    157184}
    158185
    159186finish() {
    160         if [ $ISDEBIAN -eq 0 ]; then
    161                 echo
    162                 echo "You are not running a Debian based distribution."
    163                 echo "The following things should manually be checked:"
    164                 echo " - Existence of prerequsities"
    165                 echo " - Running the init-script on boot"
    166         else
    167                 echo -e "\n ALL DONE"
    168         fi
    169 
    170         echo
    171         echo -e "You can now continue setting up instances as explained on the website:"
    172         echo -e "  https://7dtd.illy.bz/wiki/Instance%20management"
     187        echo -e "\n ALL DONE\n"
     188        echo -e "You should now be able to start your 7dtd server by running\n"
     189        echo -e "      7dtd-start.sh\n"
    173190        echo
    174191        echo -e "For further configuration options check:"
    175192        echo -e "  /etc/7dtd.conf"
    176         echo
    177         echo -e "For feedback, suggestions, problems please visit the bugtracker:"
    178         echo -e "  https://7dtd.illy.bz/"
     193        echo -e "  /home/sdtd/serverconfig.xml"
     194        echo
     195        echo -e "For feedback, suggestions, problems please visit the forum:"
     196        echo -e "  http://7daystodie.com/forums/showthread.php?2188"
    179197        echo
    180198}
     
    184202        nonDebianWarning
    185203
    186         if [ $ISDEBIAN -eq 1 ]; then
     204        if [[ $ISDEBIAN == 1 ]]; then
    187205                installAptDeps
    188                 if [ $INSTALLOPTIONALDEPS -eq 1 ]; then
    189 #                       installOptionalDeps
     206                if [[ $INSTALLOPTIONALDEPS == 1 ]]; then
     207                        installOptionalDeps
    190208                        echo
    191209                fi
     
    195213        setSteamLoginData
    196214        installSteamCmdAndSDTD
    197         if [ $ADDCRONJOBS -eq 1 ]; then
     215        if [[ $ADDCRONJOBS == 1 ]]; then
    198216                addCronJobs
    199217        fi
     218        setupServerConfig
    200219        finish
    201220}
    202221
    203 if [ -z $1 ]; then
     222if [[ -z $1 ]]; then
    204223        showHelp
    205224        exit 0
     
    222241        esac
    223242done
    224 if [ $RUNINSTALL -eq 1 ]; then
     243if [[ $RUNINSTALL == 1 ]]; then
    225244        main
    226245fi
Note: See TracChangeset for help on using the changeset viewer.