fix_samp.sh 1.3 KB

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