command_ts3_server_pass.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # LGSM command_serveradmin_password.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor : UltimateByte
  5. # Website: https://gameservermanagers.com
  6. lgsm_version="210516"
  7. # Description: Changes TS3 serveradmin password
  8. local modulename="Change password"
  9. 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_infomation_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_scriptlog "Initiating ${gamename} ServerAdmin password change"
  28. read -p "Enter new password : " newpassword
  29. }
  30. fn_serveradmin_password_set(){
  31. fn_print_info_nl "Applying new password"
  32. fn_scriptlog "Applying new password"
  33. sleep 1
  34. # Stop any running server
  35. command_stop.sh
  36. # Start server in "new password mode"
  37. ts3serverpass="1"
  38. fn_print_info_nl "Starting server with new password"
  39. command_start.sh
  40. # Stop server in "new password mode"
  41. command_stop.sh
  42. ts3serverpass="0"
  43. fn_print_ok_nl "Password applied"
  44. fn_scriptlog "New ServerAdmin password applied"
  45. sleep 1
  46. }
  47. # Running functions
  48. check.sh
  49. fn_serveradmin_password_prompt
  50. check_status.sh
  51. if [ "${status}" != "0" ]; then
  52. fn_serveradmin_password_set
  53. command_start.sh
  54. else
  55. fn_serveradmin_password_set
  56. fi