diff --git a/src/commandline.sh b/src/commandline.sh index 7151594..baab2e2 100644 --- a/src/commandline.sh +++ b/src/commandline.sh @@ -33,6 +33,7 @@ parse_commandline_args() { UPDATE_CHANNEL=develop forceUpdateCheck=1 echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE" + update_logto shift ;; -p | --production) @@ -40,6 +41,7 @@ parse_commandline_args() { UPDATE_CHANNEL=master forceUpdateCheck=1 echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE" + update_logto shift ;; -u | --update) @@ -60,6 +62,7 @@ parse_commandline_args() { warn "Switching to $UPDATE_CHANNEL_CANDIDATE update channel" UPDATE_CHANNEL="$UPDATE_CHANNEL_CANDIDATE" echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE" + update_logto shift ;; --) diff --git a/src/lib.sh b/src/lib.sh index 9cf12c6..3a13bca 100644 --- a/src/lib.sh +++ b/src/lib.sh @@ -7,7 +7,8 @@ REQUIRED_NODE_VERSION=18.0.0 REQUIRED_DOTENV_VERSION=1.3.0 -LOGTO=/srv/nightscout/data/debug.log +LOGTO=/dev/null +DEBUG_LOG_FILE=/srv/nightscout/data/debug.log NIGHTSCOUT_ROOT_DIR=/srv/nightscout CONFIG_ROOT_DIR=/srv/nightscout/config DATA_ROOT_DIR=/srv/nightscout/data diff --git a/src/logic_app.sh b/src/logic_app.sh index e051f33..3acf4c0 100644 --- a/src/logic_app.sh +++ b/src/logic_app.sh @@ -2,6 +2,14 @@ # APP LOGIC #======================================= +update_logto() { + if [[ "$UPDATE_CHANNEL" == "develop" ]]; then + LOGTO="$DEBUG_LOG_FILE" + else + LOGTO=/dev/null + fi +} + get_td_domain() { local MHOST=$(hostname) if ! [[ "$MHOST" =~ [a-zA-Z]{2,16}[0-9]{3} ]]; then @@ -29,6 +37,7 @@ load_update_channel() { if [[ -f $UPDATE_CHANNEL_FILE ]]; then UPDATE_CHANNEL=$(cat "$UPDATE_CHANNEL_FILE") msgok "Loaded update channel: $UPDATE_CHANNEL" + update_logto fi } diff --git a/src/logic_update.sh b/src/logic_update.sh index 7eaf875..a1fafd0 100644 --- a/src/logic_update.sh +++ b/src/logic_update.sh @@ -28,12 +28,12 @@ download_file() { local url=$(get_url_branch "$branch" "$path") - if ! curl -fsSL -o "$target" "$url"; then + if ! curl -fsSL -o "$target" "$url" 2>>"$LOGTO"; then if [[ -z "$GITHUB_UNAVAILABLE" ]]; then mark_github_unavailable url=$(get_url_branch "$branch" "$path") ohai "GitHub failed, retrying with Gitea ($label)..." - curl -fsSL -o "$target" "$url" + curl -fsSL -o "$target" "$url" 2>>"$LOGTO" else return 1 fi @@ -91,13 +91,13 @@ download_updates() { ohai "Downloading updated scripts and config files" local url=$(get_url "updated") - local onlineUpdated=$(curl -fsSL "$url") + local onlineUpdated=$(curl -fsSL "$url" 2>>"$LOGTO") if [[ -z "$onlineUpdated" && -z "$GITHUB_UNAVAILABLE" ]]; then mark_github_unavailable url=$(get_url "updated") ohai "GitHub failed, retrying with Gitea (update check)..." - onlineUpdated=$(curl -fsSL "$url") + onlineUpdated=$(curl -fsSL "$url" 2>>"$LOGTO") fi if [ ! "$onlineUpdated" == "" ]; then @@ -122,13 +122,13 @@ download_if_needed() { echo "$timestampNow" >"$UPDATES_DIR/timestamp" ohai "Checking if new version is available..." local url=$(get_url "updated") - local onlineUpdated=$(curl -fsSL "$url") + local onlineUpdated=$(curl -fsSL "$url" 2>>"$LOGTO") if [[ -z "$onlineUpdated" && -z "$GITHUB_UNAVAILABLE" ]]; then mark_github_unavailable url=$(get_url "updated") ohai "GitHub failed, retrying with Gitea (version check)..." - onlineUpdated=$(curl -fsSL "$url") + onlineUpdated=$(curl -fsSL "$url" 2>>"$LOGTO") fi local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded")