check_config.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # LinuxGSM check_config.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Checks if the server config is missing and warns the user if needed.
  7. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. if [ -n "${servercfgfullpath}" ] && [ ! -f "${servercfgfullpath}" ]; then
  9. fn_print_warn_nl "Configuration file missing!"
  10. echo -e "${servercfgfullpath}"
  11. fn_script_log_warn "Configuration file missing!"
  12. fn_script_log_warn "${servercfgfullpath}"
  13. install_config.sh
  14. fi
  15. if [ "${shortname}" == "ti" ] && [[ "${startparameters}" != *"DedicatedServerClientId"* ]] && [ ! -f "${servercfgdir}/Engine.ini" ]; then
  16. fn_print_warn_nl "Configuration file missing!"
  17. echo -e "${servercfgdir}/Engine.ini"
  18. fn_script_log_warn "Configuration file missing!"
  19. fn_script_log_warn "${servercfgdir}/Engine.ini"
  20. install_config.sh
  21. fi
  22. if [ "${shortname}" == "rust" ] && [ -v rconpassword ] && [ -z "${rconpassword}" ]; then
  23. fn_print_fail_nl "RCON password is not set"
  24. fn_script_log_warn "RCON password is not set"
  25. elif [ -v rconpassword ] && [ "${rconpassword}" == "CHANGE_ME" ]; then
  26. fn_print_warn_nl "Default RCON password detected"
  27. fn_script_log_warn "Default RCON password detected"
  28. elif [ -v httppassword ] && [ "${httppassword}" == "CHANGE_ME" ]; then
  29. fn_print_warn_nl "Default Web password detected"
  30. fn_script_log_warn "Default Web password detected"
  31. elif [ -v adminpassword ] && [ "${adminpassword}" == "CHANGE_ME" ]; then
  32. fn_print_warn_nl "Default Admin password detected"
  33. fn_script_log_warn "Default Admin password detected"
  34. fi
  35. if [ "${shortname}" == "vh" ] && [ -z "${serverpassword}" ]; then
  36. fn_print_fail_nl "serverpassword is not set"
  37. fn_script_log_fail "serverpassword is not set"
  38. elif [ "${shortname}" == "vh" ] && [ "${#serverpassword}" -le "4" ]; then
  39. fn_print_fail_nl "serverpassword is to short (min 5 chars)"
  40. fn_script_log_fail "serverpassword is to short (min 5 chars)"
  41. fi
  42. if [ "${shortname}" == "fivem" ] && [ -z "${licensekey}" ] && ! grep -qE "^[[:space:]]*(set[[:space:]]+)?sv_licenseKey[[:space:]]+\"?[^\" ]" "${servercfgfullpath}" 2> /dev/null; then
  43. fn_print_fail_nl "FiveM license key is not set"
  44. echo -e "* Get a free key from ${italic}https://portal.cfx.re/servers/registration-keys${default}"
  45. echo -e "* Set licensekey=\"\" in ${configdirserver}/${selfname}.cfg"
  46. fn_script_log_fail "FiveM license key is not set"
  47. if [ "${commandname}" == "START" ] || [ "${commandname}" == "DEBUG" ]; then
  48. core_exit.sh
  49. fi
  50. fi