command_ts3_server_pass.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 modulename="TS3 Change Password"
  8. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  9. fn_serveradmin_password_prompt(){
  10. echo ""
  11. echo "${gamename} ServerAdmin Password Change"
  12. echo "================================="
  13. echo ""
  14. echo "Press \"CTRL+b d\" to exit console."
  15. fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password."
  16. fn_print_warning_nl "${gamename} will restart during this process."
  17. echo ""
  18. while true; do
  19. read -e -i "y" -p "Continue? [Y/n]" yn
  20. case $yn in
  21. [Yy]* ) break;;
  22. [Nn]* ) echo Exiting; exit;;
  23. * ) echo "Please answer yes or no.";;
  24. esac
  25. done
  26. fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
  27. read -p "Enter new password : " newpassword
  28. }
  29. fn_serveradmin_password_set(){
  30. fn_print_info_nl "Applying new password"
  31. fn_script_log_info "Applying new password"
  32. sleep 1
  33. # Stop any running server
  34. command_stop.sh
  35. # Start server in "new password mode"
  36. ts3serverpass="1"
  37. fn_print_info_nl "Starting server with new password"
  38. command_start.sh
  39. # Stop server in "new password mode"
  40. command_stop.sh
  41. ts3serverpass="0"
  42. fn_print_ok_nl "Password applied"
  43. fn_script_log_pass "New ServerAdmin password applied"
  44. sleep 1
  45. }
  46. # Running functions
  47. check.sh
  48. fn_serveradmin_password_prompt
  49. check_status.sh
  50. if [ "${status}" != "0" ]; then
  51. fn_serveradmin_password_set
  52. command_start.sh
  53. else
  54. fn_serveradmin_password_set
  55. fi
  56. core_exit.sh