command_ts3_server_pass.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # LinuxGSM command_ts3_server_pass.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor : UltimateByte
  5. # Website: https://linuxgsm.com
  6. # Description: Changes TS3 serveradmin password.
  7. fn_commandname(){
  8. commandname="CHANGE-PASSWORD"
  9. commandaction="Changing password"
  10. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  11. }
  12. fn_commandname
  13. fn_serveradmin_password_prompt(){
  14. fn_print_header
  15. fn_print_information_nl "You are about to change the ${gamename} ServerAdmin password."
  16. fn_print_warning_nl "${gamename} will restart during this process."
  17. echo -e ""
  18. if ! fn_prompt_yn "Continue?" Y; then
  19. echo Exiting; exit
  20. fi
  21. fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
  22. read -rp "Enter new password: " newpassword
  23. fn_print_info_nl "Changing password"
  24. fn_script_log_info "Changing password"
  25. }
  26. fn_serveradmin_password_set(){
  27. # Start server in "new password mode".
  28. ts3serverpass="1"
  29. exitbypass="1"
  30. command_start.sh
  31. fn_commandname
  32. fn_print_ok_nl "New password applied"
  33. fn_script_log_pass "New ServerAdmin password applied"
  34. }
  35. # Running functions.
  36. check.sh
  37. fn_serveradmin_password_prompt
  38. if [ "${status}" != "0" ]; then
  39. # Stop any running server.
  40. exitbypass="1"
  41. command_stop.sh
  42. fn_commandname
  43. fn_serveradmin_password_set
  44. parms="serveradmin_password=\"${newpassword}\" inifile=\"${servercfgfullpath}\" > /dev/null 2>&1"
  45. ts3serverpass="0"
  46. command_restart.sh
  47. fn_commandname
  48. else
  49. fn_serveradmin_password_set
  50. command_stop.sh
  51. fn_commandname
  52. fi
  53. core_exit.sh