Quellcode durchsuchen

Merge pull request #578 from PhilPhonic/ts3_mariadb

support for MariaDB/MySQL
Daniel Gibbs vor 10 Jahren
Ursprung
Commit
e066dbe7c6

+ 20 - 0
TeamSpeak3/cfg/lgsm-default.ini

@@ -0,0 +1,20 @@
+machine_id=
+default_voice_port=9987
+voice_ip=0.0.0.0
+licensepath=
+filetransfer_port=30033
+filetransfer_ip=0.0.0.0
+query_port=10011
+query_ip=0.0.0.0
+query_ip_whitelist=query_ip_whitelist.txt
+query_ip_blacklist=query_ip_blacklist.txt
+dbplugin=ts3db_sqlite3
+dbpluginparameter=
+dbsqlpath=sql/
+dbsqlcreatepath=create_sqlite/
+dbconnections=10
+logpath=logs
+logquerycommands=0
+dbclientkeepdays=30
+logappend=0
+query_skipbruteforcecheck=0

+ 2 - 1
TeamSpeak3/ts3server

@@ -9,7 +9,7 @@ if [ -f ".dev-debug" ]; then
 	set -x
 fi
 
-version="201215"
+version="251215"
 
 #### Variables ####
 
@@ -37,6 +37,7 @@ executable="./ts3server_startscript.sh"
 servercfg="${servicename}.ini"
 servercfgdir="${filesdir}"
 servercfgfullpath="${servercfgdir}/${servercfg}"
+servercfgdefault="${servercfgdir}/lgsm-default.ini"
 backupdir="${rootdir}/backups"
 
 # Logging

+ 6 - 1
functions/fn_functions

@@ -2,7 +2,7 @@
 # LGSM fn_functions function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="201215"
+lgsm_version="251215"
 
 # 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.
@@ -284,6 +284,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
+fn_install_ts3db(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
 fn_install_ut2k4(){
 functionfile="${FUNCNAME}"
 fn_runfunction

+ 3 - 1
functions/fn_install

@@ -2,7 +2,7 @@
 # LGSM fn_install function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="201215"
+lgsm_version="251215"
 
 fn_check_root
 fn_install_header
@@ -32,6 +32,8 @@ fn_install_config
 if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
 	fn_install_gslt
 	fn_csgofix
+elif [ "${gamename}" == "Teamspeak 3" ]; then
+	fn_install_ts3db
 elif [ "${gamename}" == "Team Fortress 2" ]; then
 	fn_install_gslt
 elif [ "${gamename}" == "Killing Floor" ]; then

+ 5 - 12
functions/fn_install_config

@@ -2,7 +2,7 @@
 # LGSM fn_install_config function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="201215"
+lgsm_version="251215"
 
 fn_defaultconfig(){
 	echo "creating ${servercfg} config file."
@@ -102,16 +102,6 @@ fn_userinputconfig
 echo ""
 }
 
-fn_ts3config(){
-echo "creating blank ${servercfg} config file."
-sleep 1
-echo  "${servercfg} can remain blank by default."
-sleep 1
-echo  "${servercfg} is located in ${servercfgfullpath}."
-sleep 1
-touch "${servercfgfullpath}"
-}
-
 fn_ut99config(){
 echo "${defaultcfg} > ${servercfgfullpath}"
 tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}"
@@ -286,7 +276,10 @@ elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then
 	sleep 1
 	fn_serious3config
 elif [ "${gamename}" == "Teamspeak 3" ]; then
-	fn_ts3config
+	echo -e "downloading lgsm-default.ini...\c"
+	wget -N /dev/null ${githuburl}/TeamSpeak3/cfg/lgsm-default.ini 2>&1 | grep -F HTTP | cut -c45- | uniq
+	sleep 1
+	fn_defaultconfig
 elif [ "${gamename}" == "Team Fortress 2" ]; then
 	echo -e "downloading lgsm-default.cfg...\c"
 	wget -N /dev/null ${githuburl}/TeamFortress2/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq

+ 1 - 14
functions/fn_install_ts3

@@ -2,7 +2,7 @@
 # LGSM fn_install_ts3 function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="061115"
+lgsm_version="251215"
 
 fn_details_distro
 # Gets the teamspeak server architecture
@@ -49,7 +49,6 @@ if [ -z "${availablebuild}" ]; then
 fi
 
 cd "${rootdir}"
-mkdir "${filesdir}"
 echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
 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
@@ -79,15 +78,3 @@ else
 fi
 rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
 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

+ 63 - 0
functions/fn_install_ts3db

@@ -0,0 +1,63 @@
+#!/bin/bash
+# LGSM fn_install_ts3_mariadb function
+# Author: Daniel Gibbs
+# Website: http://gameservermanagers.com
+lgsm_version="251215"
+
+fn_install_ts3db_mariadb(){
+	echo ""
+	echo "checking if libmariadb2 is installed"
+	echo "================================="
+	ldd ${filesdir}/libts3db_mariadb.so | grep "libmariadb.so.2 => not found"
+	if [ $? -eq 0 ]; then
+		echo "libmariadb2 not installed. Please install it first."
+		echo "exiting..."
+		exit
+	else
+		echo "libmariadb2 installed."
+	fi
+	echo ""
+	echo "Configuring ${gamename} Server for MariaDB/MySQL"
+	echo "================================="
+	sleep 1
+	read -p "Enter MariaDB hostname: " mariahostname
+	read -p "Enter MariaDB port: " mariaport
+	read -p "Enter MariaDB username: " mariausername
+	read -p "Enter MariaDB password: " mariapassword
+	read -p "Enter MariaDB database name: " mariadbname
+	echo "updating config."
+	echo "[config]" >> ${servercfgdir}/ts3db_mariadb.ini
+	echo "host='${mariahostname}'" >> ${servercfgdir}/ts3db_mariadb.ini
+	echo "port='${mariaport}'" >> ${servercfgdir}/ts3db_mariadb.ini
+	echo "username='${mariausername}'" >> ${servercfgdir}/ts3db_mariadb.ini
+	echo "password='${mariapassword}'" >> ${servercfgdir}/ts3db_mariadb.ini
+	echo "database='${mariadbname}'" >> ${servercfgdir}/ts3db_mariadb.ini
+	echo "socket=" >> ${servercfgdir}/ts3db_mariadb.ini	
+	sed -i "s/dbplugin=ts3db_sqlite3/dbplugin=ts3db_mariadb/g" "${servercfgfullpath}"
+	sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" "${servercfgfullpath}"
+	sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" "${servercfgfullpath}"
+	echo "================================="
+	sleep 1
+}
+
+echo ""
+while true; do
+	read -e -i "n" -p "Do you want to use MariaDB/MySQL instead of sqlite (Database Server including user and database already has to be set up!)? [y/N]" yn
+	case $yn in
+	[Yy]* ) fn_install_ts3db_mariadb && break;;
+	[Nn]* ) break;;
+	* ) echo "Please answer yes or no.";;
+	esac
+done
+
+## 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 inifile=ts3-server.ini
+sleep 5
+./ts3server_startscript.sh stop