check_config.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 [ "${shortname}" == "orar" ] && [ ! -d "${servercfgdir}" ]; then
  9. install_config.sh
  10. fi
  11. if [ "${shortname}" == "jk2" ] && [ ! -f "${servercfgfullpath}" ] && [ -f "${systemdir}/${servercfg}" ]; then
  12. fn_print_info_nl "Moving ${servercfg} to ${servercfgdir}"
  13. fn_script_log_info "Moving ${systemdir}/${servercfg} to ${servercfgfullpath}"
  14. mv "${systemdir}/${servercfg}" "${servercfgfullpath}"
  15. fi
  16. if [ -n "${servercfgfullpath}" ] && [ ! -f "${servercfgfullpath}" ]; then
  17. fn_print_warn_nl "Configuration file missing!"
  18. echo -e "${servercfgfullpath}"
  19. fn_script_log_warn "Configuration file missing!"
  20. fn_script_log_warn "${servercfgfullpath}"
  21. install_config.sh
  22. fi
  23. if [ "${shortname}" == "ti" ] && [[ "${startparameters}" != *"DedicatedServerClientId"* ]] && [ ! -f "${servercfgdir}/Engine.ini" ]; then
  24. fn_print_warn_nl "Configuration file missing!"
  25. echo -e "${servercfgdir}/Engine.ini"
  26. fn_script_log_warn "Configuration file missing!"
  27. fn_script_log_warn "${servercfgdir}/Engine.ini"
  28. install_config.sh
  29. fi
  30. if [ "${shortname}" == "rust" ] && [ -v rconpassword ] && [ -z "${rconpassword}" ]; then
  31. fn_print_fail_nl "RCON password is not set"
  32. fn_script_log_warn "RCON password is not set"
  33. elif [ -v rconpassword ] && [ "${rconpassword}" == "CHANGE_ME" ]; then
  34. fn_print_warn_nl "Default RCON password detected"
  35. fn_script_log_warn "Default RCON password detected"
  36. elif [ -v httppassword ] && [ "${httppassword}" == "CHANGE_ME" ]; then
  37. fn_print_warn_nl "Default Web password detected"
  38. fn_script_log_warn "Default Web password detected"
  39. elif [ -v adminpassword ] && [ "${adminpassword}" == "CHANGE_ME" ]; then
  40. fn_print_warn_nl "Default Admin password detected"
  41. fn_script_log_warn "Default Admin password detected"
  42. fi
  43. if [ "${shortname}" == "vh" ] && [ -z "${serverpassword}" ]; then
  44. fn_print_fail_nl "serverpassword is not set"
  45. fn_script_log_fail "serverpassword is not set"
  46. elif [ "${shortname}" == "vh" ] && [ "${#serverpassword}" -le "4" ]; then
  47. fn_print_fail_nl "serverpassword is to short (min 5 chars)"
  48. fn_script_log_fail "serverpassword is to short (min 5 chars)"
  49. fi
  50. if [ "${shortname}" == "fivem" ] && ! grep -qE "^[[:space:]]*(set[[:space:]]+)?sv_licenseKey[[:space:]]+\"?[^\" ]" "${servercfgfullpath}" 2> /dev/null; then
  51. fn_print_fail_nl "FiveM license key is not set"
  52. echo -e "* Get a free key from ${italic}https://portal.cfx.re/servers/registration-keys${default}"
  53. echo -e "* Set sv_licenseKey in ${servercfgfullpath}"
  54. fn_script_log_fail "FiveM license key is not set"
  55. if [ "${commandname}" == "START" ] || [ "${commandname}" == "DEBUG" ]; then
  56. core_exit.sh
  57. fi
  58. fi