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="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 -e "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 -e ""
  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. # Start server in "new password mode".
  26. ts3serverpass="1"
  27. exitbypass="1"
  28. command_start.sh
  29. fn_print_ok_nl "Password applied"
  30. fn_script_log_pass "New ServerAdmin password applied"
  31. }
  32. # Running functions.
  33. check.sh
  34. fn_serveradmin_password_prompt
  35. check_status.sh
  36. if [ "${status}" != "0" ]; then
  37. # Stop any running server.
  38. exitbypass="1"
  39. command_stop.sh
  40. fn_serveradmin_password_set
  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