source: bootstrapper/bootstrap.sh@ 45

Last change on this file since 45 was 44, checked in by alloc, 10 years ago

Bootstrapper fix

File size: 7.2 KB
RevLine 
[1]1#!/bin/bash
[30]2# Version 1
[1]3
[30]4if [ `id -u` -ne 0 ]; then
5 echo "This script has to be run as root!"
6 exit 1
7fi
8
9
[1]10ADDCRONJOBS=0
11RUNINSTALL=0
[32]12INSTALLOPTIONALDEPS=0
[1]13
[44]14DEPENDENCIES="gcc wget rsync xmlstarlet"
[1]15
16if [ -n "$(command -v apt-get)" ]; then
17 ISDEBIAN=1
18else
19 ISDEBIAN=0
20fi
21
22if [ $(uname -m) == 'x86_64' ]; then
23 IS64BIT=1
24else
25 IS64BIT=0
26fi
27
[30]28if [ $IS64BIT -eq 1 ]; then
[35]29 DEPENDENCIES="$DEPENDENCIES lib32gcc1"
[1]30fi
31
32showHelp() {
[30]33 echo "Usage: ./bootstrap.sh [-h] [-c] -i"
[1]34 echo "Parameters:"
35 echo " -h Print this help screen and exit"
[30]36# echo " -o Install optional dependencies ($OPTDEPENDENCIES)"
[31]37 echo " -c Enable cron job for automatic backups"
[1]38 echo " -i Required to actually start the installation"
39}
40
41intro() {
42 echo
43 echo "7DtD Linux dedicated server bootstrapper"
44 echo
45 echo "This will install a 7DtD server according to the information"
46 echo "given on:"
[30]47 echo " https://7dtd.illy.bz/"
[1]48 echo
49 read -p "Press enter to continue"
50 echo -e "\n=============================================================\n\n"
51}
52
53nonDebianWarning() {
[30]54 if [ $ISDEBIAN -eq 0 ]; then
[1]55 echo "NOTE: It seems like this system is not based on Debian."
56 echo "Although installation of the scripts and SteamCMD/7dtd"
57 echo "will work the installed management scripts will probably"
[30]58 echo "fail because of missing dependencies. Make sure you check"
59 echo "the website regarding the prerequisites"
60 echo "(https://7dtd.illy.bz)."
[35]61 echo
[1]62 echo "Do you want to continue anyway?"
63 select yn in "Yes" "No"; do
64 case $yn in
65 Yes)
66 echo "Continuing..."
67 break;;
68 No)
69 echo "Aborting."
70 exit 0
71 ;;
72 esac
73 done
74 echo -e "\n=============================================================\n\n"
75 fi
76}
77
78installAptDeps() {
79 echo -e "Installing dependencies\n"
[30]80 if [ $IS64BIT -eq 1 ]; then
[1]81 dpkg --add-architecture i386
82 fi
83 apt-get update
84 apt-get install $DEPENDENCIES
85 echo -e "\n=============================================================\n\n"
86}
87
88installOptionalDeps() {
89 echo -e "Installing optional dependencies\n"
90 apt-get install $OPTDEPENDENCIES
91 echo -e "\n=============================================================\n\n"
92}
93
[32]94checkSetupDeps() {
[40]95 for DEP in gcc wget tr rsync xmlstarlet; do
[41]96 which $DEP > /dev/null 2>&1
[39]97 if [ $? -ne 0 ]; then
98 echo "\"$DEP\" not installed. Please install it and run this script again."
99 exit 1
100 fi
101 done
[35]102
[42]103 ldconfig -p | grep ld-linux | grep "(ELF)" > /dev/null
104 if [ $? -ne 0 ]; then
105 echo "WARNING: There probably is no 32 Bit version of ld-linux installed."
106 echo "This is most probably part of a 32 Bit version of a glibc-package."
[43]107 echo
108 echo "It will result in errors trying to run SteamCMD if this library is not available!."
[42]109 echo "Do you want to continue anyway?"
110 select yn in "Yes" "No"; do
111 case $yn in
112 Yes)
113 break;;
114 No)
115 echo "Aborting."
116 exit 1
117 ;;
118 esac
119 done
120 fi
121
[35]122 ldconfig -p | grep gcc | grep -v 64 > /dev/null
123 if [ $? -ne 0 ]; then
[42]124 echo "WARNING: There probably is no 32 Bit version of libgcc installed."
[43]125 echo
126 echo "It will result in errors trying to run SteamCMD if this library is not available!"
[42]127 echo "Do you want to continue anyway?"
[35]128 select yn in "Yes" "No"; do
129 case $yn in
130 Yes)
131 break;;
132 No)
133 echo "Aborting."
[38]134 exit 1
[35]135 ;;
136 esac
137 done
138 fi
[32]139}
140
[1]141setupUser() {
142 echo -e "Setting up user and group \"sdtd\"\n"
143 useradd -d /home/sdtd -m -r -s /bin/bash -U sdtd
144 echo -e "\n=============================================================\n\n"
145}
146
147installManagementScripts() {
148 echo -e "Downloading and installing management scripts\n"
149 wget -nv http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
[30]150 tar --touch -xzf /tmp/management_scripts.tar.gz -C /
151
152 chown root.root /etc/7dtd.conf
153 chmod 0600 /etc/7dtd.conf
154
155 chown sdtd.sdtd /home/sdtd -R
156
157 chown root.root /etc/init.d/7dtd.sh
158 chown root.root /etc/bash_completion.d/7dtd
159 chown root.root /usr/local/bin/7dtd.sh
160 chown root.root /usr/local/lib/7dtd -R
161 chmod 0755 /etc/init.d/7dtd.sh
162 chmod 0755 /etc/bash_completion.d/7dtd
163 chmod 0755 /usr/local/bin/7dtd.sh
164 chmod 0755 /usr/local/lib/7dtd -R
165
166 if [ $ISDEBIAN -eq 1 ]; then
[1]167 update-rc.d 7dtd.sh defaults
[32]168 fi
169
170 echo
171 echo "Compiling start-stop-daemon"
172 cd /usr/local/lib/7dtd/start-stop-daemon
[31]173
[32]174 gcc -Wall -Wextra -Wno-return-type -o start-stop-daemon start-stop-daemon.c
175 chown root.root start-stop-daemon
176 chmod 0755 start-stop-daemon
177
[1]178 echo -e "\n=============================================================\n\n"
179}
180
[35]181installLinuxEngine() {
182 echo -e "Downloading and installing Linux engine\n"
183 wget -nv http://illy.bz/fi/7dtd/linux_files.tar.gz -O /tmp/linux_files.tar.gz
[36]184 tar --touch -xzf /tmp/linux_files.tar.gz -C /home/sdtd/
[35]185
[37]186 chown sdtd.sdtd -R /home/sdtd/linux_files
[36]187 chmod 0644 -R /home/sdtd/linux_files
[37]188 find /home/sdtd/linux_files -type d -exec chmod 0755 {} \;
[35]189 chmod 0755 /home/sdtd/linux_files/engine/7DaysToDie.x86
190
191 echo -e "\n=============================================================\n\n"
192}
193
[1]194setSteamLoginData() {
195 echo -e "Steam account data\n"
196 echo "Please enter your Steam login data for SteamCMD to get the 7dtd-server files:"
197 read -p "Steam username: " username
198 read -s -p "Steam password: " password
199 sed -i "s/export STEAM_USER=/export STEAM_USER=$username/" /etc/7dtd.conf
200 sed -i "s/export STEAM_PASS=/export STEAM_PASS=$password/" /etc/7dtd.conf
201 echo -e "\n=============================================================\n\n"
202}
203
204installSteamCmdAndSDTD() {
205 echo -e "Installing SteamCMD and 7DtD\n"
[30]206 7dtd.sh updateengine
[1]207 echo -e "\n=============================================================\n\n"
208}
209
210addCronJobs() {
[30]211 echo -e "Enabling backup cron job\n"
[1]212
213 echo -e "By default a backup of the save folder will be created once"
214 echo -e " per hour. This can be changed in /etc/cron.d/7dtd-backup."
[30]215
216 cat /etc/cron.d/7dtd-backup | tr -d '#' > /tmp/7dtd-backup
217 cp /tmp/7dtd-backup /etc/cron.d
[1]218
219 echo -e "\n=============================================================\n\n"
220}
221
222finish() {
[30]223 if [ $ISDEBIAN -eq 0 ]; then
224 echo
225 echo "You are not running a Debian based distribution."
226 echo "The following things should manually be checked:"
227 echo " - Existence of prerequsities"
228 echo " - Running the init-script on boot"
229 else
230 echo -e "\n ALL DONE"
231 fi
232
[1]233 echo
[30]234 echo -e "You can now continue setting up instances as explained on the website:"
235 echo -e " https://7dtd.illy.bz/wiki/Instance%20management"
236 echo
[31]237 echo -e "You might also need to manually enable bash auto completion, refer to:"
238 echo -e " https://7dtd.illy.bz/wiki/Installation#Bashcompletion"
239 echo
[1]240 echo -e "For further configuration options check:"
241 echo -e " /etc/7dtd.conf"
242 echo
[30]243 echo -e "For feedback, suggestions, problems please visit the bugtracker:"
244 echo -e " https://7dtd.illy.bz/"
[1]245 echo
246}
247
248main() {
249 intro
250 nonDebianWarning
251
[30]252 if [ $ISDEBIAN -eq 1 ]; then
[1]253 installAptDeps
[30]254 if [ $INSTALLOPTIONALDEPS -eq 1 ]; then
255# installOptionalDeps
[1]256 echo
257 fi
[32]258 else
[38]259 checkSetupDeps
[1]260 fi
261 setupUser
262 installManagementScripts
[35]263 installLinuxEngine
[1]264 setSteamLoginData
265 installSteamCmdAndSDTD
[30]266 if [ $ADDCRONJOBS -eq 1 ]; then
[1]267 addCronJobs
268 fi
269 finish
270}
271
[30]272if [ -z $1 ]; then
[1]273 showHelp
274 exit 0
275fi
276while getopts "hcoi" opt; do
277 case "$opt" in
278 h)
279 showHelp
280 exit 0
281 ;;
282 c)
283 ADDCRONJOBS=1
284 ;;
285 o)
286 INSTALLOPTIONALDEPS=1
287 ;;
288 i)
289 RUNINSTALL=1
290 ;;
291 esac
292done
[30]293if [ $RUNINSTALL -eq 1 ]; then
[1]294 main
295fi
296
Note: See TracBrowser for help on using the repository browser.