command_ts3_server_pass.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # LinuxGSM command_ts3_server_pass.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Changes TS3 serveradmin password.
  7. commandname="CHANGE-PASSWORD"
  8. commandaction="Changing password"
  9. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  10. fn_firstcommand_set
  11. fn_serveradmin_password_prompt() {
  12. fn_print_header
  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. exitcode=0
  18. core_exit.sh
  19. fi
  20. fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
  21. read -rp "Enter new password: " newpassword
  22. fn_print_info_nl "Changing password"
  23. fn_script_log_info "Changing password"
  24. }
  25. fn_serveradmin_password_set() {
  26. # Start server in "new password mode".
  27. ts3serverpass="1"
  28. exitbypass=1
  29. command_start.sh
  30. fn_firstcommand_reset
  31. fn_print_ok_nl "New password applied"
  32. fn_script_log_pass "New ServerAdmin password applied"
  33. }
  34. # Running functions.
  35. check.sh
  36. fn_serveradmin_password_prompt
  37. if [ "${status}" != "0" ]; then
  38. # Stop any running server.
  39. exitbypass=1
  40. command_stop.sh
  41. fn_firstcommand_reset
  42. fn_serveradmin_password_set
  43. parms="serveradmin_password=\"${newpassword}\" inifile=\"${servercfgfullpath}\" > /dev/null 2>&1"
  44. ts3serverpass="0"
  45. command_restart.sh
  46. fn_firstcommand_reset
  47. else
  48. fn_serveradmin_password_set
  49. command_stop.sh
  50. fn_firstcommand_reset
  51. fi
  52. core_exit.sh