Index: bootstrapper/bootstrap.sh
===================================================================
--- bootstrapper/bootstrap.sh	(revision 500)
+++ bootstrapper/bootstrap.sh	(revision 1)
@@ -1,31 +1,10 @@
 #!/bin/bash
-VERSION=8
-
-#   Copyright 2016 Christian 'Alloc' Illy
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-
-
-if [ `id -u` -ne 0 ]; then
-	echo "This script has to be run as root!"
-	exit 1
-fi
-
-
+
+INSTALLOPTIONALDEPS=0
 ADDCRONJOBS=0
 RUNINSTALL=0
-INSTALLOPTIONALDEPS=0
-
-DEPENDENCIES="gcc wget rsync xmlstarlet expect"
+
+DEPENDENCIES="xvfb mono-runtime screen rsync libxml2-utils"
+OPTDEPENDENCIES="sendemail sendxmpp"
 
 if [ -n "$(command -v apt-get)" ]; then
@@ -41,16 +20,16 @@
 fi
 
-if [ $IS64BIT -eq 1 ]; then
-	DEPENDENCIES="$DEPENDENCIES lib32gcc-s1"
+if [[ $IS64BIT == 1 ]]; then
+	DEPENDENCIES="$DEPENDENCIES lib32gcc1 wine:i386"
+else
+	DEPENDENCIES="$DEPENDENCIES wine"
 fi
 
 showHelp() {
-	echo "7dtd bootstrapper version $VERSION"
-	echo
-	echo "Usage: ./bootstrap.sh [-h] [-c] -i"
+	echo "Usage: ./bootstrap.sh [-h] [-o] [-c] -i"
 	echo "Parameters:"
 	echo "  -h   Print this help screen and exit"
-#	echo "  -o   Install optional dependencies ($OPTDEPENDENCIES)"
-	echo "  -c   Enable cron job for automatic backups"
+	echo "  -o   Install optional dependencies ($OPTDEPENDENCIES)"
+	echo "  -c   Add cron jobs for save backups and memory checking"
 	echo "  -i   Required to actually start the installation"
 }
@@ -62,5 +41,5 @@
 	echo "This will install a 7DtD server according to the information"
 	echo "given on:"
-	echo "   https://7dtd.illy.bz/"
+	echo "   http://7daystodie.gamepedia.com/Linux_Server"
 	echo
 	read -p "Press enter to continue"
