source: bootstrapper/bootstrap.sh@ 30

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

Bootstrapper v1

File size: 5.4 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
12
13DEPENDENCIES="xvfb mono-runtime rsync xmlstarlet"
14
15if [ -n "$(command -v apt-get)" ]; then
16 ISDEBIAN=1
17else
18 ISDEBIAN=0
19fi
20
21if [ $(uname -m) == 'x86_64' ]; then
22 IS64BIT=1
23else
24 IS64BIT=0
25fi
26
27if [ $IS64BIT -eq 1 ]; then
28 DEPENDENCIES="$DEPENDENCIES lib32gcc1 wine:i386"
29else
30 DEPENDENCIES="$DEPENDENCIES wine"
31fi
32
33showHelp() {
34 echo "Usage: ./bootstrap.sh [-h] [-c] -i"
35 echo "Parameters:"
36 echo " -h Print this help screen and exit"
37# echo " -o Install optional dependencies ($OPTDEPENDENCIES)"
38 echo " -c Add cron jobs for save backups and memory checking"
39 echo " -i Required to actually start the installation"
40}
41
42intro() {
43 echo
44 echo "7DtD Linux dedicated server bootstrapper"
45 echo
46 echo "This will install a 7DtD server according to the information"
47 echo "given on:"
48 echo " https://7dtd.illy.bz/"
49 echo
50 read -p "Press enter to continue"
51 echo -e "\n=============================================================\n\n"
52}
53
54nonDebianWarning() {
55 if [ $ISDEBIAN -eq 0 ]; then
56 echo "NOTE: It seems like this system is not based on Debian."
57 echo "Although installation of the scripts and SteamCMD/7dtd"
58 echo "will work the installed management scripts will probably"
59 echo "fail because of missing dependencies. Make sure you check"
60 echo "the website regarding the prerequisites"
61 echo "(https://7dtd.illy.bz)."
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"
80 if [ $IS64BIT -eq 1 ]; then
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
94setupUser() {
95 echo -e "Setting up user and group \"sdtd\"\n"
96 useradd -d /home/sdtd -m -r -s /bin/bash -U sdtd
97 echo -e "\n=============================================================\n\n"
98}
99
100installManagementScripts() {
101 echo -e "Downloading and installing management scripts\n"
102 wget -nv http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
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
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
127 fi
128 echo -e "\n=============================================================\n\n"
129}
130
131setSteamLoginData() {
132 echo -e "Steam account data\n"
133 echo "Please enter your Steam login data for SteamCMD to get the 7dtd-server files:"
134 read -p "Steam username: " username
135 read -s -p "Steam password: " password
136 sed -i "s/export STEAM_USER=/export STEAM_USER=$username/" /etc/7dtd.conf
137 sed -i "s/export STEAM_PASS=/export STEAM_PASS=$password/" /etc/7dtd.conf
138 echo -e "\n=============================================================\n\n"
139}
140
141installSteamCmdAndSDTD() {
142 echo -e "Installing SteamCMD and 7DtD\n"
143 7dtd.sh updateengine
144 echo -e "\n=============================================================\n\n"
145}
146
147addCronJobs() {
148 echo -e "Enabling backup cron job\n"
149
150 echo -e "By default a backup of the save folder will be created once"
151 echo -e " per hour. This can be changed in /etc/cron.d/7dtd-backup."
152
153 cat /etc/cron.d/7dtd-backup | tr -d '#' > /tmp/7dtd-backup
154 cp /tmp/7dtd-backup /etc/cron.d
155
156 echo -e "\n=============================================================\n\n"
157}
158
159finish() {
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"
173 echo
174 echo -e "For further configuration options check:"
175 echo -e " /etc/7dtd.conf"
176 echo
177 echo -e "For feedback, suggestions, problems please visit the bugtracker:"
178 echo -e " https://7dtd.illy.bz/"
179 echo
180}
181
182main() {
183 intro
184 nonDebianWarning
185
186 if [ $ISDEBIAN -eq 1 ]; then
187 installAptDeps
188 if [ $INSTALLOPTIONALDEPS -eq 1 ]; then
189# installOptionalDeps
190 echo
191 fi
192 fi
193 setupUser
194 installManagementScripts
195 setSteamLoginData
196 installSteamCmdAndSDTD
197 if [ $ADDCRONJOBS -eq 1 ]; then
198 addCronJobs
199 fi
200 finish
201}
202
203if [ -z $1 ]; then
204 showHelp
205 exit 0
206fi
207while getopts "hcoi" opt; do
208 case "$opt" in
209 h)
210 showHelp
211 exit 0
212 ;;
213 c)
214 ADDCRONJOBS=1
215 ;;
216 o)
217 INSTALLOPTIONALDEPS=1
218 ;;
219 i)
220 RUNINSTALL=1
221 ;;
222 esac
223done
224if [ $RUNINSTALL -eq 1 ]; then
225 main
226fi
227
Note: See TracBrowser for help on using the repository browser.