Browse Source

Merge pull request #405 from dgibbs64/ts3server-installer

Ts3server installer
Daniel Gibbs 11 years ago
parent
commit
b8d51b7035

+ 2 - 35
functions/fn_check_logs

@@ -10,40 +10,7 @@ if [ ! -d "${scriptlogdir}" ]; then
 	fn_printdots "Checking for log files"
 	fn_printdots "Checking for log files"
 	sleep 1
 	sleep 1
 	fn_printinfo "Checking for log files: Creating log files"
 	fn_printinfo "Checking for log files: Creating log files"
-	sleep 1
 	echo -en "\n"
 	echo -en "\n"
-	mkdir -v "${rootdir}/log"
-	mkdir -v "${scriptlogdir}"
-	touch "${scriptlog}"
-	if [ -n "${consolelogdir}" ]; then
-		mkdir -v "${consolelogdir}"
-		touch "${consolelog}"
-	fi
-
-	# If a server is source or goldsource, Teamspeak 3, Starbound, Project Zomhoid create a symbolic link to the game server logs.
-	if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${gamename}" == "Teamspeak 3" ]||[ "${engine}" == "starbound" ]||[ "${engine}" == "projectzomboid" ]; then
-		if [ ! -h "${rootdir}/log/server" ]; then
-			ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
-		fi
-	fi
-
-	# If a server is unreal2 or unity3d create a dir.
-	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]; then
-		mkdir -pv "${gamelogdir}"
-	fi
-
-	# If a server is 7 Days to Die.
-	if [ "${gamename}" == "7 Days To Die" ]; then
-		if [ ! -h "${gamelogdir}/output_log.txt" ]; then
-			ln -nfsv "${filesdir}/7DaysToDie_Data/output_log.txt" "${gamelogdir}/output_log.txt"
-		fi
-	fi
-
-	# If server uses SteamCMD create a symbolic link to the Steam logs.
-	if [ -d "${rootdir}/Steam/logs" ]; then
-		if [ ! -h "${rootdir}/log/steamcmd" ]; then
-			ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd"
-		fi
-	fi
-	sleep 1
+	checklogs=1
+	fn_install_logs
 fi
 fi

+ 6 - 1
functions/fn_functions

@@ -2,7 +2,7 @@
 # LGSM fn_functions function
 # LGSM fn_functions function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 # Website: http://gameservermanagers.com
-# Version: 190515
+# Version: 240515
 
 
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # This function is called first before any other function. Without this file other functions would not load.
 # This function is called first before any other function. Without this file other functions would not load.
@@ -253,6 +253,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction
 }
 }
 
 
+fn_install_ts3(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
 fn_install_ut2k4(){
 fn_install_ut2k4(){
 functionfile="${FUNCNAME}"
 functionfile="${FUNCNAME}"
 fn_runfunction
 fn_runfunction

+ 2 - 2
functions/fn_getopt

@@ -2,7 +2,7 @@
 # LGSM fn_getopt function
 # LGSM fn_getopt function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 # Website: http://gameservermanagers.com
-# Version: 190515
+# Version: 240515
 
 
 # Description: getopt arguments.
 # Description: getopt arguments.
 
 
@@ -74,7 +74,7 @@ case "$getopt" in
 	auto-install)
 	auto-install)
 		fn_autoinstall;;
 		fn_autoinstall;;
 	*)
 	*)
-		echo "Usage: $0 {start|stop|restart|update|update-funtions|monitor|email-test|details|backup}"
+		echo "Usage: $0 {start|stop|restart|update|update-funtions|monitor|email-test|details|backup|install|auto-install}"
 		exit 1;;
 		exit 1;;
 esac
 esac
 exit
 exit

+ 13 - 1
functions/fn_install_config

@@ -2,7 +2,7 @@
 # LGSM fn_server function
 # LGSM fn_server function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 # Website: http://gameservermanagers.com
-# Version: 120515
+# Version: 240515
 
 
 fn_arma3config(){
 fn_arma3config(){
 mkdir -pv "${servercfgdir}"
 mkdir -pv "${servercfgdir}"
@@ -87,6 +87,16 @@ sed -i "s/\"rconpassword\"/\"${rconpass}\"/g" "${servercfgfullpath}"
 echo ""
 echo ""
 }
 }
 
 