@@ -69,12 +48,10 @@
 
 nonDebianWarning() {
-	if [ $ISDEBIAN -eq 0 ]; then
+	if [[ $ISDEBIAN == 0 ]]; then
 		echo "NOTE: It seems like this system is not based on Debian."
 		echo "Although installation of the scripts and SteamCMD/7dtd"
 		echo "will work the installed management scripts will probably"
-		echo "fail because of missing dependencies. Make sure you check"
-		echo "the website regarding the prerequisites"
-		echo "(https://7dtd.illy.bz)."
-		echo
+		echo "*NOT* work out of the box and installation of dependencies"
+		echo "will fail too."
 		echo "Do you want to continue anyway?"
 		select yn in "Yes" "No"; do
@@ -95,5 +72,5 @@
 installAptDeps() {
 	echo -e "Installing dependencies\n"
-	if [ $IS64BIT -eq 1 ]; then
+	if [[ $IS64BIT == 1 ]]; then
 		dpkg --add-architecture i386
 	fi
@@ -109,51 +86,4 @@
 }
 
-checkSetupDeps() {
-	for DEP in gcc wget tr rsync xmlstarlet expect; do
-		which $DEP > /dev/null 2>&1
-		if [ $? -ne 0 ]; then
-			echo "\"$DEP\" not installed. Please install it and run this script again."
-			exit 1
-		fi
-	done
-	
-	ldconfig -p | grep ld-linux | grep "(ELF)" > /dev/null
-	if [ $? -ne 0 ]; then
-		echo "WARNING: There probably is no 32 Bit version of ld-linux installed."
-		echo "This is most probably part of a 32 Bit version of a glibc-package."
-		echo
-		echo "It will result in errors trying to run SteamCMD if this library is not available!."
-		echo "Do you want to continue anyway?"
-		select yn in "Yes" "No"; do
-			case $yn in
-				Yes)
-					break;;
-				No)
-					echo "Aborting."
-					exit 1
-					;;
-			esac
-		done
-	fi
-
-	ldconfig -p | grep gcc | grep -v 64 > /dev/null
-	if [ $? -ne 0 ]; then
-		echo "WARNING: There probably is no 32 Bit version of libgcc installed."
-		echo
-		echo "It will result in errors trying to run SteamCMD if this library is not available!"
-		echo "Do you want to continue anyway?"
-		select yn in "Yes" "No"; do
-			case $yn in
-				Yes)
-					break;;
-				No)
-					echo "Aborting."
-					exit 1
-					;;
-			esac
-		done
-	fi
-}
-
 setupUser() {
 	echo -e "Setting up user and group \"sdtd\"\n"
@@ -164,43 +94,22 @@
 installManagementScripts() {
 	echo -e "Downloading and installing management scripts\n"
-	wget -nv https://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
-	TMPPATH=`mktemp -d`
-	tar --touch --no-overwrite-dir -xzf /tmp/management_scripts.tar.gz -C $TMPPATH
-	cd $TMPPATH
-	for SRCFILE in `find * -type f`; do
-		DESTFOLDER=/`dirname $SRCFILE`
-		mkdir -p $DESTFOLDER
-		cp -a $SRCFILE $DESTFOLDER/
-	done
-	rm -R $TMPPATH
-
-	chown root:root /etc/7dtd.conf
-	chmod 0600 /etc/7dtd.conf
-
-	chown sdtd:sdtd /home/sdtd -R
-
-	chown root:root /etc/init.d/7dtd.sh
-	chown root:root /etc/bash_completion.d/7dtd
-	chown root:root /etc/cron.d/7dtd-backup
-	chown root:root /usr/local/bin/7dtd.sh
-	chown root:root /usr/local/lib/7dtd -R
-	chmod 0755 /etc/init.d/7dtd.sh
-	chmod 0755 /etc/bash_completion.d/7dtd
-	chmod 0755 /etc/cron.d/7dtd-backup
-	chmod 0755 /usr/local/bin/7dtd.sh
-	chmod 0755 /usr/local/lib/7dtd -R
-
-	if [ $ISDEBIAN -eq 1 ]; then
+	wget -nv http://illy.bz/fi/7dtd/management_scripts.tar.gz -O /tmp/management_scripts.tar.gz
+	tar -xzf /tmp/management_scripts.tar.gz --no-same-owner --owner=root --group=root -C /
+	chmod go-rwx /etc/7dtd.conf
+	chmod +x /etc/init.d/7dtd.sh
+	chmod +x /usr/local/bin/7dtd-*
+	if [[ $ISDEBIAN == 1 ]]; then
 		update-rc.d 7dtd.sh defaults
 	fi
-	
-	echo
-	echo "Compiling start-stop-daemon"
-	cd /usr/local/lib/7dtd/start-stop-daemon
-
-	gcc -Wall -Wextra -Wno-return-type -o start-stop-daemon start-stop-daemon.c
-	chown root:root start-stop-daemon
-	chmod 0755 start-stop-daemon
-
+	echo -e "\n=============================================================\n\n"
+}
+
+setSteamLoginData() {
+	echo -e "Steam account data\n"
+	echo "Please enter your Steam login data for SteamCMD to get the 7dtd-server files:"
+	read -p "Steam username: " username
+	read -s -p "Steam password: " password
+	sed -i "s/export STEAM_USER=/export STEAM_USER=$username/" /etc/7dtd.conf
+	sed -i "s/export STEAM_PASS=/export STEAM_PASS=$password/" /etc/7dtd.conf
 	echo -e "\n=============================================================\n\n"
 }
@@ -208,43 +117,82 @@
 installSteamCmdAndSDTD() {
 	echo -e "Installing SteamCMD and 7DtD\n"
-	7dtd.sh updateengine
+	7dtd-update.sh
+	cp -p /home/sdtd/7dtd/serverconfig.xml /home/sdtd/
+	echo -e "\n=============================================================\n\n"
+}
+
+setupServerConfig() {
+	echo -e "Setting up basic 7DtD server config\n"
+
+	until [[ $public == "y" || $public == "n" ]]; do
+		read -p "Should the server be public [yn]? " public
+	done
+	if [[ "$public" == "y" ]]; then public=true; else public=false; fi
+	echo
+
+	read -p "Server name: " servername
+	echo
+	read -p "Server password (empty for none): " serverpassword
+	echo
+
+	echo "Select world to play on:"
+	select worldname in "Navezgane" "MP Forest Horde" "MP Forest Skirmish" "MP Wasteland Horde" "MP Wasteland Skirmish" "MP Wasteland War"; do
+		if [[ -n $worldname ]]; then
+			break
+		fi
+	done
+	echo
+
+	echo "Select game mode:"
+	select gamemode in "GameModeSurvival" "GameModeZombieHorde" "GameModeDeathmatch"; do
+		if [[ -n $gamemode ]]; then
+			break
+		fi
+	done
+	echo
+
+	read -p "Game name: " gamename
+	echo
+	read -p "Difficulty (0-4): " difficulty
+	echo
+
+	sed -i "s/name=\"ServerIsPublic\".*value=\"[^\"]*\"/name=\"ServerIsPublic\" value=\"$public\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"ServerName\".*value=\"[^\"]*\"/name=\"ServerName\" value=\"$servername\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"ServerPassword\".*value=\"[^\"]*\"/name=\"ServerPassword\" value=\"$serverpassword\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"GameWorld\".*value=\"[^\"]*\"/name=\"GameWorld\" value=\"$worldname\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"GameName\".*value=\"[^\"]*\"/name=\"GameName\" value=\"$gamename\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"GameDifficulty\".*value=\"[^\"]*\"/name=\"GameDifficulty\" value=\"$difficulty\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"GameMode\".*value=\"[^\"]*\"/name=\"GameMode\" value=\"$gamemode\"/" /home/sdtd/serverconfig.xml
+	sed -i "s/name=\"TelnetPort\".*value=\"[^\"]*\"/name=\"TelnetPort\" value=\"25003\"/" /home/sdtd/serverconfig.xml
+
 	echo -e "\n=============================================================\n\n"
 }
 
 addCronJobs() {
-	echo -e "Enabling backup cron job\n"
+	echo -e "Adding cron jobs\n"
 
 	echo -e "By default a backup of the save folder will be created once"
 	echo -e "  per hour. This can be changed in /etc/cron.d/7dtd-backup."
-	
-	cat /etc/cron.d/7dtd-backup | tr -d '#' > /tmp/7dtd-backup
-	cp /tmp/7dtd-backup /etc/cron.d
-
+	echo -e "Memory monitor will be run every five minutes by default."
+	echo -e "  This can be changed in /etc/cron.d/7dtd-check_mem."
+
+	echo "0 *     * * *   root    /usr/local/bin/7dtd-backup.sh" > /etc/cron.d/7dtd-backup
+	echo "*/5 *   * * *   root    /usr/local/bin/7dtd-check_mem.sh" > /etc/cron.d/7dtd-check_mem
+
+	echo -e "\nNOTE: Do not forget to edit /etc/7dtd.conf to match\nyour notification needs!"
 	echo -e "\n=============================================================\n\n"
 }
 
 finish() {
-	if [ $ISDEBIAN -eq 0 ]; then
-		echo
-		echo "You are not running a Debian based distribution."
-		echo "The following things should manually be checked:"
-		echo " - Existence of prerequsities"
-		echo " - Running the init-script on boot"
-	else
-		echo -e "\n ALL DONE"
-	fi
-
-	echo
-	echo -e "You can now continue setting up instances as explained on the website:"
-	echo -e "  https://7dtd.illy.bz/wiki/Instance%20management"
-	echo
-	echo -e "You might also need to manually enable bash auto completion, refer to:"
-	echo -e "  https://7dtd.illy.bz/wiki/Installation#Bashcompletion"
+	echo -e "\n ALL DONE\n"
+	echo -e "You should now be able to start your 7dtd server by running\n"
+	echo -e "      7dtd-start.sh\n"
 	echo
 	echo -e "For further configuration options check:"
 	echo -e "  /etc/7dtd.conf"
-	echo
-	echo -e "For feedback, suggestions, problems please visit the bugtracker:"
-	echo -e "  https://7dtd.illy.bz/"
+	echo -e "  /home/sdtd/serverconfig.xml"
+	echo
+	echo -e "For feedback, suggestions, problems please visit the forum:"
+	echo -e "  http://7daystodie.com/forums/showthread.php?2188"
 	echo
 }
@@ -254,23 +202,23 @@
 	nonDebianWarning
 
-	if [ $ISDEBIAN -eq 1 ]; then
+	if [[ $ISDEBIAN == 1 ]]; then
 		installAptDeps
-		if [ $INSTALLOPTIONALDEPS -eq 1 ]; then
-#			installOptionalDeps
+		if [[ $INSTALLOPTIONALDEPS == 1 ]]; then
+			installOptionalDeps
 			echo
 		fi
-	else
-		checkSetupDeps
 	fi
 	setupUser
 	installManagementScripts
+	setSteamLoginData
 	installSteamCmdAndSDTD
-	if [ $ADDCRONJOBS -eq 1 ]; then
+	if [[ $ADDCRONJOBS == 1 ]]; then
 		addCronJobs
 	fi
+	setupServerConfig
 	finish
 }
 
-if [ -z $1 ]; then
+if [[ -z $1 ]]; then
 	showHelp
 	exit 0
@@ -293,5 +241,5 @@
 	esac
 done
-if [ $RUNINSTALL -eq 1 ]; then
+if [[ $RUNINSTALL == 1 ]]; then
 	main
 fi
