command_ts3_server_pass.sh 1.6 KB

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