+fn_ts3config(){
+echo  "Creating blank ${servercfg}"
+sleep 1
+echo  "${servercfg} can remain blank by default."
+sleep 1
+echo  "${servercfg} is located in ${servercfgfullpath}."
+sleep 1
+touch "${servercfgfullpath}"
+}
+
 fn_ut99config(){
 fn_ut99config(){
 echo "${defaultcfg} > ${servercfgfullpath}"
 echo "${defaultcfg} > ${servercfgfullpath}"
 tr -d '\r' < "${defaultcfg}" > "${servercfgfullpath}"
 tr -d '\r' < "${defaultcfg}" > "${servercfgfullpath}"
@@ -245,6 +255,8 @@ elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then
 	wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/SeriousSam3BFE/cfg/lgsm-default.ini 2>&1 | grep -F HTTP | cut -c45- | uniq
 	wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/SeriousSam3BFE/cfg/lgsm-default.ini 2>&1 | grep -F HTTP | cut -c45- | uniq
 	sleep 1
 	sleep 1
 	fn_serious3config
 	fn_serious3config
+elif [ "${gamename}" == "Teamspeak 3" ]; then
+	fn_ts3config
 elif [ "${gamename}" == "Team Fortress 2" ]; then
 elif [ "${gamename}" == "Team Fortress 2" ]; then
 	echo -e "downloading lgsm-default.cfg...\c"
 	echo -e "downloading lgsm-default.cfg...\c"
 	wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/TeamFortress2/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq
 	wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/TeamFortress2/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq

+ 15 - 27
functions/fn_install_logs

@@ -2,58 +2,46 @@
 # LGSM fn_install_logs function
 # LGSM fn_install_logs function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 # Website: http://gameservermanagers.com
-# Version: 160415
+# Version: 240415
 
 
-echo ""
-echo "Creating log directorys"
-echo "================================="
+if [ "${checklogs}" != "1" ]; then
+	echo ""
+	echo "Creating log directorys"
+	echo "================================="
+fi
 sleep 1
 sleep 1
 # Create dir's for the script and console logs
 # Create dir's for the script and console logs
 mkdir -v "${rootdir}/log"
 mkdir -v "${rootdir}/log"
 mkdir -v "${scriptlogdir}"
 mkdir -v "${scriptlogdir}"
 touch "${scriptlog}"
 touch "${scriptlog}"
-mkdir -v "${consolelogdir}"
-touch "${consolelog}"
-
-# If a server is Project Zomboid create a symbolic link to the game server logs
-if [ "${engine}" == "projectzomboid" ]; then
-	ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
+if [ -n "${consolelogdir}" ]; then
+	mkdir -v "${consolelogdir}"
+	touch "${consolelog}"
 fi
 fi
 
 
-# If a server is source or goldsource create a symbolic link to the game server logs
-if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
+# If a server is source or goldsource, Teamspeak 3, Starbound, Project Zomhoid create a symbolic link to the game server logs.
+if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${gamename}" == "Teamspeak 3" ]||[ "${engine}" == "starbound" ]||[ "${engine}" == "projectzomboid" ]; then
 	if [ ! -h "${rootdir}/log/server" ]; then
 	if [ ! -h "${rootdir}/log/server" ]; then
 		ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
 		ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
-	else
-		echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
 	fi
 	fi
 fi
 fi
 
 
-# If a server is unreal2 or unity3d create a dir
+# If a server is unreal2 or unity3d create a dir.
 if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]; then
 if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]; then
 	mkdir -pv "${gamelogdir}"
 	mkdir -pv "${gamelogdir}"
 fi
 fi
