command_ts3_server_pass.sh 1.5 KB

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