Changeset 30 for bootstrapper


Ignore:
Timestamp:
May 27, 2014, 12:36:11 PM (10 years ago)
Author:
alloc
Message:

Bootstrapper v1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bootstrapper/bootstrap.sh

    r7 r30  
    11#!/bin/bash
    2 
    3 INSTALLOPTIONALDEPS=0
     2# Version 1
     3
     4if [ `id -u` -ne 0 ]; then
     5        echo "This script has to be run as root!"
     6        exit 1
     7fi
     8
     9
    410ADDCRONJOBS=0
    511RUNINSTALL=0
    612
    7 DEPENDENCIES="xvfb mono-runtime rsync libxml2-utils"
    8 OPTDEPENDENCIES="sendemail sendxmpp"
     13DEPENDENCIES="xvfb mono-runtime rsync xmlstarlet"
    914
    1015if [ -n "$(command -v apt-get)" ]; then
     
    2025fi
    2126
    22 if [[ $IS64BIT == 1 ]]; then
     27if [ $IS64BIT -eq 1 ]; then
    2328        DEPENDENCIES="$DEPENDENCIES lib32gcc1 wine:i386"
    2429else
     
    2732
    2833showHelp() {
    29         echo "Usage: ./bootstrap.sh [-h] [-o] [-c] -i"
     34        echo "Usage: ./bootstrap.sh [-h] [-c] -i"
    3035        echo "Parameters:"
    3136        echo "  -h   Print this help screen and exit"
    32         echo "  -o   Install optional dependencies ($OPTDEPENDENCIES)"
     37#       echo "  -o   Install optional dependencies ($OPTDEPENDENCIES)"
    3338        echo "  -c   Add cron jobs for save backups and memory checking"
    3439        echo "  -i   Required to actually start the installation"
     
    4146        echo "This will install a 7DtD server according to the information"
    4247        echo "given on:"
    43         echo "   http://7daystodie.gamepedia.com/Linux_Server"
     48        echo "   https://7dtd.illy.bz/"
    4449        echo
    4550        read -p "Press enter to continue"
     
    4853
    4954nonDebianWarning() {
    50         if [[ $ISDEBIAN == 0 ]]; then
     55        if [ $ISDEBIAN -eq 0 ]; then
    5156                echo "NOTE: It seems like this system is not based on Debian."
    5257                echo "Although installation of the scripts and SteamCMD/7dtd"
    5358                echo "will work the installed management scripts will probably"
    54                 echo "*NOT* work out of the box and installation of dependencies"
    55                 echo "will fail too."
     59                echo "fail because of missing dependencies. Make sure you check"
     60                echo "the website regarding the prerequisites"
     61                echo "(https://7dtd.illy.bz)."
    5662                echo "Do you want to continue anyway?"
    5763                select yn in "Yes" "No"; do
     
    7278installAptDeps() {
    7379        echo -e "Installing dependencies\n"
    74         if [[ $IS64BIT == 1 ]]; then
     80        if [ $IS64BIT -eq 1 ]; then
    7581                dpkg --add-architecture i386
    7682        fi
     
    95101        echo -e "Downloading and installing management scripts\n"
    96102        wget -nv http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
    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
     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
    102120                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
    103127        fi
    104128        echo -e "\n=============================================================\n\n"
     
    117141installSteamCmdAndSDTD() {
    118142        echo -e "Installing SteamCMD and 7DtD\n"
    119         7dtd-update.sh
    120         cp -p /home/sdtd/7dtd/serverconfig.xml /home/sdtd/
    121         echo -e "\n=============================================================\n\n"
    122 }
    123 
    124 setupServerConfig() {
    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 
     143        7dtd.sh updateengine
    168144        echo -e "\n=============================================================\n\n"
    169145}
    170146
    171147addCronJobs() {
    172         echo -e "Adding cron jobs\n"
     148        echo -e "Enabling backup cron job\n"
    173149
    174150        echo -e "By default a backup of the save folder will be created once"
    175151        echo -e "  per hour. This can be changed in /etc/cron.d/7dtd-backup."
    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!"
     152       
     153        cat /etc/cron.d/7dtd-backup | tr -d '#' > /tmp/7dtd-backup
     154        cp /tmp/7dtd-backup /etc/cron.d
     155
    183156        echo -e "\n=============================================================\n\n"
    184157}
    185158
    186159finish() {
    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"
     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"
    190173        echo
    191174        echo -e "For further configuration options check:"
    192175        echo -e "  /etc/7dtd.conf"
    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"
     176        echo
     177        echo -e "For feedback, suggestions, problems please visit the bugtracker:"
     178        echo -e "  https://7dtd.illy.bz/"
    197179        echo
    198180}
     
    202184        nonDebianWarning
    203185
    204         if [[ $ISDEBIAN == 1 ]]; then
     186        if [ $ISDEBIAN -eq 1 ]; then
    205187                installAptDeps
    206                 if [[ $INSTALLOPTIONALDEPS == 1 ]]; then
    207                         installOptionalDeps
     188                if [ $INSTALLOPTIONALDEPS -eq 1 ]; then
     189#                       installOptionalDeps
    208190                        echo
    209191                fi
     
    213195        setSteamLoginData
    214196        installSteamCmdAndSDTD
    215         if [[ $ADDCRONJOBS == 1 ]]; then
     197        if [ $ADDCRONJOBS -eq 1 ]; then
    216198                addCronJobs
    217199        fi
    218         setupServerConfig
    219200        finish
    220201}
    221202
    222 if [[ -z $1 ]]; then
     203if [ -z $1 ]; then
    223204        showHelp
    224205        exit 0
     
    241222        esac
    242223done
    243 if [[ $RUNINSTALL == 1 ]]; then
     224if [ $RUNINSTALL -eq 1 ]; then
    244225        main
    245226fi
Note: See TracChangeset for help on using the changeset viewer.