+
+# If a server is 7 Days to Die.
 if [ "${gamename}" == "7 Days To Die" ]; then
 if [ "${gamename}" == "7 Days To Die" ]; then
 	if [ ! -h "${gamelogdir}/output_log.txt" ]; then
 	if [ ! -h "${gamelogdir}/output_log.txt" ]; then
 		ln -nfsv "${filesdir}/7DaysToDie_Data/output_log.txt" "${gamelogdir}/output_log.txt"
 		ln -nfsv "${filesdir}/7DaysToDie_Data/output_log.txt" "${gamelogdir}/output_log.txt"
 	fi
 	fi
 fi
 fi
 
 
-# If a server is starbound create a symbolic link to the game server logs
-if [ "${engine}" == "starbound" ]; then
-	if [ ! -h "${rootdir}/log/server" ]; then
-		ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
-	else
-		echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
-	fi
-fi
-
-# If server uses SteamCMD create a symbolic link to the Steam logs
+# If server uses SteamCMD create a symbolic link to the Steam logs.
 if [ -d "${rootdir}/Steam/logs" ]; then
 if [ -d "${rootdir}/Steam/logs" ]; then
 	if [ ! -h "${rootdir}/log/steamcmd" ]; then
 	if [ ! -h "${rootdir}/log/steamcmd" ]; then
 		ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd"
 		ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd"
-	else
-		echo "Symbolic link ${rootdir}/Steam/logs => ${rootdir}/log/steamcmd already exists!"
 	fi
 	fi
 fi
 fi
 sleep 1
 sleep 1

+ 29 - 20
functions/fn_install_ts3

@@ -2,11 +2,18 @@
 # LGSM fn_install_ts3 function
 # LGSM fn_install_ts3 function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 # Website: http://gameservermanagers.com
-# Version: 120515
+# Version: 240515
 
 
-fn_details_config
+fn_details_distro
 # Gets the teamspeak server architecture
 # Gets the teamspeak server architecture
-ts3arch=${arch}
+if [ "${arch}" == "x86_64" ]; then
+	ts3arch="amd64"
+elif [ "${arch}" == "i386" ]; then
+	ts3arch="x86"
+else
+	fn_printfailure "${arch} is an unsupported architecture"
+	exit
+fi
 
 
 # Grabs all version numbers not in correct order
 # Grabs all version numbers not in correct order
 wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
 wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
@@ -22,6 +29,7 @@ while read ts3_version_number; do
 	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz"
 	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz"
 	if [[ $? == 0 ]]; then
 	if [[ $? == 0 ]]; then
 		availablebuild="${ts3_version_number}"
 		availablebuild="${ts3_version_number}"
+		echo "Latest Build: ${availablebuild}"
 		# Break while-loop, if the latest release could be found
 		# Break while-loop, if the latest release could be found
 		echo "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-66server_linux-${ts3arch}-${ts3_version_number}.tar.g"
 		echo "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-66server_linux-${ts3arch}-${ts3_version_number}.tar.g"
 		break
 		break
@@ -34,51 +42,52 @@ rm -f .ts3_version_numbers.tmp
 # Checks availablebuild info is available
 # Checks availablebuild info is available
 if [ -z "${availablebuild}" ]; then
 if [ -z "${availablebuild}" ]; then
 	fn_printfail "Checking for update: teamspeak.com"
 	fn_printfail "Checking for update: teamspeak.com"
-	fn_scriptlog "Checking for update: teamspeak.com"
 	sleep 1
 	sleep 1
 	fn_printfail "Checking for update: teamspeak.com: Not returning version info"
 	fn_printfail "Checking for update: teamspeak.com: Not returning version info"
-	fn_scriptlog "Failure! Checking for update: teamspeak.com: Not returning version info"
 	sleep 2
 	sleep 2
 	exit
 	exit
 fi
 fi
 
 
 cd "${rootdir}"
 cd "${rootdir}"
+mkdir "${filesdir}"
 echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
 echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
-fn_scriptlog "Downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz"
 wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz 2>&1 | grep -F HTTP | cut -c45-| uniq
 wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz 2>&1 | grep -F HTTP | cut -c45-| uniq
 sleep 1
 sleep 1
 echo -e "extracting teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
 echo -e "extracting teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
