source: bootstrapper/bootstrap.sh@ 245

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

Scripts 79: Do not require to store Steam account data

File size: 7.3 KB
Line 
1#!/bin/bash
2VERSION=6
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 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 "7dtd bootstrapper version $VERSION"
34 echo
35 echo "Usage: ./bootstrap.sh [-h] [-c] -i"
36 echo "Parameters:"
37 echo " -h Print this help screen and exit"
38# echo " -o Install optional dependencies ($OPTDEPENDENCIES)"
39 echo " -c Enable cron job for automatic backups"
40 echo " -i Required to actually start the installation"
41}
42
43intro() {
44 echo
45 echo "7DtD Linux dedicated server bootstrapper"
46 echo
47 echo "This will install a 7DtD server according to the information"
48 echo "given on:"
49 echo " https://7dtd.illy.bz/"
50 echo
51 read -p "Press enter to continue"
52 echo -e "\n=============================================================\n\n"
53}
54
55nonDebianWarning() {
56 if [ $ISDEBIAN -eq 0 ]; then
57 echo "NOTE: It seems like this system is not based on Debian."
58 echo "Although installation of the scripts and SteamCMD/7dtd"
59 echo "will work the installed management scripts will probably"
60 echo "fail because of missing dependencies. Make sure you check"
61 echo "the website regarding the prerequisites"
62 echo "(https://7dtd.illy.bz)."
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
110 echo "It will result in errors trying to run SteamCMD if this library is not available!."
111 echo "Do you want to continue anyway?"
112 select yn in "Yes" "No"; do
113 case $yn in
114 Yes)
115 break;;
116 No)
117 echo "Aborting."
118 exit 1
119 ;;
120 esac
121 done
122 fi
123
124 ldconfig -p | grep gcc | grep -v 64 > /dev/null
125 if [ $? -ne 0 ]; then
126 echo "WARNING: There probably is no 32 Bit version of libgcc installed."
127 echo
128 echo "It will result in errors trying to run SteamCMD if this library is not available!"
129 echo "Do you want to continue anyway?"
130 select yn in "Yes" "No"; do
131 case $yn in
132 Yes)
133 break;;
134 No)
135 echo "Aborting."
136 exit 1
137 ;;
138 esac
139 done
140 fi
141}
142
143setupUser() {
144 echo -e "Setting up user and group \"sdtd\"\n"
145 useradd -d /home/sdtd -m -r -s /bin/bash -U sdtd
146 echo -e "\n=============================================================\n\n"
147}
148
149installManagementScripts() {
150 echo -e "Downloading and installing management scripts\n"
151 wget -nv http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
152 tar --touch --no-overwrite-dir -xzf /tmp/management_scripts.tar.gz -C /
153
154 chown root.root /etc/7dtd.conf
155 chmod 0600 /etc/7dtd.conf
156
157 chown sdtd.sdtd /home/sdtd -R
158
159 chown root.root /etc/init.d/7dtd.sh
160 chown root.root /etc/bash_completion.d/7dtd
161 chown root.root /etc/cron.d/7dtd-backup
162 chown root.root /usr/local/bin/7dtd.sh
163 chown root.root /usr/local/lib/7dtd -R
164 chmod 0755 /etc/init.d/7dtd.sh
165 chmod 0755 /etc/bash_completion.d/7dtd
166 chmod 0755 /etc/cron.d/7dtd-backup
167 chmod 0755 /usr/local/bin/7dtd.sh
168 chmod 0755 /usr/local/lib/7dtd -R
169
170 if [ $ISDEBIAN -eq 1 ]; then
171 update-rc.d 7dtd.sh defaults
172 fi
173
174 echo
175 echo "Compiling start-stop-daemon"
176 cd /usr/local/lib/7dtd/start-stop-daemon
177
178 gcc -Wall -Wextra -Wno-return-type -o start-stop-daemon start-stop-daemon.c
179 chown root.root start-stop-daemon
180 chmod 0755 start-stop-daemon
181
182 echo -e "\n=============================================================\n\n"
183}
184
185setSteamLoginData() {
186 echo -e "Steam account data\n"
187 echo -e "Steam account login data is required for SteamCMD to get the 7dtd-server files.\n"
188 echo -e "Store account login data in /etc/7dtd.conf which will be only readable by root?"
189 echo -e "If you select to NOT store the data you will have to enter it each time you want"
190 echo -e "to update the server files.\n"
191 while : ; do
192 local STOREDATA
193 read -p "Store data in /etc/7dtd.conf? (yn) " STOREDATA
194 case $STOREDATA in
195 y)
196 read -p "Steam username: " username
197 read -s -p "Steam password: " password
198 sed -i "s/export STEAM_USER=/export STEAM_USER=$username/" /etc/7dtd.conf
199 sed -i "s/export STEAM_PASS=/export STEAM_PASS=$password/" /etc/7dtd.conf
200 echo -e "\n=============================================================\n\n"
201 break
202 ;;
203 n)
204 break
205 ;;
206 *)
207 echo "Wrong input"
208 esac
209 done
210}
211
212installSteamCmdAndSDTD() {
213 echo -e "Installing SteamCMD and 7DtD\n"
214 7dtd.sh updateengine
215 echo -e "\n=============================================================\n\n"
216}
217
218addCronJobs() {
219 echo -e "Enabling backup cron job\n"
220
221 echo -e "By default a backup of the save folder will be created once"
222 echo -e " per hour. This can be changed in /etc/cron.d/7dtd-backup."
223
224 cat /etc/cron.d/7dtd-backup | tr -d '#' > /tmp/7dtd-backup
225 cp /tmp/7dtd-backup /etc/cron.d
226
227 echo -e "\n=============================================================\n\n"
228}
229
230finish() {
231 if [ $ISDEBIAN -eq 0 ]; then
232 echo
233 echo "You are not running a Debian based distribution."
234 echo "The following things should manually be checked:"
235 echo " - Existence of prerequsities"
236 echo " - Running the init-script on boot"
237 else
238 echo -e "\n ALL DONE"
239 fi
240
241 echo
242 echo -e "You can now continue setting up instances as explained on the website:"
243 echo -e " https://7dtd.illy.bz/wiki/Instance%20management"
244 echo
245 echo -e "You might also need to manually enable bash auto completion, refer to:"
246 echo -e " https://7dtd.illy.bz/wiki/Installation#Bashcompletion"
247 echo
248 echo -e "For further configuration options check:"
249 echo -e " /etc/7dtd.conf"
250 echo
251 echo -e "For feedback, suggestions, problems please visit the bugtracker:"
252 echo -e " https://7dtd.illy.bz/"
253 echo
254}
255
256main() {
257 intro
258 nonDebianWarning
259
260 if [ $ISDEBIAN -eq 1 ]; then
261 installAptDeps
262 if [ $INSTALLOPTIONALDEPS -eq 1 ]; then
263# installOptionalDeps
264 echo
265 fi
266 else
267 checkSetupDeps
268 fi
269 setupUser
270 installManagementScripts
271 setSteamLoginData
272 installSteamCmdAndSDTD
273 if [ $ADDCRONJOBS -eq 1 ]; then
274 addCronJobs
275 fi
276 finish
277}
278
279if [ -z $1 ]; then
280 showHelp
281 exit 0
282fi
283while getopts "hcoi" opt; do
284 case "$opt" in
285 h)
286 showHelp
287 exit 0
288 ;;
289 c)
290 ADDCRONJOBS=1
291 ;;
292 o)
293 INSTALLOPTIONALDEPS=1
294 ;;
295 i)
296 RUNINSTALL=1
297 ;;
298 esac
299done
300if [ $RUNINSTALL -eq 1 ]; then
301 main
302fi
303
Note: See TracBrowser for help on using the repository browser.