command_ts3_server_password.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # LGSM command_serveradmin_password.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor : UltimateByte
  5. # Website: http://gameservermanagers.com
  6. lgsm_version="050116"
  7. # Description: Changes TS3 serveradmin password
  8. local modulename="TS3 Server Password"
  9. function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  10. fn_serveradmin_password_prompt(){
  11. fn_printwarn "Initiating TS3 serveradmin password change"
  12. sleep 2
  13. echo -en "\n"
  14. echo "Changing telnet ServerQuery password"
  15. while true; do
  16. read -p "Continue ? [y/n]" yn
  17. case $yn in
  18. [Yy]* ) break;;
  19. [Nn]* ) exit;;
  20. * ) echo "Please answer yes or no.";;
  21. esac
  22. done
  23. fn_scriptlog "Initiating serveradmin password change"
  24. echo -n "Enter the new password : " ; read newpassword
  25. fn_scriptlog "New serveradmin password chosen"
  26. }
  27. fn_serveradmin_password_set(){
  28. fn_printdots "Applying new password"
  29. sleep 1
  30. fn_scriptlog "Starting routine with new password start option"
  31. ./ts3server_startscript.sh start serveradmin_password="${newpassword}" > /dev/null 2>&1
  32. info_ts3status.sh
  33. if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}" = "No server running (ts3server.pid is missing)" ]; then
  34. fn_printfailnl "Unable to start ${servername}"
  35. fn_scriptlog "Unable to start ${servername}"
  36. echo -e " Check log files: ${rootdir}/log"
  37. exit 1
  38. else
  39. fn_printok "${servername} has set a new serveradmin password"
  40. echo -en "\n"
  41. fn_scriptlog "Started ${servername} with new password"
  42. fi
  43. sleep 1
  44. }
  45. # Running functions
  46. check.sh
  47. fn_serveradmin_password_prompt
  48. info_ts3status.sh
  49. if [ "${ts3status}" == "Server is running" ]; then
  50. command_stop.sh
  51. fn_serveradmin_password_set
  52. echo "Server will now restart normally"
  53. sleep 1
  54. command_stop.sh
  55. command_start.sh
  56. else
  57. fn_serveradmin_password_set
  58. echo -en "\n"
  59. command_stop.sh
  60. fi