Changeset 30 for bootstrapper
- Timestamp:
- May 27, 2014, 12:36:11 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
bootstrapper/bootstrap.sh
r7 r30 1 1 #!/bin/bash 2 3 INSTALLOPTIONALDEPS=0 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 4 10 ADDCRONJOBS=0 5 11 RUNINSTALL=0 6 12 7 DEPENDENCIES="xvfb mono-runtime rsync libxml2-utils" 8 OPTDEPENDENCIES="sendemail sendxmpp" 13 DEPENDENCIES="xvfb mono-runtime rsync xmlstarlet" 9 14 10 15 if [ -n "$(command -v apt-get)" ]; then … … 20 25 fi 21 26 22 if [ [ $IS64BIT == 1 ]]; then27 if [ $IS64BIT -eq 1 ]; then 23 28 DEPENDENCIES="$DEPENDENCIES lib32gcc1 wine:i386" 24 29 else … … 27 32 28 33 showHelp() { 29 echo "Usage: ./bootstrap.sh [-h] [- o] [-c] -i"34 echo "Usage: ./bootstrap.sh [-h] [-c] -i" 30 35 echo "Parameters:" 31 36 echo " -h Print this help screen and exit" 32 echo " -o Install optional dependencies ($OPTDEPENDENCIES)"37 # echo " -o Install optional dependencies ($OPTDEPENDENCIES)" 33 38 echo " -c Add cron jobs for save backups and memory checking" 34 39 echo " -i Required to actually start the installation" … … 41 46 echo "This will install a 7DtD server according to the information" 42 47 echo "given on:" 43 echo " http ://7daystodie.gamepedia.com/Linux_Server"48 echo " https://7dtd.illy.bz/" 44 49 echo 45 50 read -p "Press enter to continue" … … 48 53 49 54 nonDebianWarning() { 50 if [ [ $ISDEBIAN == 0 ]]; then55 if [ $ISDEBIAN -eq 0 ]; then 51 56 echo "NOTE: It seems like this system is not based on Debian." 52 57 echo "Although installation of the scripts and SteamCMD/7dtd" 53 58 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)." 56 62 echo "Do you want to continue anyway?" 57 63 select yn in "Yes" "No"; do … … 72 78 installAptDeps() { 73 79 echo -e "Installing dependencies\n" 74 if [ [ $IS64BIT == 1 ]]; then80 if [ $IS64BIT -eq 1 ]; then 75 81 dpkg --add-architecture i386 76 82 fi … … 95 101 echo -e "Downloading and installing management scripts\n" 96 102 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 102 120 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 103 127 fi 104 128 echo -e "\n=============================================================\n\n" … … 117 141 installSteamCmdAndSDTD() { 118 142 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 168 144 echo -e "\n=============================================================\n\n" 169 145 } 170 146 171 147 addCronJobs() { 172 echo -e " Adding cron jobs\n"148 echo -e "Enabling backup cron job\n" 173 149 174 150 echo -e "By default a backup of the save folder will be created once" 175 151 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 183 156 echo -e "\n=============================================================\n\n" 184 157 } 185 158 186 159 finish() { 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" 190 173 echo 191 174 echo -e "For further configuration options check:" 192 175 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/" 197 179 echo 198 180 } … … 202 184 nonDebianWarning 203 185 204 if [ [ $ISDEBIAN == 1 ]]; then186 if [ $ISDEBIAN -eq 1 ]; then 205 187 installAptDeps 206 if [ [ $INSTALLOPTIONALDEPS == 1 ]]; then207 installOptionalDeps188 if [ $INSTALLOPTIONALDEPS -eq 1 ]; then 189 # installOptionalDeps 208 190 echo 209 191 fi … … 213 195 setSteamLoginData 214 196 installSteamCmdAndSDTD 215 if [ [ $ADDCRONJOBS == 1 ]]; then197 if [ $ADDCRONJOBS -eq 1 ]; then 216 198 addCronJobs 217 199 fi 218 setupServerConfig219 200 finish 220 201 } 221 202 222 if [ [ -z $1 ]]; then203 if [ -z $1 ]; then 223 204 showHelp 224 205 exit 0 … … 241 222 esac 242 223 done 243 if [ [ $RUNINSTALL == 1 ]]; then224 if [ $RUNINSTALL -eq 1 ]; then 244 225 main 245 226 fi
Note:
See TracChangeset
for help on using the changeset viewer.