-fn_scriptlog "Extracting teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz"
-tar -xf "teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
+tar -xf "teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz" 2> ".${servicename}-tar-error.tmp"
 local status=$?
 local status=$?
 if [ ${status} -eq 0 ]; then
 if [ ${status} -eq 0 ]; then
 	echo "OK"
 	echo "OK"
 else
 else
 	echo "FAIL - Exit status ${status}"
 	echo "FAIL - Exit status ${status}"
-	fn_scriptlog "Failed to extract - Exit status ${status}"
 	sleep 1
 	sleep 1
-	cat "${scriptlogdir}/.${servicename}-tar-error.tmp"
-	cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}"
-	rm "${scriptlogdir}/.${servicename}-tar-error.tmp"
-	fn_scriptlog "Failure! Unable to update"
+	cat ".${servicename}-tar-error.tmp"
+	rm ".${servicename}-tar-error.tmp"
 	exit
 	exit
 fi
 fi
 echo -e "copying to ${filesdir}...\c"
 echo -e "copying to ${filesdir}...\c"
-fn_scriptlog "Copying to ${filesdir}"
-cp -R "${rootdir}/teamspeak3-server_linux-${ts3arch}/*" "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
+cp -R "${rootdir}/teamspeak3-server_linux-${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp"
 local status=$?
 local status=$?
 if [ ${status} -eq 0 ]; then
 if [ ${status} -eq 0 ]; then
 	echo "OK"
 	echo "OK"
 else
 else
 	echo "FAIL - Exit status ${status}"
 	echo "FAIL - Exit status ${status}"
-	fn_scriptlog "Failed to copy - Exit status ${status}"
 	sleep 1
 	sleep 1
-	cat "${scriptlogdir}/.${servicename}-cp-error.tmp"
-	cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}"
-	rm "${scriptlogdir}/.${servicename}-cp-error.tmp"
-	fn_scriptlog "Failure! Unable to update"
+	cat ".${servicename}-cp-error.tmp"
+	rm ".${servicename}-cp-error.tmp"
 	exit
 	exit
 fi
 fi
 rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
 rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
 rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
 rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
 
 
+## Get privilege key
+echo ""
+echo "Getting privilege key"
+echo "================================="
+sleep 1
+echo "IMPORANT! Save these details for later."
+sleep 1
+cd "${executabledir}"
+./ts3server_startscript.sh start
+sleep 5
+./ts3server_startscript.sh stop

+ 11 - 7
functions/fn_start

@@ -2,7 +2,7 @@
 # LGSM fn_start function
 # LGSM fn_start function
 # Author: Daniel Gibbs
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 # Website: http://gameservermanagers.com
-# Version: 090515
+# Version: 240515
 
 
 # Description: Starts the server.
 # Description: Starts the server.
 
 
@@ -23,13 +23,17 @@ fi
 if [ ! -e "${servercfgfullpath}" ]; then
 if [ ! -e "${servercfgfullpath}" ]; then
 	fn_printwarn "${servercfgfullpath} is missing"
 	fn_printwarn "${servercfgfullpath} is missing"
 	fn_scriptlog "${servercfgfullpath} is missing"
 	fn_scriptlog "${servercfgfullpath} is missing"
-	sleep 1
-	fn_printinfo "Creating blank ${servercfgfullpath}"
-	fn_scriptlog "Creating blank ${servercfgfullpath}"
-	sleep 1
-	fn_printinfo "${servercfgfullpath} can remain blank by default."
+	sleep 2
+	echo -en "\n"
+	echo  "	* Creating blank ${servercfg}"
+	fn_scriptlog "Creating blank ${servercfg}"
+	sleep 2
+	echo  "	* ${servercfg} can remain blank by default."
 	fn_scriptlog "${servercfgfullpath} can remain blank by default."
 	fn_scriptlog "${servercfgfullpath} can remain blank by default."
-	sleep 1
+	sleep 2
+	echo  "	* ${servercfg} is located in ${servercfgfullpath}."
+	fn_scriptlog "${servercfg} is located in ${servercfgfullpath}."
+	sleep 5
 	touch "${servercfgfullpath}"
 	touch "${servercfgfullpath}"
 fi
 fi
 fn_logs
 fn_logs