command_ts3_server_pass.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. local commandname="PASSWORD-CHANGE"
  8. local commandaction="Password Change"
  9. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  10. fn_serveradmin_password_prompt(){
  11. fn_print_header
  12. fn_print_information_nl "You are about to change the ${gamename} ServerAdmin password."
  13. fn_print_warning_nl "${gamename} will restart during this process."
  14. echo -e ""
  15. if ! fn_prompt_yn "Continue?" Y; then
  16. echo Exiting; exit
  17. fi
  18. fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
  19. read -rp "Enter new password: " newpassword
  20. }
  21. fn_serveradmin_password_set(){
  22. fn_print_info_nl "Starting "
  23. fn_script_log_info "Starting server with new password"
  24. # Start server in "new password mode".
  25. ts3serverpass="1"
  26. exitbypass="1"
  27. command_start.sh
  28. fn_print_ok_nl "Password applied"
  29. fn_script_log_pass "New ServerAdmin password applied"
  30. }
  31. # Running functions.
  32. check.sh
  33. fn_serveradmin_password_prompt
  34. check_status.sh
  35. if [ "${status}" != "0" ]; then
  36. # Stop any running server.
  37. exitbypass="1"
  38. command_stop.sh
  39. fn_serveradmin_password_set
  40. parms="serveradmin_password="${newpassword}" inifile="${servercfgfullpath}" > /dev/null 2>&1"
  41. ts3serverpass="0"
  42. fn_print_info_nl "Restarting server normally"
  43. fn_script_log_info "Restarting server normally"
  44. command_restart.sh
  45. else
  46. fn_serveradmin_password_set
  47. command_stop.sh
  48. fi
  49. core_exit.sh