command_monitor.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. #!/bin/bash
  2. # LinuxGSM command_monitor.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Monitors server by checking for running processes
  7. # then passes to gamedig and gsquery.
  8. commandname="MONITOR"
  9. commandaction="Monitoring"
  10. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  11. fn_firstcommand_set
  12. # Checks if this instance is running one of the given commands, e.g. "update|u".
  13. # Matches the script run as ./gameserver, /path/to/gameserver or bash gameserver.
  14. fn_monitor_command_running() {
  15. [ "$(pgrep -fc -u "${USER}" "^([^ ]*/)?bash ([^ ]*/)?${selfname} ($1)( |$)")" != "0" ]
  16. }
  17. fn_monitor_check_monitoring() {
  18. if [ -f "${lockdir}/${selfname}.lock" ]; then
  19. # Part of migration to v23.5.0. #4296
  20. rm -f "${lockdir:?}/${selfname}.lock"
  21. date '+%s' > "${lockdir:?}/${selfname}-monitoring.lock"
  22. elif [ ! -f "${lockdir}/${selfname}-monitoring.lock" ]; then
  23. # Monitor does not run if lockfile is not found.
  24. fn_print_dots "Checking lockfile"
  25. fn_print_checking_eol
  26. fn_script_log_info "Checking lockfile: CHECKING"
  27. fn_print_error "Checking lockfile: No lockfile found"
  28. fn_print_error_eol_nl
  29. fn_script_log_error "Checking lockfile: No lockfile found: ERROR"
  30. echo -e "* Start ${selfname} to run monitor."
  31. core_exit.sh
  32. fi
  33. }
  34. fn_monitor_check_install() {
  35. if fn_monitor_command_running "install|i|auto-install|ai"; then
  36. fn_print_dots "Checking installer"
  37. fn_print_checking_eol
  38. fn_script_log_info "Checking installer: CHECKING"
  39. fn_print_info "Checking installer: LinuxGSM is installing"
  40. fn_print_info_eol_nl
  41. fn_script_log_pass "Checking installer: LinuxGSM is installing"
  42. core_exit.sh
  43. fi
  44. }
  45. fn_monitor_check_debug() {
  46. if fn_monitor_command_running "debug|d"; then
  47. fn_print_dots "Checking debug"
  48. fn_print_checking_eol
  49. fn_print_info "Checking debug: Debug is running"
  50. fn_print_info_eol_nl
  51. fn_script_log_pass "Checking debug: Debug is running"
  52. core_exit.sh
  53. fi
  54. }
  55. fn_monitor_check_details() {
  56. if fn_monitor_command_running "details|dt"; then
  57. fn_print_dots "Checking details"
  58. fn_print_checking_eol
  59. fn_print_info "Checking details: Details is running"
  60. fn_print_info_eol_nl
  61. fn_script_log_pass "Checking details: Details is running"
  62. core_exit.sh
  63. fi
  64. }
  65. fn_monitor_check_starting() {
  66. # Remove stale lockfile.
  67. if [ -f "${lockdir}/${selfname}-starting.lock" ]; then
  68. if [ "$(find "${lockdir}/${selfname}-starting.lock" -mmin +5)" ]; then
  69. fn_print_dots "Checking start"
  70. fn_print_checking_eol
  71. fn_print_warn "Checking start: Removing stale lockfile"
  72. fn_print_warn_eol_nl
  73. fn_script_log_warn "Checking start: Removing stale lockfile"
  74. rm -f "${lockdir:?}/${selfname}-starting.lock"
  75. fi
  76. fi
  77. if [ -f "${lockdir}/${selfname}-starting.lock" ] && fn_monitor_command_running "start|st"; then
  78. fn_print_dots "Checking start"
  79. fn_print_checking_eol
  80. fn_print_info "Checking start: LinuxGSM is starting"
  81. fn_print_info_eol_nl
  82. fn_script_log_info "Checking start: LinuxGSM is starting"
  83. core_exit.sh
  84. fi
  85. }
  86. fn_monitor_check_stopping() {
  87. # Remove stale lockfile.
  88. if [ -f "${lockdir}/${selfname}-stopping.lock" ]; then
  89. if [ "$(find "${lockdir}/${selfname}-stopping.lock" -mmin +5)" ]; then
  90. fn_print_dots "Checking stop"
  91. fn_print_checking_eol
  92. fn_print_warn "Checking stop: Removing stale lockfile"
  93. fn_print_warn_eol_nl
  94. fn_script_log_warn "Checking stop: Removing stale lockfile"
  95. rm -f "${lockdir:?}/${selfname}-stopping.lock"
  96. fi
  97. fi
  98. if [ -f "${lockdir}/${selfname}-stopping.lock" ] && fn_monitor_command_running "stop|sp"; then
  99. fn_print_dots "Checking stop"
  100. fn_print_checking_eol
  101. fn_print_info "Checking stop: LinuxGSM is stopping"
  102. fn_print_info_eol_nl
  103. fn_script_log_info "Checking stop: LinuxGSM is stopping"
  104. core_exit.sh
  105. fi
  106. }
  107. fn_monitor_check_restart_request() {
  108. if [ -f "${lockdir}/${selfname}-restart-request.lock" ]; then
  109. fn_print_dots "Checking restart: "
  110. fn_print_checking_eol
  111. fn_print_info "Checking restart: Restart requested: "
  112. fn_print_info_eol_nl
  113. fn_script_log_info "Checking restart: Restart requested"
  114. check_players_online.sh
  115. if [ -n "${playersonline}" ]; then
  116. fn_print_info_nl "${playersonline} players are on the server: restart postponed"
  117. fn_script_log_info "${playersonline} players are on the server: restart postponed"
  118. echo "${playersonline}" > "${lockdir:?}/${selfname}-player-numbers.lock"
  119. date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
  120. core_exit.sh
  121. fi
  122. command_restart.sh
  123. core_exit.sh
  124. fi
  125. }
  126. # An update postponed because players were online runs once the server is empty.
  127. # It runs in the background as its own update command, so monitor returns straight away
  128. # (e.g. a healthcheck timeout can't stop it) and other monitor runs see the update in progress.
  129. fn_monitor_check_update_request() {
  130. local updaterequest="${lockdir}/${selfname}-update-request.lock"
  131. if [ -f "${updaterequest}" ]; then
  132. fn_print_dots "Checking update: "
  133. fn_print_checking_eol
  134. fn_print_info "Checking update: Update requested: "
  135. fn_print_info_eol_nl
  136. fn_script_log_info "Checking update: Update requested"
  137. check_players_online.sh
  138. if [ -n "${playersonline}" ]; then
  139. fn_print_info_nl "${playersonline} players are on the server: update postponed"
  140. fn_script_log_info "${playersonline} players are on the server: update postponed"
  141. echo "${playersonline}" > "${lockdir:?}/${selfname}-player-numbers.lock"
  142. else
  143. local requestforce=""
  144. if grep -qx "force" "${updaterequest}"; then
  145. requestforce="1"
  146. fi
  147. fn_print_info_nl "Checking update: Running requested update"
  148. fn_script_log_info "Checking update: Running requested update"
  149. forceupdate="${requestforce}" setsid "${rootdir}/${selfname}" update > /dev/null 2>&1 < /dev/null &
  150. # shellcheck disable=SC2034 # Used by core_exit.sh.
  151. exitcode=0
  152. core_exit.sh
  153. fi
  154. fi
  155. }
  156. # A backup postponed because players were online runs once the server is empty, in the background
  157. # like a requested update. An alert is sent once if it has been postponed for over 24 hours.
  158. fn_monitor_check_backup_request() {
  159. local backuprequest="${lockdir}/${selfname}-backup-request.lock"
  160. if [ -f "${backuprequest}" ]; then
  161. fn_print_dots "Checking backup: "
  162. fn_print_checking_eol
  163. fn_print_info "Checking backup: Backup requested: "
  164. fn_print_info_eol_nl
  165. fn_script_log_info "Checking backup: Backup requested"
  166. check_players_online.sh
  167. if [ -n "${playersonline}" ]; then
  168. fn_print_info_nl "${playersonline} players are on the server: backup postponed"
  169. fn_script_log_info "${playersonline} players are on the server: backup postponed"
  170. echo "${playersonline}" > "${lockdir:?}/${selfname}-player-numbers.lock"
  171. local requested
  172. requested="$(head -n 1 "${backuprequest}")"
  173. if [[ "${requested}" =~ ^[0-9]+$ ]] && [ "$(($(date '+%s') - requested))" -gt 86400 ] && ! grep -q "alerted" "${backuprequest}"; then
  174. alert="backup-postponed"
  175. alert.sh
  176. echo "alerted" >> "${backuprequest}"
  177. fi
  178. else
  179. fn_print_info_nl "Checking backup: Running requested backup"
  180. fn_script_log_info "Checking backup: Running requested backup"
  181. setsid "${rootdir}/${selfname}" backup > /dev/null 2>&1 < /dev/null &
  182. # shellcheck disable=SC2034 # Used by core_exit.sh.
  183. exitcode=0
  184. core_exit.sh
  185. fi
  186. fi
  187. }
  188. fn_monitor_check_backup() {
  189. # Remove stale lockfile, unless a long backup is still running.
  190. if [ -f "${lockdir}/backup.lock" ] && ! fn_monitor_command_running "backup|b"; then
  191. if [ "$(find "${lockdir}/backup.lock" -mmin +60)" ]; then
  192. fn_print_dots "Checking backup"
  193. fn_print_checking_eol
  194. fn_print_warn "Checking backup: Removing stale lockfile"
  195. fn_print_warn_eol
  196. fn_script_log_warn "Checking backup: Removing stale lockfile"
  197. rm -f "${lockdir:?}/backup.lock"
  198. fi
  199. fi
  200. if [ -f "${lockdir}/backup.lock" ] && fn_monitor_command_running "backup|b"; then
  201. fn_print_dots "Checking backup"
  202. fn_print_checking_eol
  203. fn_print_info "Checking backup: Backup is running"
  204. fn_print_info_eol_nl
  205. fn_script_log_info "Checking backup: Backup is running"
  206. core_exit.sh
  207. fi
  208. }
  209. fn_monitor_check_update() {
  210. # Remove stale lockfile, unless a long update is still running.
  211. if [ -f "${lockdir}/update.lock" ] && ! fn_monitor_command_running "update|u|validate|v|force-update|fu|update-restart|ur|workshop-update|wu"; then
  212. if [ "$(find "${lockdir}/update.lock" -mmin +15)" ]; then
  213. fn_print_dots "Checking update"
  214. fn_print_checking_eol
  215. fn_print_warn "Checking update: Removing stale lockfile"
  216. fn_print_warn_eol_nl
  217. fn_script_log_warn "Checking update: Removing stale lockfile"
  218. rm -f "${lockdir:?}/update.lock"
  219. fi
  220. fi
  221. if [ -f "${lockdir}/update.lock" ] && fn_monitor_command_running "update|u|validate|v|force-update|fu|update-restart|ur|workshop-update|wu"; then
  222. fn_print_dots "Checking update"
  223. fn_print_checking_eol
  224. fn_print_info "Checking update: LinuxGSM is updating the game server"
  225. fn_print_info_eol_nl
  226. fn_script_log_pass "Checking update: LinuxGSM is updating the game server"
  227. core_exit.sh
  228. fi
  229. }
  230. # Source engine games may display a messages to indicate the server needs restarting.
  231. fn_monitor_check_update_source() {
  232. if [ -f "${consolelogdir}/${selfname}-console.log" ] && [ "${engine}" == "source" ]; then
  233. if grep -q "Your server needs to be restarted in order to receive the latest update." "${consolelogdir}/${selfname}-console.log"; then
  234. fn_print_dots "Checking update"
  235. fn_print_checking_eol
  236. fn_script_log_info "Checking update: CHECKING"
  237. fn_print_ok "Checking update"
  238. fn_print_ok_eol_nl
  239. fn_script_log_info "Checking update: ${selfname} has requested a restart for an update to be applied"
  240. alert="update-restart-request"
  241. alert.sh
  242. command_restart.sh
  243. core_exit.sh
  244. fi
  245. fi
  246. }
  247. fn_monitor_check_session() {
  248. fn_print_dots "Checking session"
  249. fn_print_checking_eol
  250. fn_script_log_info "Checking session: CHECKING"
  251. # Tmux session width and height needs to be reviewed as may no longer be required.
  252. sessionwidth="80"
  253. sessionheight="23"
  254. # Check for PIDS with identical tmux sessions running.
  255. if [ "$(pgrep -fcx "tmux -L ${socketname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}")" -ge "2" ]; then
  256. fn_print_error "Checking session: There are PIDS with identical tmux sessions running"
  257. fn_print_error_eol_nl
  258. fn_script_log_error "Checking session: ERROR"
  259. fn_script_log_error "Checking session: There are PIDS with identical tmux sessions running"
  260. fn_script_log_error "Checking session: Killing all tmux sessions with the socketname name ${socketname} and session name ${sessionname}"
  261. pkill -f "tmux -L ${socketname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}"
  262. command_restart.sh
  263. core_exit.sh
  264. # Check for tmux pids with the same tmux session and socket names. This will reduce issues with migration to release v23.5.0. #4296
  265. elif [ "$(pgrep -fc -u "${USER}" "^tmux -L ${sessionname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}( |$)")" != "0" ]; then
  266. fn_print_error "Checking session: PIDS with the same tmux session and socket names are running"
  267. fn_print_error_eol_nl
  268. fn_script_log_error "Checking session: ERROR"
  269. fn_script_log_error "Checking session: PIDS with the same tmux session and socket names are running"
  270. fn_script_log_error "Checking session: Killing session with the socketname name ${sessionname} and session name ${sessionname}"
  271. pkill -f "^tmux -L ${sessionname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}( |$)"
  272. command_restart.sh
  273. core_exit.sh
  274. # Check for tmux pids that are using the old type of tmux session. This will reduce issues with migration to release v23.5.0. #4296
  275. elif [ "$(pgrep -fc -u "${USER}" "^tmux new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}( |$)")" != "0" ]; then
  276. fn_print_error "Checking session: PIDS with old type tmux session are running"
  277. fn_print_error_eol_nl
  278. fn_script_log_error "Checking session: ERROR"
  279. fn_script_log_error "Checking session: PIDS with old type tmux session are running"
  280. fn_script_log_error "Checking session: Killing session with the session name ${sessionname}"
  281. pkill -f "^tmux new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}( |$)"
  282. command_restart.sh
  283. core_exit.sh
  284. elif [ "${status}" != "0" ]; then
  285. fn_print_ok "Checking session"
  286. fn_print_ok_eol_nl
  287. fn_script_log_pass "Checking session: OK"
  288. # send LinuxGSM stats if monitor is OK.
  289. if [ "${stats}" == "on" ] || [ "${stats}" == "y" ] && [ "${querymode}" == "1" ]; then
  290. info_stats.sh
  291. fi
  292. else
  293. fn_print_error "Checking session"
  294. fn_print_fail_eol_nl
  295. fn_script_log_fail "Checking session: FAIL"
  296. alert="monitor-session"
  297. alert.sh
  298. fn_script_log_info "Checking session: Monitor is restarting ${selfname}"
  299. command_restart.sh
  300. core_exit.sh
  301. fi
  302. }
  303. # Monitor will check queryport is set before continuing.
  304. fn_monitor_check_queryport() {
  305. if [ -z "${queryport}" ] || [ "${queryport}" == "0" ]; then
  306. fn_print_dots "Checking port"
  307. fn_print_checking_eol
  308. fn_script_log_info "Checking port: CHECKING"
  309. if [ -n "${rconenabled}" ] && [ "${rconenabled}" != "true" ] && [ "${shortname}" == "av" ]; then
  310. fn_print_warn "Checking port: Unable to query, rcon is not enabled"
  311. fn_script_log_warn "Checking port: Unable to query, rcon is not enabled"
  312. else
  313. fn_print_error "Checking port: Unable to query, queryport is not set"
  314. fn_script_log_error "Checking port: Unable to query, queryport is not set"
  315. fi
  316. core_exit.sh
  317. fi
  318. }
  319. fn_query_gsquery() {
  320. if [ ! -f "${modulesdir}/query_gsquery.py" ]; then
  321. fn_fetch_file_github "lgsm/modules" "query_gsquery.py" "${modulesdir}" "chmodx" "norun" "noforce" "nohash"
  322. fi
  323. "${modulesdir}"/query_gsquery.py -a "${queryip}" -p "${queryport}" -e "${querytype}" > /dev/null 2>&1
  324. querystatus="$?"
  325. }
  326. fn_query_tcp() {
  327. bash -c "exec 3<> /dev/tcp/'${queryip}'/'${queryport}'" > /dev/null 2>&1
  328. querystatus="$?"
  329. }
  330. fn_monitor_query() {
  331. # Will loop and query up to 5 times every 15 seconds.
  332. # Query will wait up to 60 seconds to confirm server is down as server can become non-responsive during map changes.
  333. totalseconds=0
  334. for queryattempt in {1..5}; do
  335. for queryip in "${queryips[@]}"; do
  336. fn_print_dots "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
  337. fn_print_querying_eol
  338. fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : QUERYING"
  339. # querydelay
  340. if [ "$(head -n 1 "${lockdir}/${selfname}-started.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then
  341. fn_print_ok "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
  342. fn_print_delay_eol_nl
  343. fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : DELAY"
  344. fn_script_log_info "Query bypassed: ${gameservername} started less than ${querydelay} minutes ago"
  345. fn_script_log_info "Server started: $(date -d "@$(head -n 1 "${lockdir}/${selfname}-started.lock")")"
  346. fn_script_log_info "Current time: $(date)"
  347. monitorpass=1
  348. core_exit.sh
  349. # will use query method selected in fn_monitor_loop
  350. # gamedig
  351. elif [ "${querymethod}" == "gamedig" ]; then
  352. query_gamedig.sh
  353. # gsquery
  354. elif [ "${querymethod}" == "gsquery" ]; then
  355. fn_query_gsquery
  356. #tcp query
  357. elif [ "${querymethod}" == "tcp" ]; then
  358. fn_query_tcp
  359. fi
  360. if [ "${querystatus}" == "0" ]; then
  361. # Server query OK.
  362. fn_print_ok "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
  363. fn_print_ok_eol_nl
  364. fn_script_log_pass "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : OK"
  365. monitorpass=1
  366. if [ "${querystatus}" == "0" ]; then
  367. # Add query data to log.
  368. if [ "${gdname}" ]; then
  369. fn_script_log_info "Server name: ${gdname}"
  370. fi
  371. if [ "${gdplayers}" ]; then
  372. fn_script_log_info "Players: ${gdplayers}/${gdmaxplayers}"
  373. fi
  374. if [ "${gdbots}" ]; then
  375. fn_script_log_info "Bots: ${gdbots}"
  376. fi
  377. if [ "${gdmap}" ]; then
  378. fn_script_log_info "Map: ${gdmap}"
  379. fi
  380. if [ "${gdgamemode}" ]; then
  381. fn_script_log_info "Game Mode: ${gdgamemode}"
  382. fi
  383. # send LinuxGSM stats if monitor is OK.
  384. if [ "${stats}" == "on" ] || [ "${stats}" == "y" ]; then
  385. info_stats.sh
  386. fi
  387. fi
  388. core_exit.sh
  389. else
  390. # Server query FAIL.
  391. fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
  392. fn_print_fail_eol
  393. fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : FAIL"
  394. # Monitor will try gamedig (if supported) for first 30s then gsquery before restarting.
  395. # gsquery will fail if longer than 60s
  396. if [ "${totalseconds}" -ge "59" ]; then
  397. # Monitor will FAIL if over 60s and trigger gane server reboot.
  398. fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
  399. fn_print_fail_eol_nl
  400. fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : FAIL"
  401. # Send alert if enabled.
  402. alert="monitor-query"
  403. alert.sh
  404. command_restart.sh
  405. fn_firstcommand_reset
  406. core_exit.sh
  407. fi
  408. fi
  409. done
  410. # Second counter will wait for 15s before breaking loop.
  411. for seconds in {1..15}; do
  412. fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
  413. fn_print_wait_eol
  414. fn_sleep_time_1
  415. totalseconds=$((totalseconds + 1))
  416. if [ "${seconds}" == "15" ]; then
  417. break
  418. fi
  419. done
  420. done
  421. }
  422. fn_monitor_loop() {
  423. # loop though query methods selected by querymode.
  424. totalseconds=0
  425. if [ "${querymode}" == "2" ]; then
  426. local query_methods_array=(gamedig gsquery)
  427. elif [ "${querymode}" == "3" ]; then
  428. local query_methods_array=(gamedig)
  429. elif [ "${querymode}" == "4" ]; then
  430. local query_methods_array=(gsquery)
  431. elif [ "${querymode}" == "5" ]; then
  432. local query_methods_array=(tcp)
  433. fi
  434. for querymethod in "${query_methods_array[@]}"; do
  435. # Will check if gamedig is installed and bypass if not.
  436. if [ "${querymethod}" == "gamedig" ]; then
  437. if [ "$(command -v gamedig 2> /dev/null)" ] || [ -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ] && [ "$(command -v jq 2> /dev/null)" ]; then
  438. if [ -z "${monitorpass}" ]; then
  439. fn_monitor_query
  440. fi
  441. else
  442. fn_script_log_info "gamedig is not installed"
  443. fn_script_log_info "https://docs.linuxgsm.com/requirements/gamedig"
  444. fi
  445. else
  446. # will not query if query already passed.
  447. if [ -z "${monitorpass}" ]; then
  448. fn_monitor_query
  449. fi
  450. fi
  451. done
  452. }
  453. fn_print_dots ""
  454. monitorflag=1
  455. # Dont do any monitoring or checks if installer is running.
  456. fn_monitor_check_install
  457. check.sh
  458. core_logs.sh
  459. info_game.sh
  460. # query pre-checks
  461. fn_monitor_check_details
  462. fn_monitor_check_backup
  463. fn_monitor_check_debug
  464. fn_monitor_check_update_source
  465. fn_monitor_check_update
  466. fn_monitor_check_monitoring
  467. fn_monitor_check_starting
  468. fn_monitor_check_stopping
  469. fn_monitor_check_session
  470. fn_monitor_check_restart_request
  471. fn_monitor_check_update_request
  472. fn_monitor_check_backup_request
  473. # Monitor will not continue if session only check.
  474. if [ "${querymode}" != "1" ]; then
  475. fn_monitor_check_queryport
  476. # Add a querydelay of 1 min if var missing.
  477. if [ -z "${querydelay}" ]; then
  478. querydelay="1"
  479. fi
  480. fn_monitor_loop
  481. fi
  482. core_exit.sh