command_ts3_server_pass.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # LGSM 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. while true; do
  20. read -e -i "y" -p "Continue? [Y/n]" yn
  21. case $yn in
  22. [Yy]* ) break;;
  23. [Nn]* ) echo Exiting; exit;;
  24. * ) echo "Please answer yes or no.";;
  25. esac
  26. done
  27. fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
  28. read -p "Enter new password : " newpassword
  29. }
  30. fn_serveradmin_password_set(){
  31. fn_print_info_nl "Starting server with new password..."
  32. fn_script_log_info "Starting server with new password"
  33. sleep 1
  34. # Start server in "new password mode"
  35. ts3serverpass="1"
  36. exitbypass="1"
  37. command_start.sh
  38. fn_print_ok_nl "Password applied"
  39. fn_script_log_pass "New ServerAdmin password applied"
  40. sleep 1
  41. }
  42. # Running functions
  43. check.sh
  44. fn_serveradmin_password_prompt
  45. check_status.sh
  46. if [ "${status}" != "0" ]; then
  47. # Stop any running server
  48. exitbypass="1"
  49. command_stop.sh
  50. fn_serveradmin_password_set
  51. ts3serverpass="0"
  52. fn_print_info_nl "Restarting server normally"
  53. fn_script_log_info "Restarting server normally"
  54. command_restart.sh
  55. else
  56. fn_serveradmin_password_set
  57. command_stop.sh
  58. fi
  59. core_exit.sh