Преглед изворни кода

Merge pull request #614 from dgibbs64/ts3-password

Teamspeak 3 password change is now possible
Daniel Gibbs пре 10 година
родитељ
комит
f66f4c8a56

+ 6 - 2
functions/command_start.sh

@@ -2,7 +2,7 @@
 # LGSM command_start.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="070116"
 
 # Description: Starts the server.
 
@@ -55,7 +55,11 @@ mv "${scriptlog}" "${scriptlogdate}"
 # Create lock file
 date > "${rootdir}/${lockselfname}"
 cd "${executabledir}"
-./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1
+if [ "${ts3serverpass}" == "1" ];then
+	./ts3server_startscript.sh start serveradmin_password="${newpassword}" 
+else
+	./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1
+fi
 sleep 1
 info_ts3status.sh
 if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then

+ 62 - 0
functions/command_ts3_server_pass.sh

@@ -0,0 +1,62 @@
+#!/bin/bash
+# LGSM command_serveradmin_password.sh function
+# Author: Daniel Gibbs
+# Contributor : UltimateByte
+# Website: http://gameservermanagers.com
+lgsm_version="080116"
+
+# Description: Changes TS3 serveradmin password
+
+local modulename="Change password"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+
+fn_serveradmin_password_prompt(){
+echo ""
+echo "${gamename} ServerAdmin Password Change"
+echo "============================"
+echo ""
+echo "Press \"CTRL+b d\" to exit console."
+fn_printinfomationnl "You are about to change the ${gamename} ServerAdmin password."
+fn_printwarningnl "${gamename} will restart during this process."
+echo ""
+while true; do
+	read -e -i "y" -p "Continue? [y/N]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) echo Exiting; return;;
+	* ) echo "Please answer yes or no.";;
+esac
+done
+fn_scriptlog "Initiating ${gamename} ServerAdmin password change"
+read -p "Enter new password : " newpassword
+}
+
+
+fn_serveradmin_password_set(){
+fn_printinfonl "Applying new password"
+fn_scriptlog "Applying new password"
+sleep 1
+# Stop any running server
+command_stop.sh
+# Start server in "new password mode"
+ts3serverpass="1"
+fn_printinfonl "Starting server with new password"
+command_start.sh
+# Stop server in "new password mode"
+command_stop.sh
+fn_printoknl "Password applied"
+fn_scriptlog "New ServerAdmin password applied"
+sleep 1
+}
+
+# Running functions
+check.sh
+fn_serveradmin_password_prompt
+info_ts3status.sh
+if [ "${ts3status}" == "Server is running" ]; then
+	fn_serveradmin_password_set
+	command_start.sh
+else
+	fn_serveradmin_password_set
+fi

+ 5 - 0
functions/core_functions.sh

@@ -85,6 +85,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
+command_ts3_server_pass.sh(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
 fn_restart(){
 local modulename="Restarting"
 info_config.sh

+ 4 - 1
functions/core_getopt.sh

@@ -2,7 +2,7 @@
 # LGSM core_getopt.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="070116"
 
 # Description: getopt arguments.
 
@@ -90,6 +90,8 @@ case "$getopt" in
 		command_details.sh;;
 	b|backup)
 		command_backup.sh;;
+	pw|change-password)
+		command_ts3_server_pass.sh;;
 	dev|dev-debug)
 		command_dev_debug.sh;;		
 	i|install)
@@ -113,6 +115,7 @@ case "$getopt" in
 		echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
 		echo -e "\e[34memail-test\t\e[0mSends test monitor email."
 		echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
+		echo -e "\e[34mchange-password\t\e[0mChanges TS3 serveradmin password."
 		echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
 		echo -e "\e[34minstall\t\e[0mInstall the server."
 		echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."