source: bootstrapper/bootstrap.sh@ 42

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

Minor bootstrapper changes

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