diff --git a/.shellcheckrc b/.shellcheckrc index 026ee646c7..d16f69e0b2 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1 +1 @@ -disable=SC2154 +disable=SC2154,SC2034 diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index 16ba7e9390..cab14481d2 100644 --- a/lgsm/modules/alert.sh +++ b/lgsm/modules/alert.sh @@ -10,13 +10,9 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" # Generates alert log of the details at the time of the alert. # Used with email alerts. fn_alert_log() { - info_distro.sh - info_game.sh - info_messages.sh if [ -f "${alertlog}" ]; then rm -f "${alertlog:?}" fi - { fn_info_messages_head fn_info_messages_distro @@ -97,45 +93,66 @@ fn_alert_monitor_query() { # Update alerts fn_alert_update() { - fn_script_log_info "Sending alert: ${selfname} has received a game server update: ${localbuild}" + # If previousbuild is set show transition, else fallback to single version. + if [ -n "${previousbuild:-}" ] && [ -n "${localbuild:-}" ]; then + fn_script_log_info "Sending alert: ${selfname} updated: ${previousbuild} -> ${localbuild}" + alertmessage="${selfname} updated: ${previousbuild} -> ${localbuild}." + else + fn_script_log_info "Sending alert: ${selfname} updated to ${localbuild}" + alertmessage="${selfname} updated to ${localbuild}." + fi alertaction="Updated" alertemoji="🎉" alertsound="1" - alertmessage="${selfname} has received a game server update: ${localbuild}." # Green alertcolourhex="#00cd00" alertcolourdec="52480" } -fn_alert_update_request() { - fn_script_log_info "Sending alert: ${selfname} has requested an update and needs to be restarted." - alertaction="Updating" +# Update failure alert +fn_alert_update_failed() { + # Expect updatefailureexpected (target version) and updatefailuregot (actual localbuild) if set + local updateexpected="${updatefailureexpected:-${remotebuild:-unknown}}" + local updategot="${updatefailuregot:-${localbuild:-unknown}}" + fn_script_log_error "Sending alert: ${selfname} update failed: expected ${updateexpected}, got ${updategot}" + alertaction="Update Failed" + alertemoji="❌" + alertsound="2" + alertmessage="${selfname} update failed: expected ${updateexpected}, got ${updategot}. Manual intervention required." + # Red + alertcolourhex="#cd0000" + alertcolourdec="13434880" +} + +fn_alert_update_restart_request() { + fn_script_log_info "Sending alert: ${selfname} restart requested" + alertaction="Restart Requested" alertemoji="🎉" alertsound="1" - alertmessage="${selfname} has requested an update and needs to be restarted." + alertmessage="${selfname} has requested a restart for an update to be applied. Restarting now." # Blue alertcolourhex="#1e90ff" alertcolourdec="2003199" } fn_alert_check_update() { - fn_script_log_info "Sending alert: ${gamename} update available: ${remotebuildversion}" - alertaction="Update available" + fn_script_log_info "Sending alert: ${gamename} update available: ${localbuild} -> ${remotebuild}" + alertaction="Update Available" alertemoji="🎉" alertsound="1" - alertmessage="${gamename} update available: ${remotebuildversion}" + alertmessage="${gamename} update available: ${localbuild} -> ${remotebuild}" # Blue alertcolourhex="#1e90ff" alertcolourdec="2003199" } fn_alert_update_linuxgsm() { - fn_script_log_info "Sending alert: ${selfname} has received an LinuxGSM update" + fn_script_log_info "Sending alert: ${selfname} has received a LinuxGSM update" alertaction="Updated" alertemoji="🎉" alertsound="1" alertbody="${gamename} update available" - alertmessage="${selfname} has received an LinuxGSM update and been restarted." + alertmessage="${selfname} has received a LinuxGSM update and been restarted." # Green alertcolourhex="#00cd00" alertcolourdec="52480" @@ -197,8 +214,9 @@ fn_alert_info() { alertcolourdec="2003199" } -# Images -alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png" +info_distro.sh +info_game.sh +info_messages.sh if [ "${alert}" == "permissions" ]; then fn_alert_permissions @@ -210,8 +228,10 @@ elif [ "${alert}" == "test" ]; then fn_alert_test elif [ "${alert}" == "update" ]; then fn_alert_update -elif [ "${alert}" == "update-request" ]; then - fn_alert_update_request +elif [ "${alert}" == "update-failed" ]; then + fn_alert_update_failed +elif [ "${alert}" == "update-restart-request" ]; then + fn_alert_update_restart_request elif [ "${alert}" == "check-update" ]; then fn_alert_check_update elif [ "${alert}" == "config" ]; then @@ -237,6 +257,7 @@ else fi alerttitle="${alertemoji} ${alertaction} - ${servername} ${alertemoji}" +alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png" # Generate alert log. fn_alert_log diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index 1440b6a96b..bd8e8b58c8 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -46,11 +46,6 @@ json=$( "name": "Server Time", "value": "$(date)", "inline": true - }, - { - "name": "More info", - "value": "${alerturl}", - "inline": true } EOF ) diff --git a/lgsm/modules/check_last_update.sh b/lgsm/modules/check_last_update.sh index 2686c6507d..a68285344a 100644 --- a/lgsm/modules/check_last_update.sh +++ b/lgsm/modules/check_last_update.sh @@ -11,6 +11,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" if [ -f "${lockdir}/${selfname}-last-started.lock" ]; then laststart=$(cat "${lockdir}/${selfname}-last-started.lock") fi + if [ -f "${lockdir}/last-updated.lock" ]; then lastupdate=$(cat "${lockdir}/last-updated.lock") fi diff --git a/lgsm/modules/command_monitor.sh b/lgsm/modules/command_monitor.sh index 5fa3c3000f..7c813aed77 100644 --- a/lgsm/modules/command_monitor.sh +++ b/lgsm/modules/command_monitor.sh @@ -164,8 +164,8 @@ fn_monitor_check_update_source() { fn_script_log_info "Checking update: CHECKING" fn_print_ok "Checking update" fn_print_ok_eol_nl - fn_script_log_info "Checking update: ${selfname} has requested an update and needs to be restarted" - alert="update-request" + fn_script_log_info "Checking update: ${selfname} has requested a restart for an update to be applied" + alert="update-restart-request" alert.sh command_restart.sh core_exit.sh diff --git a/lgsm/modules/command_postdetails.sh b/lgsm/modules/command_postdetails.sh index 7f5f673043..800a842881 100644 --- a/lgsm/modules/command_postdetails.sh +++ b/lgsm/modules/command_postdetails.sh @@ -59,7 +59,7 @@ fi fn_print_dots "termbin.com" link=$(cat "${postdetailslog}" | { - nc -w 3 termbin.com 9999 + nc -w 10 termbin.com 9999 echo $? > /tmp/nc_exit_status } | tr -d '\n\0') nc_exit_status=$(cat /tmp/nc_exit_status) diff --git a/lgsm/modules/core_steamcmd.sh b/lgsm/modules/core_steamcmd.sh index bf97901328..d265f577d1 100644 --- a/lgsm/modules/core_steamcmd.sh +++ b/lgsm/modules/core_steamcmd.sh @@ -185,12 +185,12 @@ fn_update_steamcmd_remotebuild() { fi # password for branch not needed to check the buildid - remotebuildversion=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_request "${appid}" +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]') + remotebuild=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_request "${appid}" +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -200,7 +200,7 @@ fn_update_steamcmd_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -211,14 +211,14 @@ fn_update_steamcmd_remotebuild() { fn_update_steamcmd_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" fn_print "\n" fn_print_nl "${bold}${underline}Update${default} available" fn_print_nl "* Local build: ${red}${localbuild}${default}" - fn_print_nl "* Remote build: ${green}${remotebuildversion}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then fn_print_nl "* Branch: ${branch}" fi @@ -229,16 +229,17 @@ fn_update_steamcmd_compare() { fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -n "${betapassword}" ]; then fn_script_log_info "Branch password: ${betapassword}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -257,7 +258,6 @@ fn_update_steamcmd_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir:?}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" @@ -268,7 +268,7 @@ fn_update_steamcmd_compare() { fn_print "\n" fn_print_nl "${bold}${underline}No update${default} available" fn_print_nl "* Local build: ${green}${localbuild}${default}" - fn_print_nl "* Remote build: ${green}${remotebuildversion}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then fn_print_nl "* Branch: ${branch}" fi @@ -279,7 +279,7 @@ fn_update_steamcmd_compare() { fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi diff --git a/lgsm/modules/update_fctr.sh b/lgsm/modules/update_fctr.sh index 3418c74247..5de789cdb1 100644 --- a/lgsm/modules/update_fctr.sh +++ b/lgsm/modules/update_fctr.sh @@ -10,25 +10,32 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_dl() { # Download and extract files to serverfiles. fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "nochmodx" "norun" "force" "nohash" - fn_dl_extract "${tmpdir}" "factorio_headless_${factorioarch}-${remotebuildversion}.tar.xz" "${serverfiles}" "factorio" + fn_dl_extract "${tmpdir}" "factorio_headless_${factorioarch}-${remotebuild}.tar.xz" "${serverfiles}" "factorio" fn_clear_tmp } fn_update_localbuild() { - # Gets local build info. - fn_print_dots "Checking local build: ${remotelocation}" + # Optional arg1: 'silent' to suppress user-facing output + local mode="${1:-}" + if [ "${mode}" != "silent" ]; then + fn_print_dots "Checking local build: ${remotelocation}" + fi # Uses executable to get local build. if [ -d "${executabledir}" ]; then cd "${executabledir}" || exit localbuild=$(${executable} --version | grep -m 1 "Version:" | awk '{print $2}') fi if [ -z "${localbuild}" ]; then - fn_print_error "Checking local build: ${remotelocation}: missing local build info" + if [ "${mode}" != "silent" ]; then + fn_print_error "Checking local build: ${remotelocation}: missing local build info" + fi fn_script_log_error "Missing local build info" fn_script_log_error "Set localbuild to 0" localbuild="0" else - fn_print_ok "Checking local build: ${remotelocation}" + if [ "${mode}" != "silent" ]; then + fn_print_ok "Checking local build: ${remotelocation}" + fi fn_script_log_pass "Checking local build" fi } @@ -37,14 +44,14 @@ fn_update_remotebuild() { # Gets remote build info. apiurl="https://factorio.com/get-download/${branch}/headless/${factorioarch}" remotebuildresponse=$(curl -s "${apiurl}") - remotebuildversion=$(echo "${remotebuildresponse}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1) + remotebuild=$(echo "${remotebuildresponse}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1) remotebuildurl="https://factorio.com/get-download/${branch}/headless/${factorioarch}" - remotebuildfilename="factorio_headless_${factorioarch}-${remotebuildversion}.tar.xz" + remotebuildfilename="factorio_headless_${factorioarch}-${remotebuild}.tar.xz" if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -54,7 +61,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -65,35 +72,37 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild} ${factorioarch}${default}" - echo -e "* Remote build: ${green}${remotebuildversion} ${factorioarch}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild} ${factorioarch}" - fn_script_log_info "Remote build: ${remotebuildversion} ${factorioarch}" + fn_script_log_info "Remote build: ${remotebuild} ${factorioarch}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + # Keep track of the build before updating for alert purposes. + previousbuild="${localbuild}" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -120,6 +129,23 @@ fn_update_compare() { command_start.sh fn_firstcommand_reset fi + # Refresh local build value after update (silent) so alerts show new version. + fn_update_localbuild silent + # Verify the update applied correctly unless forced update to same version. + if [ "${localbuild}" != "${remotebuild}" ]; then + # If forced update and version unchanged treat as acceptable; otherwise failure. + if [ "${forceupdate}" != "1" ] || [ "${previousbuild}" = "${localbuild}" ]; then + fn_script_log_error "Update verification failed: expected ${remotebuild}, got ${localbuild}" + fn_print_fail_nl "Update verification failed: expected ${remotebuild}, got ${localbuild}" + updatefailureexpected="${remotebuild}" + updatefailuregot="${localbuild}" + alert="update-failed" + alert.sh + core_exit.sh + fi + else + fn_script_log_pass "Update verification success: ${previousbuild} -> ${localbuild}" + fi unset exitbypass alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then @@ -128,26 +154,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild} ${factorioarch}${default}" - echo -e "* Remote build: ${green}${remotebuildversion} ${factorioarch}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild} ${factorioarch}" - fn_script_log_info "Remote build: ${remotebuildversion} ${factorioarch}" + fn_script_log_info "Remote build: ${remotebuild} ${factorioarch}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } diff --git a/lgsm/modules/update_jk2.sh b/lgsm/modules/update_jk2.sh index 5fdd54c654..b267e1352e 100644 --- a/lgsm/modules/update_jk2.sh +++ b/lgsm/modules/update_jk2.sh @@ -36,12 +36,12 @@ fn_update_remotebuild() { remotebuildresponse=$(curl -s "${apiurl}") remotebuildfilename=$(echo "${remotebuildresponse}" | jq -r '.assets[]|select(.browser_download_url | contains("dedicated.zip")) | .name') remotebuildurl=$(echo "${remotebuildresponse}" | jq -r '.assets[]|select(.browser_download_url | contains("dedicated.zip")) | .browser_download_url') - remotebuildversion=$(echo "${remotebuildresponse}" | jq -r '.tag_name') + remotebuild=$(echo "${remotebuildresponse}" | jq -r '.tag_name') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -51,7 +51,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -62,34 +62,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -117,7 +118,6 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" @@ -125,38 +125,32 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } # The location where the builds are checked and downloaded. -remotelocation="github.com" - -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi +remotelocation="factorio.com" if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild diff --git a/lgsm/modules/update_mc.sh b/lgsm/modules/update_mc.sh index a9be77576d..81540f0020 100644 --- a/lgsm/modules/update_mc.sh +++ b/lgsm/modules/update_mc.sh @@ -39,24 +39,24 @@ fn_update_remotebuild() { remotebuildresponse=$(curl -s "${apiurl}") # Latest release. if [ "${branch}" == "release" ] && [ "${mcversion}" == "latest" ]; then - remotebuildversion=$(echo "${remotebuildresponse}" | jq -r '.latest.release') + remotebuild=$(echo "${remotebuildresponse}" | jq -r '.latest.release') # Latest snapshot. elif [ "${branch}" == "snapshot" ] && [ "${mcversion}" == "latest" ]; then - remotebuildversion=$(echo "${remotebuildresponse}" | jq -r '.latest.snapshot') + remotebuild=$(echo "${remotebuildresponse}" | jq -r '.latest.snapshot') # Specific release/snapshot. else - remotebuildversion=$(echo "${remotebuildresponse}" | jq -r --arg branch "${branch}" --arg mcversion "${mcversion}" '.versions | .[] | select(.type==$branch and .id==$mcversion) | .id') + remotebuild=$(echo "${remotebuildresponse}" | jq -r --arg branch "${branch}" --arg mcversion "${mcversion}" '.versions | .[] | select(.type==$branch and .id==$mcversion) | .id') fi - remotebuildfilename="minecraft_server.${remotebuildversion}.jar" + remotebuildfilename="minecraft_server.${remotebuild}.jar" # Generate link to version manifest json. - remotebuildmanifest=$(echo "${remotebuildresponse}" | jq -r --arg branch "${branch}" --arg mcversion "${remotebuildversion}" '.versions | .[] | select(.type==$branch and .id==$mcversion) | .url') + remotebuildmanifest=$(echo "${remotebuildresponse}" | jq -r --arg branch "${branch}" --arg mcversion "${remotebuild}" '.versions | .[] | select(.type==$branch and .id==$mcversion) | .url') # Generate link to server.jar remotebuildurl=$(curl -s "${remotebuildmanifest}" | jq -r '.downloads.server.url') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -66,7 +66,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -77,35 +77,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -140,26 +140,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -167,12 +167,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="mojang.com" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl diff --git a/lgsm/modules/update_mcb.sh b/lgsm/modules/update_mcb.sh index a8616c3b82..9940415a1c 100644 --- a/lgsm/modules/update_mcb.sh +++ b/lgsm/modules/update_mcb.sh @@ -8,12 +8,12 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_dl() { - fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "bedrock_server.${remotebuildversion}.zip" "nochmodx" "norun" "noforce" "nohash" + fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "bedrock_server.${remotebuild}.zip" "nochmodx" "norun" "noforce" "nohash" echo -e "Extracting to ${serverfiles}...\c" if [ "${firstcommandname}" == "INSTALL" ]; then - unzip -oq "${tmpdir}/bedrock_server.${remotebuildversion}.zip" -x "server.properties" -d "${serverfiles}" + unzip -oq "${tmpdir}/bedrock_server.${remotebuild}.zip" -x "server.properties" -d "${serverfiles}" else - unzip -oq "${tmpdir}/bedrock_server.${remotebuildversion}.zip" -x "permissions.json" "server.properties" "allowlist.json" -d "${serverfiles}" + unzip -oq "${tmpdir}/bedrock_server.${remotebuild}.zip" -x "permissions.json" "server.properties" "allowlist.json" -d "${serverfiles}" fi exitcode=$? if [ "${exitcode}" -ne 0 ]; then @@ -61,13 +61,13 @@ fn_update_remotebuild() { else remotebuildurl=$(echo "${remotebuildresponse}" | jq -r 'select(.downloadType == "serverBedrockLinux") | .downloadUrl') fi - remotebuildversion=$(echo "${remotebuildurl}" | grep -Eo "[.0-9]+[0-9]") - remotebuildfilename="bedrock-server-${remotebuildversion}.zip" + remotebuild=$(echo "${remotebuildurl}" | grep -Eo "[.0-9]+[0-9]") + remotebuildfilename="bedrock-server-${remotebuild}.zip" if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -77,7 +77,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -88,35 +88,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -151,26 +151,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -178,12 +178,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="minecraft.net" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl diff --git a/lgsm/modules/update_mta.sh b/lgsm/modules/update_mta.sh index 50a3fb895e..b1ba0459c8 100644 --- a/lgsm/modules/update_mta.sh +++ b/lgsm/modules/update_mta.sh @@ -39,11 +39,11 @@ fn_update_remotebuild() { remotebuildresponse=$(curl -s "${apiurl}") remotebuildfilename="multitheftauto_linux_x64.tar.gz" remotebuildurl="http://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz" - remotebuildversion=$(echo "${remotebuildresponse}") + remotebuild="${remotebuildresponse}" if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -53,7 +53,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -64,7 +64,7 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" if [ "${forceupdate}" == "1" ]; then @@ -74,30 +74,31 @@ fn_update_compare() { mtaupdatestatus="available" fi fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -125,7 +126,6 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" @@ -133,26 +133,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -160,12 +160,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="linux.mtasa.com" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl diff --git a/lgsm/modules/update_pmc.sh b/lgsm/modules/update_pmc.sh index c38911d4ee..e0bbfa05ae 100644 --- a/lgsm/modules/update_pmc.sh +++ b/lgsm/modules/update_pmc.sh @@ -11,7 +11,7 @@ fn_update_dl() { # Download and extract files to serverfiles. fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "chmodx" "norun" "force" "${remotebuildhash}" cp -f "${tmpdir}/${remotebuildfilename}" "${serverfiles}/${executable#./}" - echo "${remotebuildversion}" > "${serverfiles}/build.txt" + echo "${remotebuild}" > "${serverfiles}/build.txt" fn_clear_tmp } @@ -61,12 +61,12 @@ fn_update_remotebuild() { remotebuildhash=$(echo "${remotebuildresponseversion}" | jq -r '.downloads.application.sha256') remotebuildurl="${apiurl}/${paperproject}/versions/${remotebuildmcversion}/builds/${remotebuildpaperversion}/downloads/${remotebuildfilename}" # Combines Minecraft: Java Edition version and paper build. e.g 1.16.5-456 - remotebuildversion="${remotebuildmcversion}-${remotebuildpaperversion}" + remotebuild="${remotebuildmcversion}-${remotebuildpaperversion}" if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -76,7 +76,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -87,35 +87,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -150,26 +150,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -177,12 +177,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="papermc.io" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${shortname}" == "pmc" ]; then paperproject="paper" elif [ "${shortname}" == "vpmc" ]; then diff --git a/lgsm/modules/update_ts3.sh b/lgsm/modules/update_ts3.sh index e1917e5e13..ec3bc0060e 100644 --- a/lgsm/modules/update_ts3.sh +++ b/lgsm/modules/update_ts3.sh @@ -43,12 +43,12 @@ fn_update_remotebuild() { remotebuildhash=$(echo -e "${remotebuildresponse}" | jq -r '.linux.x86.checksum') fi remotebuildfilename=$(basename "${remotebuildurl}") - remotebuildversion=$(echo -e "${remotebuildresponse}" | jq -r '.linux.x86_64.version') + remotebuild=$(echo -e "${remotebuildresponse}" | jq -r '.linux.x86_64.version') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -58,7 +58,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -69,35 +69,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -132,26 +132,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -171,12 +171,6 @@ fi # The location where the builds are checked and downloaded. remotelocation="teamspeak.com" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl diff --git a/lgsm/modules/update_ut99.sh b/lgsm/modules/update_ut99.sh index bdfb96f0b0..4e3f93b310 100644 --- a/lgsm/modules/update_ut99.sh +++ b/lgsm/modules/update_ut99.sh @@ -11,7 +11,7 @@ fn_update_dl() { # Download and extract files to serverfiles. fn_fetch_file "${remotebuildurl}" "" "" "" "${tmpdir}" "${remotebuildfilename}" "nochmodx" "norun" "force" "nohash" fn_dl_extract "${tmpdir}" "${remotebuildfilename}" "${serverfiles}" - echo "${remotebuildversion}" > "${serverfiles}/build.txt" + echo "${remotebuild}" > "${serverfiles}/build.txt" fn_clear_tmp } @@ -37,12 +37,12 @@ fn_update_remotebuild() { remotebuildresponse=$(curl -s "${apiurl}") remotebuildfilename=$(echo "${remotebuildresponse}" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .name') remotebuildurl=$(echo "${remotebuildresponse}" | jq -r '.assets[]|select(.browser_download_url | contains("Linux-amd64")) | .browser_download_url') - remotebuildversion=$(echo "${remotebuildresponse}" | jq -r '.tag_name') + remotebuild=$(echo "${remotebuildresponse}" | jq -r '.tag_name') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -52,7 +52,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -63,35 +63,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -126,26 +126,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -153,12 +153,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="github.com" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl diff --git a/lgsm/modules/update_vints.sh b/lgsm/modules/update_vints.sh index a300b87eb9..86a7156ee0 100644 --- a/lgsm/modules/update_vints.sh +++ b/lgsm/modules/update_vints.sh @@ -20,6 +20,7 @@ fn_update_localbuild() { # Uses executable to get local build. if [ -d "${executabledir}" ]; then cd "${executabledir}" || exit + # shellcheck disable=SC2086 # Intentional: preexecutable may be empty; unquoted to drop it without producing an empty arg. localbuild="$(${preexecutable} ${executable} --version 2> /dev/null | sed '/^[[:space:]]*$/d')" fi if [ -z "${localbuild}" ]; then @@ -44,14 +45,14 @@ fn_update_remotebuild() { else remotebuildversion="${branch}" fi - remotebuildfilename=$(echo "${remotebuildresponse}" | jq --arg remotebuildversion "${remotebuildversion}" -r '.[$remotebuildversion].linuxserver.filename') - remotebuildurl=$(echo "${remotebuildresponse}" | jq --arg remotebuildversion "${remotebuildversion}" -r '.[$remotebuildversion].linuxserver.urls.cdn') - remotebuildhash=$(echo "${remotebuildresponse}" | jq --arg remotebuildversion "${remotebuildversion}" -r '.[$remotebuildversion].linuxserver.md5') + remotebuildfilename=$(echo "${remotebuildresponse}" | jq --arg remotebuild "${remotebuild}" -r '.[$remotebuild].linuxserver.filename') + remotebuildurl=$(echo "${remotebuildresponse}" | jq --arg remotebuild "${remotebuild}" -r '.[$remotebuild].linuxserver.urls.cdn') + remotebuildhash=$(echo "${remotebuildresponse}" | jq --arg remotebuild "${remotebuild}" -r '.[$remotebuild].linuxserver.md5') if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -61,7 +62,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -72,35 +73,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -135,26 +136,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -162,12 +163,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="vintagestory.at" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl diff --git a/lgsm/modules/update_xnt.sh b/lgsm/modules/update_xnt.sh index c00233aa7b..3a937a9f6a 100644 --- a/lgsm/modules/update_xnt.sh +++ b/lgsm/modules/update_xnt.sh @@ -54,13 +54,12 @@ fn_update_remotebuild() { remotebuildfilename=$(echo "${remotebuildtag}" | tr -d 'v') remotebuildfilename="${remotebuildfilename}.zip" remotebuildurl="https://dl.xonotic.org/${remotebuildfilename}" - - remotebuildversion="${remotebuildtag}" + remotebuild="${remotebuildtag}" if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" - # Checks if remotebuildversion variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + # Checks if remotebuild variable has been set. + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_fail "Checking remote build: ${remotelocation}" fn_script_log_fail "Checking remote build" core_exit.sh @@ -70,7 +69,7 @@ fn_update_remotebuild() { fi else # Checks if remotebuild variable has been set. - if [ -z "${remotebuildversion}" ] || [ "${remotebuildversion}" == "null" ]; then + if [ -z "${remotebuild}" ] || [ "${remotebuild}" == "null" ]; then fn_print_failure "Unable to get remote build" fn_script_log_fail "Unable to get remote build" core_exit.sh @@ -81,35 +80,35 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" # Update has been found or force update. - if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + if [ "${localbuild}" != "${remotebuild}" ] || [ "${forceupdate}" == "1" ]; then # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi - fn_script_log_info "${localbuild} > ${remotebuildversion}" + fn_script_log_info "${localbuild} > ${remotebuild}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -144,26 +143,26 @@ fn_update_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuild}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi - echo -en "\n" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" - fn_script_log_info "Remote build: ${remotebuildversion}" + fn_script_log_info "Remote build: ${remotebuild}" if [ -n "${branch}" ]; then fn_script_log_info "Branch: ${branch}" fi if [ -f "${rootdir}/.dev-debug" ]; then - echo -e "Remote build info" - echo -e "* apiurl: ${apiurl}" - echo -e "* remotebuildfilename: ${remotebuildfilename}" - echo -e "* remotebuildurl: ${remotebuildurl}" - echo -e "* remotebuildversion: ${remotebuildversion}" + fn_print_nl "Remote build info" + fn_print_nl "* apiurl: ${apiurl}" + fn_print_nl "* remotebuildfilename: ${remotebuildfilename}" + fn_print_nl "* remotebuildurl: ${remotebuildurl}" + fn_print_nl "* remotebuild: ${remotebuild}" fi fi } @@ -171,12 +170,6 @@ fn_update_compare() { # The location where the builds are checked and downloaded. remotelocation="github.com" -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_fail_nl "jq is not installed" - fn_script_log_fail "jq is not installed" - core_exit.sh -fi - if [ "${firstcommandname}" == "INSTALL" ]; then fn_update_remotebuild fn_update_dl