From 67407f07c74458ee767a59acf662c440e1cb7e20 Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Tue, 6 Jan 2026 01:30:40 +0000 Subject: [PATCH] Fixed non-interactive cleanup --- install.sh | 452 +++++++++++++++++++++++++++++++++---------- src/logic_cleanup.sh | 22 +-- src/utils_console.sh | 4 +- updated | 2 +- 4 files changed, 359 insertions(+), 121 deletions(-) diff --git a/install.sh b/install.sh index f6865a0..fde4f0d 100755 --- a/install.sh +++ b/install.sh @@ -16,7 +16,7 @@ # This file is automatically generated. Do not modify it directly! # Instead, modify the source files in the src directory and run the build script! # -# Build time: 2026.01.05 22:19 +# Build time: 2026.01.06 01:30 @@ -29,7 +29,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 @@ -61,7 +62,9 @@ DISK_CRITICAL_WARNING=104857600 # == 100 MiB DISK_CRITICAL_MAIL=604800 # == 7 days in seconds DOCKER_DOWN_MAIL=604800 # == 7 days in seconds SCRIPT_VERSION="1.10.2" #auto-update -SCRIPT_BUILD_TIME="2026.01.05" #auto-update +SCRIPT_BUILD_TIME="2026.01.06" #auto-update +FORCE_DEBUG_LOG="" +NONINTERACTIVE_MODE="false" #======================================= # DOWNLOAD CONFIG @@ -69,7 +72,7 @@ SCRIPT_BUILD_TIME="2026.01.05" #auto-update GITHUB_BASE_URL="https://raw.githubusercontent.com/dlvoy/mikrus-installer" GITEA_BASE_URL="https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch" -GITHUB_UNAVAILABLE="" # Empty string = GitHub is available, set to "1" if GitHub fails +GITHUB_UNAVAILABLE="" # Empty string = GitHub is available, set to "1" if GitHub fails #======================================= @@ -166,6 +169,7 @@ emoji_check="\U2705" emoji_ok="\U1F197" emoji_err="\U274C" emoji_note="\U1F4A1" +emoji_debug="\U1F4DC" uni_bullet=" $(printf '\u2022') " uni_copyright="$(printf '\uA9\uFE0F')" @@ -215,31 +219,80 @@ chomp() { } ohai() { - printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "==> %s\n" "$(shell_join "$@")" + else + printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" + fi } msgok() { - # shellcheck disable=SC2059 - printf "$emoji_ok $1\n" + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "$1\n" + else + # shellcheck disable=SC2059 + printf "$emoji_ok $1\n" + fi } msgnote() { - # shellcheck disable=SC2059 - printf "$emoji_note $1\n" + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "$1\n" + else + # shellcheck disable=SC2059 + printf "$emoji_note $1\n" + fi } msgcheck() { - # shellcheck disable=SC2059 - printf "$emoji_check $1\n" + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "$1\n" + else + # shellcheck disable=SC2059 + printf "$emoji_check $1\n" + fi } msgerr() { - # shellcheck disable=SC2059 - printf "$emoji_err $1\n" + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "$1\n" + else + # shellcheck disable=SC2059 + printf "$emoji_err $1\n" + fi +} + +msgdebug() { + if [[ "$UPDATE_CHANNEL" == "develop" || "$FORCE_DEBUG_LOG" == "1" ]]; then + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "$1\n" + else + printf "$emoji_debug $1\n" + fi + fi +} + +hline() { + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + printf "%s\n" "-------------------------------------------------------" + else + printf "${tty_bold}%s${tty_reset}\n" "-------------------------------------------------------" + fi } warn() { - printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2 + if [ "$NONINTERACTIVE_MODE" = "true" ]; then + # shellcheck disable=SC2059 + printf "Warning: %s\n" "$(chomp "$1")" >&2 + else + printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2 + fi } @@ -612,13 +665,48 @@ event_count() { else local eventsJSON=$(dotenv-tool parse -r -f "${EVENTS_DB}") local eventsKeysStr=$(echo "${eventsJSON}" | jq -r ".values | keys[]") - local eventsCount=${#eventsKeysStr} - if ((eventsCount > 0)); then - mapfile -t eventList < <(echo "${eventsKeysStr}") - echo "${#eventList[@]}" - else + + if [[ -z "$eventsKeysStr" ]]; then echo "0" + return fi + + mapfile -t eventList < <(echo "${eventsKeysStr}") + local count=0 + local processedNames=() + + for eventId in "${eventList[@]}"; do + # Parse eventName and eventTail (suffix) + mapfile -t -d '_' eventIdSplit <<<"${eventId}" + local eventTail=$(echo "${eventIdSplit[-1]}" | tr -d '\n') + unset "eventIdSplit[-1]" + printf -v eventBase '%s_' "${eventIdSplit[@]}" + local eventName="${eventBase%_}" + if [ ${#eventIdSplit[@]} -eq 0 ]; then + eventName="$eventTail" + eventTail="" + fi + + if [[ "$eventTail" == "start" ]] || [[ "$eventTail" == "end" ]]; then + # Group start/end as one + if [[ ! " ${processedNames[*]} " =~ [[:space:]]${eventName}[[:space:]] ]]; then + processedNames+=("${eventName}") + ((count++)) + fi + elif [[ "$eventTail" == "set" ]]; then + ((count++)) + elif [[ "$eventTail" == "clear" ]]; then + # Count clear only if set exists + local hasSet=$(echo "$eventsJSON" | jq -r ".values.${eventName}_set") + if [[ "$hasSet" != "null" ]]; then + ((count++)) + fi + else + # Lone event (no suffix) + ((count++)) + fi + done + echo "$count" fi } @@ -663,10 +751,16 @@ event_list() { fi else if [[ "$eventTail" == "set" ]] || [[ "$eventTail" == "clear" ]]; then + local startVar=$(echo "$eventsJSON" | jq -r ".values.${eventName}_set") + local endVar=$(echo "$eventsJSON" | jq -r ".values.${eventName}_clear") + + # Filter out orphaned clear events (clear exists but set does not) + if [[ "$startVar" == "null" ]] && [[ "$endVar" != "null" ]]; then + continue + fi + if [[ ! " ${namesTab[*]} " =~ [[:space:]]${eventName}[[:space:]] ]]; then namesTab+=("${eventName}") - local startVar=$(echo "$eventsJSON" | jq -r ".values.${eventName}_set") - local endVar=$(echo "$eventsJSON" | jq -r ".values.${eventName}_clear") local joinedVar="od: $startVar zdjęto: $endVar" local fixedVar=$(echo "$joinedVar" | sed -E -e "s/ ?(od|zdjęto): null ?//g") if [[ "$fixedVar" =~ od: ]] && [[ "$fixedVar" =~ zdjęto: ]]; then @@ -1376,7 +1470,9 @@ get_watchdog_status() { } watchdog_check() { - echo "Nightscout Watchdog mode" + echo "---------------------------" + echo " Nightscout Watchdog mode" + echo "---------------------------" WATCHDOG_LAST_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") WATCHDOG_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") @@ -1463,7 +1559,7 @@ watchdog_check() { if [ "$WATCHDOG_STATUS" = "detection_failed" ]; then { - echo "----------------------------------------------------------------" + hline echo "[$WATCHDOG_TIME] Unknown server failure:" echo "CONTAINERS:" docker stats --no-stream @@ -1531,6 +1627,7 @@ watchdog_check() { } + #======================================= # CLEANUP LOGIC #======================================= @@ -1599,6 +1696,39 @@ do_cleanup_app_logs() { rm -f "$WATCHDOG_CRON_LOG" } +cleanup_stats() { + local spaceInfo=$(get_space_info) + local remainingTxt=$(echo "$spaceInfo" | awk '{print $3}' | numfmt --to iec-i --suffix=B) + local totalTxt=$(echo "$spaceInfo" | awk '{print $2}' | numfmt --to iec-i --suffix=B) + local percTxt=$(echo "$spaceInfo" | awk '{print $4}') + local fixedPerc=$percTxt + + local nowB=$(echo "$spaceInfo" | awk '{print $3}') + local lastTimeB=$(echo "$lastTimeSpaceInfo" | awk '{print $3}') + local savedB=$((nowB - lastTimeB)) + local savedTxt=$(echo "$savedB" | numfmt --to iec-i --suffix=B) + + if ((savedB < 1)); then + savedTxt="---" + fi + + hline + printf " Dostępne: %s\n Zwolniono: %s\n Zajęte: %s (z %s)\n" "${remainingTxt}" "${savedTxt}" "${fixedPerc}" "${totalTxt}" + hline +} + +do_cleanup_all() { + echo "Sprzątanie..." + lastTimeSpaceInfo=$(get_space_info) + hline + do_cleanup_container_logs + do_cleanup_sys + do_cleanup_docker + do_cleanup_db + do_cleanup_diagnostics + cleanup_stats +} + #======================================= @@ -1618,36 +1748,83 @@ source_admin() { # UPGRADE #======================================= +mark_github_unavailable() { + GITHUB_UNAVAILABLE="1" +} + +get_url_branch() { + local branch="$1" + local path="$2" + if [[ -n "$GITHUB_UNAVAILABLE" ]]; then + echo "${GITEA_BASE_URL}/${branch}/${path}" + else + echo "${GITHUB_BASE_URL}/${branch}/${path}" + fi +} + +get_url() { + get_url_branch "$UPDATE_CHANNEL" "$1" +} + +download_file() { + local label="$1" + local target="$2" + local path="$3" + local branch="${4:-$UPDATE_CHANNEL}" + + local url=$(get_url_branch "$branch" "$path") + + 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" 2>>"$LOGTO" + else + return 1 + fi + fi +} + download_if_not_exists() { - if [[ -f $2 ]]; then - msgok "Found $1" + local label="$1" + local target="$2" + local path="$3" + local branch="${4:-$UPDATE_CHANNEL}" + + if [[ -f "$target" ]]; then + msgok "Found $label" else - ohai "Downloading $1..." - curl -fsSL -o "$2" "$3" - msgcheck "Downloaded $1" + ohai "Downloading $label..." + if download_file "$label" "$target" "$path" "$branch"; then + msgcheck "Downloaded $label" + else + msgerr "Failed to download $label" + return 1 + fi fi } download_conf() { - download_if_not_exists "deployment config" "$ENV_FILE_DEP" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/templates/deployment.env" - download_if_not_exists "nightscout config" "$ENV_FILE_NS" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/templates/nightscout.env" - download_if_not_exists "docker compose file" "$DOCKER_COMPOSE_FILE" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/templates/docker-compose.yml" - download_if_not_exists "profanity database" "$PROFANITY_DB_FILE" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/profanity.db" - download_if_not_exists "reservation database" "$RESERVED_DB_FILE" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/reserved.db" + download_if_not_exists "deployment config" "$ENV_FILE_DEP" "templates/deployment.env" + download_if_not_exists "nightscout config" "$ENV_FILE_NS" "templates/nightscout.env" + download_if_not_exists "docker compose file" "$DOCKER_COMPOSE_FILE" "templates/docker-compose.yml" + download_if_not_exists "profanity database" "$PROFANITY_DB_FILE" "templates/profanity.db" "profanity" + download_if_not_exists "reservation database" "$RESERVED_DB_FILE" "templates/reserved.db" "profanity" } download_tools() { - download_if_not_exists "update stamp" "$UPDATES_DIR/updated" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/updated" + download_if_not_exists "update stamp" "$UPDATES_DIR/updated" "updated" - if ! [[ -f $TOOL_FILE ]]; then - download_if_not_exists "nightscout-tool file" "$TOOL_FILE" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/install.sh" + if ! [[ -f "$TOOL_FILE" ]]; then + download_if_not_exists "nightscout-tool file" "$TOOL_FILE" "install.sh" local timestamp=$(date +%s) echo "$timestamp" >"$UPDATES_DIR/timestamp" else msgok "Found nightscout-tool" fi - if ! [[ -f $TOOL_LINK ]]; then + if ! [[ -f "$TOOL_LINK" ]]; then ohai "Linking nightscout-tool" ln -s "$TOOL_FILE" "$TOOL_LINK" fi @@ -1658,14 +1835,24 @@ download_tools() { download_updates() { ohai "Downloading updated scripts and config files" - local onlineUpdated="$(curl -fsSL "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/updated")" + + local url=$(get_url "updated") + 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" 2>>"$LOGTO") + fi + if [ ! "$onlineUpdated" == "" ]; then - curl -fsSL -o "$UPDATES_DIR/install.sh" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/install.sh" - curl -fsSL -o "$UPDATES_DIR/deployment.env" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/templates/deployment.env" - curl -fsSL -o "$UPDATES_DIR/nightscout.env" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/templates/nightscout.env" - curl -fsSL -o "$UPDATES_DIR/docker-compose.yml" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/templates/docker-compose.yml" - curl -fsSL -o "$PROFANITY_DB_FILE" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/profanity.db" - curl -fsSL -o "$RESERVED_DB_FILE" "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/reserved.db" + download_file "install script" "$UPDATES_DIR/install.sh" "install.sh" + download_file "deployment info" "$UPDATES_DIR/deployment.env" "templates/deployment.env" + download_file "nightscout info" "$UPDATES_DIR/nightscout.env" "templates/nightscout.env" + download_file "docker compose" "$UPDATES_DIR/docker-compose.yml" "templates/docker-compose.yml" + download_file "profanity db" "$PROFANITY_DB_FILE" "templates/profanity.db" "profanity" + download_file "reserved db" "$RESERVED_DB_FILE" "templates/reserved.db" "profanity" else onlineUpdated="error" fi @@ -1680,7 +1867,16 @@ download_if_needed() { if (((timestampNow - lastCheck) > updateCheck)) || [ "$lastDownload" == "" ] || [ "$lastDownload" == "error" ] || ((forceUpdateCheck == 1)) || [ $# -eq 1 ]; then echo "$timestampNow" >"$UPDATES_DIR/timestamp" ohai "Checking if new version is available..." - local onlineUpdated="$(curl -fsSL "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/updated")" + local url=$(get_url "updated") + 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" 2>>"$LOGTO") + fi + local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded") if [ "$onlineUpdated" == "$lastDownload" ] && ((forceUpdateCheck == 0)); then msgok "Latest update already downloaded" @@ -1692,40 +1888,6 @@ download_if_needed() { fi } -update_background_check() { - download_if_needed - - local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "") - local updateInstalled=$(read_or_default "$UPDATES_DIR/updated" "") - - if [ ! "$lastDownload" == "$updateInstalled" ] && [ ! "$lastDownload" == "" ] && [ ! "$lastDownload" == "error" ]; then - echo "Update needed" - local lastCalled=$(get_since_last_time "update_needed") - if ((lastCalled == -1)) || ((lastCalled > UPDATE_MAIL)); then - set_last_time "update_needed" - echo "Sending mail to user - tool update needed" - { - echo "✨ Na Twoim serwerze mikr.us z Nightscoutem można zaktualizować narzędzie nightscout-tool!" - echo " " - echo "🐕 Watchdog wykrył że dostępna jest nowa aktualizacja nightscout-tool." - echo "Na Twoim serwerze zainstalowana jest starsza wersja narzędzia - zaktualizuj go by poprawić stabilność systemu i uzyskać dostęp do nowych funkcji." - echo " " - echo "Aby zaktualizować narzędzie:" - echo " " - echo "1. Zaloguj się do panelu administracyjnego mikrusa i zaloguj się do WebSSH:" - echo " https://mikr.us/panel/?a=webssh" - echo " " - echo "2. Uruchom narzędzie komendą:" - echo " nightscout-tool" - echo " " - echo "3. Potwierdź naciskając przycisk:" - echo " 【 Aktualizacja 】" - echo " " - } | pusher "✨_Na_Twoim_serwerze_Nightscout_dostępna_jest_aktualizacja" - fi - fi -} - #======================================= @@ -1864,6 +2026,14 @@ retry_diagnostics() { # APP LOGIC #======================================= +update_logto() { + if [[ "$UPDATE_CHANNEL" == "develop" || "$FORCE_DEBUG_LOG" == "1" ]]; 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 @@ -1890,7 +2060,7 @@ get_domain_status() { load_update_channel() { if [[ -f $UPDATE_CHANNEL_FILE ]]; then UPDATE_CHANNEL=$(cat "$UPDATE_CHANNEL_FILE") - msgok "Loaded update channel: $UPDATE_CHANNEL" + update_logto fi } @@ -1900,6 +2070,15 @@ startup_version() { msgnote "build ${updateInstalled}" msgnote "$uni_copyright 2023-2026 Dominik Dzienia" msgnote "Licensed under CC BY-NC-ND 4.0" + if [[ -f $UPDATE_CHANNEL_FILE ]]; then + msgok "Loaded update channel: $UPDATE_CHANNEL" + fi +} + +startup_debug() { + if [[ "$UPDATE_CHANNEL" == "develop" || "$FORCE_DEBUG_LOG" == "1" ]]; then + msgdebug "Debug logging enabled - see: $DEBUG_LOG_FILE" + fi } @@ -2337,16 +2516,78 @@ mail_restart_needed() { } | pusher "🛟_Twoj_serwer_Nightscout_potrzebuje_ręcznego_restartu!" } +update_background_check() { + download_if_needed + + local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "") + local updateInstalled=$(read_or_default "$UPDATES_DIR/updated" "") + + if [ ! "$lastDownload" == "$updateInstalled" ] && [ ! "$lastDownload" == "" ] && [ ! "$lastDownload" == "error" ]; then + echo "Update needed" + local lastCalled=$(get_since_last_time "update_needed") + if ((lastCalled == -1)) || ((lastCalled > UPDATE_MAIL)); then + set_last_time "update_needed" + echo "Sending mail to user - tool update needed" + { + echo "✨ Na Twoim serwerze mikr.us z Nightscoutem można zaktualizować narzędzie nightscout-tool!" + echo " " + echo "🐕 Watchdog wykrył że dostępna jest nowa aktualizacja nightscout-tool." + echo "Na Twoim serwerze zainstalowana jest starsza wersja narzędzia - zaktualizuj go by poprawić stabilność systemu i uzyskać dostęp do nowych funkcji." + echo " " + echo "Aby zaktualizować narzędzie:" + echo " " + echo "1. Zaloguj się do panelu administracyjnego mikrusa i zaloguj się do WebSSH:" + echo " https://mikr.us/panel/?a=webssh" + echo " " + echo "2. Uruchom narzędzie komendą:" + echo " nightscout-tool" + echo " " + echo "3. Potwierdź naciskając przycisk:" + echo " 【 Aktualizacja 】" + echo " " + } | pusher "✨_Na_Twoim_serwerze_Nightscout_dostępna_jest_aktualizacja" + fi + fi +} + + #======================================= # COMMANDLINE PARSER #======================================= +help() { + cat <"$UPDATE_CHANNEL_FILE" + update_logto shift ;; -p | --production) @@ -2380,6 +2630,7 @@ parse_commandline_args() { UPDATE_CHANNEL=master forceUpdateCheck=1 echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE" + update_logto shift ;; -u | --update) @@ -2400,8 +2651,18 @@ 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 ;; + -s | --cleanup) + NONINTERACTIVE_MODE=true + do_cleanup_all + exit 0 + ;; + -h | --help) + help + exit 0 + ;; --) shift break @@ -2411,6 +2672,8 @@ parse_commandline_args() { done if [ "$WATCHDOGMODE" = "true" ]; then + startup_version + startup_debug watchdog_check fi @@ -2440,7 +2703,7 @@ show_watchdog_logs() { { echo "Ostatnie uruchomienie watchdoga:" get_watchdog_age_string - echo "-------------------------------------------------------" + hline if [[ -f $WATCHDOG_LOG_FILE ]]; then echo "Statusy ostatnich przebiegów watchdoga:" @@ -2448,7 +2711,7 @@ show_watchdog_logs() { else echo "Brak logów z ostatnich przebiegów watchdoga" fi - echo "-------------------------------------------------------" + hline if [[ -f $WATCHDOG_CRON_LOG ]]; then echo "Log ostatniego przebiegu watchdoga:" @@ -3209,26 +3472,6 @@ install_or_menu() { -#======================================= -# ACTIONS AND STEPS -#======================================= - - - - - - - - - - - - - - - - - @@ -3237,8 +3480,9 @@ install_or_menu() { # MAIN SCRIPT #======================================= -startup_version parse_commandline_args "$@" +startup_version +startup_debug # check_interactive check_git check_docker diff --git a/src/logic_cleanup.sh b/src/logic_cleanup.sh index 134fbae..33e0eb8 100644 --- a/src/logic_cleanup.sh +++ b/src/logic_cleanup.sh @@ -71,7 +71,7 @@ cleanup_stats() { local remainingTxt=$(echo "$spaceInfo" | awk '{print $3}' | numfmt --to iec-i --suffix=B) local totalTxt=$(echo "$spaceInfo" | awk '{print $2}' | numfmt --to iec-i --suffix=B) local percTxt=$(echo "$spaceInfo" | awk '{print $4}') - local fixedPerc=${percTxt/[%]/=} + local fixedPerc=$percTxt local nowB=$(echo "$spaceInfo" | awk '{print $3}') local lastTimeB=$(echo "$lastTimeSpaceInfo" | awk '{print $3}') @@ -82,25 +82,19 @@ cleanup_stats() { savedTxt="---" fi - local statusTitle="\n$(center_multiline 45 "$( - pad_multiline \ - " Dostępne: ${remainingTxt}" \ - "\n Zwolniono: ${savedTxt}" \ - "\n Zajęte: ${fixedPerc} (z ${totalTxt})" - )")\n" - - hline - echo "${statusTitle/=/%}" - hline + hline + printf " Dostępne: %s\n Zwolniono: %s\n Zajęte: %s (z %s)\n" "${remainingTxt}" "${savedTxt}" "${fixedPerc}" "${totalTxt}" + hline } do_cleanup_all() { - echo "Cleanup" - hline + echo "Sprzątanie..." + lastTimeSpaceInfo=$(get_space_info) + hline do_cleanup_container_logs do_cleanup_sys do_cleanup_docker do_cleanup_db do_cleanup_diagnostics cleanup_stats -} \ No newline at end of file +} diff --git a/src/utils_console.sh b/src/utils_console.sh index 32bf81b..7af4c8a 100644 --- a/src/utils_console.sh +++ b/src/utils_console.sh @@ -78,9 +78,9 @@ msgdebug() { hline() { if [ "$NONINTERACTIVE_MODE" = "true" ]; then - printf "-------------------------------------------------------\n" + printf "%s\n" "-------------------------------------------------------" else - printf "${tty_bold}-------------------------------------------------------${tty_reset}\n" + printf "${tty_bold}%s${tty_reset}\n" "-------------------------------------------------------" fi } diff --git a/updated b/updated index 4471889..362aea8 100644 --- a/updated +++ b/updated @@ -1 +1 @@ -2026-01-05T21:19:43.286Z \ No newline at end of file +2026-01-06T01:30:06.751Z \ No newline at end of file