command_ts3_server_pass.sh 1.5 KB

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