4
0

fix_samp.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # LinuxGSM fix_sfc.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Resolves issue that the default rcon password is not changed.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. if [ -f "${servercfgfullpath}" ]; then
  9. # check if default password is set "changeme"
  10. currentpass=$(grep -E "^rcon_password" "${servercfgfullpath}" | sed 's/^rcon_password //')
  11. defaultpass="changeme"
  12. # check if default password is set
  13. if [ "${currentpass}" == "${defaultpass}" ]; then
  14. fixname="change default rcon password"
  15. fn_fix_msg_start
  16. fn_script_log_info "Changing rcon/admin password."
  17. randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
  18. rconpass="admin${randomstring}"
  19. sed -i "s/rcon_password changeme/rcon_password ${rconpass}/g" "${servercfgfullpath}"
  20. fn_fix_msg_end
  21. fi
  22. # check if the hostname is the default name
  23. currenthostname=$(grep -E "^hostname" "${servercfgfullpath}" | sed 's/^hostname //')
  24. defaulthostname="SA-MP 0.3 Server"
  25. if [ "${currenthostname}" == "${defaulthostname}" ]; then
  26. fixname="change default hostname"
  27. fn_fix_msg_start
  28. fn_script_log_info "Changing default hostname to LinuxGSM"
  29. sed -i "s/hostname ${defaulthostname}/hostname LinuxGSM/g" "${servercfgfullpath}"
  30. fn_fix_msg_end
  31. fi
  32. fi