From cfa873c483ad1b3ae5c82fcf3e9cf84cd1a2c27a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Aug 2025 22:24:26 +0000 Subject: [PATCH] feat: refactor update comparison output for consistency and clarity - Replaced direct echo statements with fn_print functions for uniformity in output formatting across multiple update scripts. - Ensured lockfile creation uses the correct syntax for variable expansion. - Moved lock file to the same location to ensure monitor doesnt reboot at the wrong time - Updated remote build information display to enhance readability and maintain consistency in logging. - Removed unnecessary echo commands to streamline the output process. --- .shellcheckrc | 2 +- lgsm/modules/check_last_update.sh | 1 + lgsm/modules/core_steamcmd.sh | 2 +- lgsm/modules/update_fctr.sh | 46 +++++++++++++------------- lgsm/modules/update_jk2.sh | 54 ++++++++++++++----------------- lgsm/modules/update_mc.sh | 52 +++++++++++++---------------- lgsm/modules/update_mcb.sh | 52 +++++++++++++---------------- lgsm/modules/update_mta.sh | 54 ++++++++++++++----------------- lgsm/modules/update_pmc.sh | 52 +++++++++++++---------------- lgsm/modules/update_ts3.sh | 52 +++++++++++++---------------- lgsm/modules/update_ut99.sh | 52 +++++++++++++---------------- lgsm/modules/update_vints.sh | 53 ++++++++++++++---------------- lgsm/modules/update_xnt.sh | 52 +++++++++++++---------------- 13 files changed, 236 insertions(+), 288 deletions(-) diff --git a/.shellcheckrc b/.shellcheckrc index 026ee646c..d16f69e0b 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1 +1 @@ -disable=SC2154 +disable=SC2154,SC2034 diff --git a/lgsm/modules/check_last_update.sh b/lgsm/modules/check_last_update.sh index 2686c6507..a68285344 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/core_steamcmd.sh b/lgsm/modules/core_steamcmd.sh index bf9790132..34cd294c5 100644 --- a/lgsm/modules/core_steamcmd.sh +++ b/lgsm/modules/core_steamcmd.sh @@ -239,6 +239,7 @@ fn_update_steamcmd_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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" diff --git a/lgsm/modules/update_fctr.sh b/lgsm/modules/update_fctr.sh index 3418c7424..95aa09a94 100644 --- a/lgsm/modules/update_fctr.sh +++ b/lgsm/modules/update_fctr.sh @@ -69,21 +69,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -93,7 +93,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -128,14 +128,14 @@ 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}${remotebuildversion}${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}" @@ -143,11 +143,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" fi fi } diff --git a/lgsm/modules/update_jk2.sh b/lgsm/modules/update_jk2.sh index 5fdd54c65..a96b0e9e0 100644 --- a/lgsm/modules/update_jk2.sh +++ b/lgsm/modules/update_jk2.sh @@ -66,21 +66,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -90,6 +90,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +125,14 @@ 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}${remotebuildversion}${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}" @@ -140,23 +140,17 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 a9be77576..49b6a7130 100644 --- a/lgsm/modules/update_mc.sh +++ b/lgsm/modules/update_mc.sh @@ -81,21 +81,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -105,7 +105,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +140,14 @@ 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}${remotebuildversion}${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}" @@ -155,11 +155,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 a8616c3b8..5b0669428 100644 --- a/lgsm/modules/update_mcb.sh +++ b/lgsm/modules/update_mcb.sh @@ -92,21 +92,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -116,7 +116,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +151,14 @@ 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}${remotebuildversion}${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}" @@ -166,11 +166,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 50a3fb895..964f1c474 100644 --- a/lgsm/modules/update_mta.sh +++ b/lgsm/modules/update_mta.sh @@ -39,7 +39,7 @@ 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}") + remotebuildversion="${remotebuildresponse}" if [ "${firstcommandname}" != "INSTALL" ]; then fn_print_dots "Checking remote build: ${remotelocation}" # Checks if remotebuildversion variable has been set. @@ -74,21 +74,21 @@ 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -98,6 +98,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +133,14 @@ 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}${remotebuildversion}${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}" @@ -148,11 +148,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 c38911d4e..395dfd725 100644 --- a/lgsm/modules/update_pmc.sh +++ b/lgsm/modules/update_pmc.sh @@ -91,21 +91,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -115,7 +115,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +150,14 @@ 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}${remotebuildversion}${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}" @@ -165,11 +165,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 e1917e5e1..a7e6b10a4 100644 --- a/lgsm/modules/update_ts3.sh +++ b/lgsm/modules/update_ts3.sh @@ -73,21 +73,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -97,7 +97,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +132,14 @@ 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}${remotebuildversion}${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}" @@ -147,11 +147,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 bdfb96f0b..cd1998bfb 100644 --- a/lgsm/modules/update_ut99.sh +++ b/lgsm/modules/update_ut99.sh @@ -67,21 +67,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -91,7 +91,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +126,14 @@ 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}${remotebuildversion}${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}" @@ -141,11 +141,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" 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 4021af11a..88686d1e2 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 @@ -74,21 +75,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -98,7 +99,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" if [ "${commandname}" == "UPDATE" ]; then - date +%s > "${lockdir}/last-updated.lock" + date +%s > "${lockdir:?}/last-updated.lock" unset updateonstart check_status.sh # If server stopped. @@ -133,14 +134,14 @@ 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}${remotebuildversion}${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}" @@ -148,11 +149,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" fi fi } @@ -160,12 +161,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 c00233aa7..eb5b5a627 100644 --- a/lgsm/modules/update_xnt.sh +++ b/lgsm/modules/update_xnt.sh @@ -85,21 +85,21 @@ fn_update_compare() { # 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}${remotebuildversion}${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 "* remotebuildversion: ${remotebuildversion}" 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}" @@ -109,7 +109,7 @@ fn_update_compare() { fn_script_log_info "${localbuild} > ${remotebuildversion}" 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,14 +144,14 @@ 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}${remotebuildversion}${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}" @@ -159,11 +159,11 @@ fn_update_compare() { 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 "* remotebuildversion: ${remotebuildversion}" fi fi } @@ -171,12 +171,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