Code cleanup

develop
Dominik Dzienia 3 weeks ago
parent 31ce3ccc4e
commit 3994ed2165

@ -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.06 01:30
# Build time: 2026.01.06 15:22
@ -65,6 +65,7 @@ SCRIPT_VERSION="1.10.2" #auto-update
SCRIPT_BUILD_TIME="2026.01.06" #auto-update
FORCE_DEBUG_LOG=""
NONINTERACTIVE_MODE="false"
EXECUTED="true"
#=======================================
# DOWNLOAD CONFIG
@ -75,6 +76,10 @@ 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
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SETUP
#=======================================
@ -142,6 +147,11 @@ fi
# shellcheck disable=SC2148
# shellcheck disable=SC2155
# shellcheck disable=SC2034
#=======================================
# FORMATERS
#=======================================
@ -200,6 +210,11 @@ uni_watchdog_ok="$(printf '\U1F415') Nightscout działa"
# shellcheck disable=SC2148
# shellcheck disable=SC2155
# shellcheck disable=SC2059
#
#=======================================
# CONSOLE OUTPUT UTILS
#=======================================
@ -214,6 +229,16 @@ shell_join() {
done
}
all_join() {
local arg
printf "$1"
shift
for arg in "$@"; do
printf " "
printf "${arg}"
done
}
chomp() {
printf "%s" "${1/"$'\n'"/}"
}
@ -228,7 +253,8 @@ ohai() {
}
msgprint() {
printf "%s\n" "$(shell_join "$@")"
#shellcheck disable=SC2046
printf $(all_join "$@")
}
msgok() {
@ -301,6 +327,10 @@ warn() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# UTILS
#=======================================
@ -371,6 +401,10 @@ read_or_default() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# STRING UTILS
#=======================================
@ -469,6 +503,10 @@ pad_multiline() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SCREEN DIALOGS
#=======================================
@ -590,6 +628,10 @@ MIKRUS_APIKEY=''
MIKRUS_HOST=''
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# EVENTS MARKERS LOGIC
#=======================================
@ -664,7 +706,7 @@ event_label() {
}
event_count() {
if [ ! -f ${EVENTS_DB} ]; then
if [ ! -f "${EVENTS_DB}" ]; then
echo "0"
else
local eventsJSON=$(dotenv-tool parse -r -f "${EVENTS_DB}")
@ -715,7 +757,7 @@ event_count() {
}
event_list() {
if [ ! -f ${EVENTS_DB} ]; then
if [ ! -f "${EVENTS_DB}" ]; then
echo "Nie odnotowano zdarzeń"
else
local eventsJSON=$(dotenv-tool parse -r -f "${EVENTS_DB}")
@ -853,6 +895,11 @@ get_events_status() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SETUP
#=======================================
@ -1073,6 +1120,10 @@ uninstall_cron() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SETUP CHECKS
#=======================================
@ -1178,6 +1229,11 @@ check_diceware() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# PATCH OLDER CONFIGS
#=======================================
@ -1198,6 +1254,8 @@ patch_docker_compose() {
if grep -q "bitnami/mongodb" "$DOCKER_COMPOSE_FILE"; then
ohai "Patching docker-compose.yml MongoDB image..."
# Replace bitnami/mongodb with official mongo image
# This is BY PURPOSE left as var in yaml - as it is replaced wit env vars
# shellcheck disable=SC2016
sed -i -E 's|image:\s*"*(bitnami/)?mongodb:.*"|image: "mongo:${NS_MONGODB_TAG}"|g' "$DOCKER_COMPOSE_FILE"
patched=1
fi
@ -1224,6 +1282,11 @@ patch_docker_compose() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# DOCKER
#=======================================
@ -1238,12 +1301,21 @@ get_docker_status() {
}
install_containers() {
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE up --no-recreate -d >>"$LOGTO" 2>&1
if [[ "$FORCE_DEBUG_LOG" == "1" && "$NONINTERACTIVE_MODE" = "true" ]]; then
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up --no-recreate -d
else
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up --no-recreate -d >>"$LOGTO" 2>&1
fi
}
update_containers() {
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE pull >>"$LOGTO" 2>&1
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE up -d >>"$LOGTO" 2>&1
if [[ "$FORCE_DEBUG_LOG" == "1" && "$NONINTERACTIVE_MODE" = "true" ]]; then
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" pull
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up -d
else
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" pull >>"$LOGTO" 2>&1
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up -d >>"$LOGTO" 2>&1
fi
}
install_containers_progress() {
@ -1254,7 +1326,11 @@ install_containers_progress() {
}
uninstall_containers() {
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE down >>"$LOGTO" 2>&1
if [[ "$FORCE_DEBUG_LOG" == "1" && "$NONINTERACTIVE_MODE" = "true" ]]; then
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" down
else
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" down >>"$LOGTO" 2>&1
fi
}
uninstall_containers_progress() {
@ -1311,6 +1387,10 @@ get_container_status_code() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# APP
#=======================================
@ -1322,6 +1402,10 @@ get_space_info() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# WATCHDOG LOGIC
#=======================================
@ -1632,6 +1716,10 @@ watchdog_check() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# CLEANUP LOGIC
#=======================================
@ -1729,12 +1817,15 @@ do_cleanup_all() {
do_cleanup_sys
do_cleanup_docker
do_cleanup_db
do_cleanup_diagnostics
cleanup_stats
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# CONFIGURATION
#=======================================
@ -1748,6 +1839,11 @@ source_admin() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# UPGRADE
#=======================================
@ -1892,6 +1988,152 @@ download_if_needed() {
fi
}
download_update_forced() {
local timestampNow=$(date +%s)
local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "")
echo "$timestampNow" >"$UPDATES_DIR/timestamp"
ohai "Downloading updates..."
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
if [ "$onlineUpdated" == "$lastDownload" ]; then
msgdebug "Downloaded update will be the same as last downloaded"
fi
# we downlaod it anyway
download_updates
}
#shellcheck disable=SC2154
do_update_tool() {
download_update_forced
local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "???")
local updateInstalled=$(read_or_default "$UPDATES_DIR/updated" "???")
if [ "$lastDownload" == "error" ]; then
msgerr "Aktualizacja niemożliwa"
msgerr "Nie można w tej chwili aktualizować narzędzia.${TL}Spróbuj ponownie później.${NL}Jeśli problem nie ustąpi - sprawdź konfigurację kanału aktualizacji"
else
if [ "$UPDATE_CHANNEL" == "master" ] && [[ "$lastDownload" < "$updateInstalled" ]]; then
warn "Downgrade na produkcyjnym kanale aktualizacji!"
fi
local changed=0
local redeploy=0
local instOnlineVer=$(extract_version "$(<"$UPDATES_DIR/install.sh")")
local depEnvOnlineVer=$(extract_version "$(<"$UPDATES_DIR/deployment.env")")
local nsEnvOnlineVer=$(extract_version "$(<"$UPDATES_DIR/nightscout.env")")
local compOnlineVer=$(extract_version "$(<"$UPDATES_DIR/docker-compose.yml")")
local instLocalVer=$(extract_version "$(<"$TOOL_FILE")")
local depEnvLocalVer=$(extract_version "$(<"$ENV_FILE_DEP")")
local nsEnvLocalVer=$(extract_version "$(<"$ENV_FILE_NS")")
local compLocalVer=$(extract_version "$(<"$DOCKER_COMPOSE_FILE")")
local msgInst="$(printf "\U1F7E2") $instLocalVer"
local msgDep="$(printf "\U1F7E2") $depEnvLocalVer"
local msgNs="$(printf "\U1F7E2") $nsEnvLocalVer"
local msgComp="$(printf "\U1F7E2") $compLocalVer"
if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then
changed=$((changed + 1))
msgInst="$(printf "\U1F534") $instLocalVer $(printf "\U27A1") $instOnlineVer"
fi
if ! [ "$depEnvLocalVer" == "$depEnvOnlineVer" ]; then
changed=$((changed + 1))
redeploy=$((redeploy + 1))
msgDep="$(printf "\U1F534") $depEnvLocalVer $(printf "\U27A1") $depEnvOnlineVer"
fi
if ! [ "$nsEnvLocalVer" == "$nsEnvOnlineVer" ]; then
changed=$((changed + 1))
redeploy=$((redeploy + 1))
msgNs="$(printf "\U1F534") $nsEnvLocalVer $(printf "\U27A1") $nsEnvOnlineVer"
fi
if ! [ "$compLocalVer" == "$compOnlineVer" ]; then
changed=$((changed + 1))
redeploy=$((redeploy + 1))
msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer"
fi
local okTxt=""
if [ "$redeploy" -gt 0 ]; then
okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}"
fi
local versionMsg="${TL}Build: ${updateInstalled}"
if [ ! "$lastDownload" == "$updateInstalled" ]; then
versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")"
fi
hline
echo -e "Aktualizacja plików:" "${versionMsg}" \
"$(
pad_multiline \
"${TL}${uni_bullet}Skrypt instalacyjny: $msgInst" \
"${NL}${uni_bullet}Konfiguracja deploymentu: $msgDep" \
"${NL}${uni_bullet}Konfiguracja Nightscout: $msgNs" \
"${NL}${uni_bullet}Kompozycja usług: $msgComp${NL}"
)" \
"$okTxt"
hline
clear_last_time "update_needed"
if [ "$redeploy" -gt 0 ]; then
ohai "Redeploy - uninstalling containers"
uninstall_containers
fi
if ! [ "$compOnlineVer" == "$compLocalVer" ]; then
ohai "Updating $DOCKER_COMPOSE_FILE"
cp -fr "$UPDATES_DIR/docker-compose.yml" "$DOCKER_COMPOSE_FILE"
fi
if ! [ "$depEnvLocalVer" == "$depEnvOnlineVer" ]; then
ohai "Updating $ENV_FILE_DEP"
dotenv-tool -pr -o "$ENV_FILE_DEP" -i "$UPDATES_DIR/deployment.env" "$ENV_FILE_DEP"
fi
if ! [ "$nsEnvLocalVer" == "$nsEnvOnlineVer" ]; then
ohai "Updating $ENV_FILE_NS"
dotenv-tool -pr -o "$ENV_FILE_NS" -i "$UPDATES_DIR/deployment.env" "$ENV_FILE_NS"
fi
echo "$lastDownload" >"$UPDATES_DIR/updated"
if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then
ohai "Updating $TOOL_FILE"
cp -fr "$UPDATES_DIR/install.sh" "$TOOL_FILE"
fi
if [ "$redeploy" -gt 0 ]; then
ohai "Redeploy - installing containers"
install_containers
fi
hline
msgok "Aktualizacja zakończona"
# fi
fi
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
@ -2026,6 +2268,11 @@ retry_diagnostics() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# APP LOGIC
#=======================================
@ -2034,6 +2281,7 @@ update_logto() {
if [[ "$UPDATE_CHANNEL" == "develop" || "$FORCE_DEBUG_LOG" == "1" ]]; then
LOGTO="$DEBUG_LOG_FILE"
else
#shellcheck disable=SC2034
LOGTO=/dev/null
fi
}
@ -2085,7 +2333,25 @@ startup_debug() {
fi
}
do_restart() {
msgnote "Restarting containers..."
uninstall_containers
install_containers
msgok "Restarted"
}
do_update_ns() {
msgnote "Updating Nightscout and Mongo containers (downloading latest images)..."
uninstall_containers
update_containers
msgok "Updated"
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
@ -2143,6 +2409,11 @@ admin_panel_promo() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SETUP PROMPT DIALOGS
#=======================================
@ -2283,6 +2554,10 @@ prompt_api_secret() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SETUP UI
#=======================================
@ -2405,6 +2680,11 @@ domain_setup() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# REMINDERS
#=======================================
@ -2556,6 +2836,10 @@ update_background_check() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# COMMANDLINE PARSER
#=======================================
@ -2566,7 +2850,8 @@ Usage: nightscout-tool [options]
Description:
Nightscout-tool is a command-line tool for managing Nightscout.
Nightscout-tool is a command-line tool for managing Nightscout instance
and its containers on mikr.us hosting.
In UI mode, tool provides a menu-driven interface for managing
Nightscout server, its configuration, updates, cleanup, and diagnostics.
@ -2577,12 +2862,15 @@ Description:
Options:
-w, --watchdog Run in watchdog mode
-v, --version Show version
-l, --loud Enable debug logging
-l, --loud Enable debug logging (UI) or verbose mode (non-int.)
-d, --develop Switch to DEVELOP update channel
-p, --production Switch to PRODUCTION update channel
-u, --update Force update check
-u, --update Perform unattended update of tool
-c, --channel Switch to specified update channel
-s, --cleanup Perform cleanup
-r, --restart Restart containers
--update-ns Update Nightscout and Mongo containers
--force-check Force update check in UI mode
-h, --help Show this help message
EOF
}
@ -2591,7 +2879,10 @@ parse_commandline_args() {
load_update_channel
CMDARGS=$(getopt --quiet -o wvldpuc:sh --long watchdog,version,loud,develop,production,update,channel:,cleanup,help -n 'nightscout-tool' -- "$@")
CMDARGS=$(getopt --quiet \
-o wvldpuc:srh \
--long watchdog,version,loud,develop,production,update,force-check,channel:,cleanup,restart,update-ns,help \
-n 'nightscout-tool' -- "$@")
# shellcheck disable=SC2181
if [ $? != 0 ]; then
@ -2604,6 +2895,10 @@ parse_commandline_args() {
WATCHDOGMODE=false
NONINTERACTIVE_MODE=false
local action=""
local new_channel=""
# First pass: gather configuration and determine action
while true; do
case "$1" in
-w | --watchdog)
@ -2612,60 +2907,62 @@ parse_commandline_args() {
shift
;;
-v | --version)
echo "$SCRIPT_VERSION"
exit 0
action="version"
shift
;;
-l | --loud)
warn "Loud mode, enabling debug logging"
FORCE_DEBUG_LOG="1"
update_logto
shift
;;
-d | --develop)
warn "Switching to DEVELOP update channel"
UPDATE_CHANNEL=develop
new_channel="develop"
forceUpdateCheck=1
echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE"
update_logto
shift
;;
-p | --production)
warn "Switching to PRODUCTION update channel"
UPDATE_CHANNEL=master
new_channel="master"
forceUpdateCheck=1
echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE"
update_logto
shift
;;
-u | --update)
warn "Forcing update check"
-f | --force-check)
forceUpdateCheck=1
shift
;;
-u | --update)
NONINTERACTIVE_MODE=true
action="update"
shift
;;
-c | --channel)
shift # The arg is next in position args
UPDATE_CHANNEL_CANDIDATE=$1
new_channel=$1
forceUpdateCheck=1
[[ ! "$UPDATE_CHANNEL_CANDIDATE" =~ ^[a-z]{3,}$ ]] && {
echo "Incorrect channel name provided: $UPDATE_CHANNEL_CANDIDATE"
[[ ! "$new_channel" =~ ^[a-z]{3,}$ ]] && {
echo "Incorrect channel name provided: $new_channel"
exit 1
}
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
action="cleanup"
shift
;;
-r | --restart)
NONINTERACTIVE_MODE=true
action="restart"
shift
;;
--update-ns)
#shellcheck disable=SC2034
NONINTERACTIVE_MODE=true
action="update-ns"
shift
;;
-h | --help)
help
exit 0
action="help"
shift
;;
--)
shift
@ -2675,17 +2972,65 @@ parse_commandline_args() {
esac
done
# Apply configuration
if [ -n "$FORCE_DEBUG_LOG" ]; then
warn "Loud mode, enabling debug logging"
update_logto
fi
if [ -n "$new_channel" ]; then
warn "Switching to $new_channel update channel"
UPDATE_CHANNEL="$new_channel"
echo "$UPDATE_CHANNEL" >"$UPDATE_CHANNEL_FILE"
update_logto
fi
if [ "$forceUpdateCheck" = "1" ]; then
warn "Forcing update check"
fi
# Second pass: execute action or continue
case "$action" in
version)
echo "$SCRIPT_VERSION"
exit 0
;;
help)
help
exit 0
;;
cleanup)
do_cleanup_all
exit 0
;;
restart)
do_restart
exit 0
;;
update)
do_update_tool
exit 0
;;
update-ns)
do_update_ns
exit 0
;;
esac
if [ "$WATCHDOGMODE" = "true" ]; then
startup_version
startup_debug
watchdog_check
fi
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# WATCHDOG UI
#=======================================
@ -2729,6 +3074,10 @@ show_watchdog_logs() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# CLEANUP UI
#=======================================
@ -2846,6 +3195,11 @@ cleanup_menu() {
}
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# CONFIG AND MANAGEMENT UI
#=======================================
@ -3070,6 +3424,10 @@ uninstall_menu() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# UPDATE UI
#=======================================
@ -3246,6 +3604,10 @@ update_menu() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# DIAGNOSTICS UI
#=======================================
@ -3319,6 +3681,10 @@ send_diagnostics() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# MAIN APP UI
#=======================================
@ -3445,6 +3811,7 @@ main_menu() {
install_or_menu() {
STATUS_NS=$(get_docker_status "ns-server")
#shellcheck disable=SC2034
lastTimeSpaceInfo=$(get_space_info)
if [ "$STATUS_NS" = "missing" ]; then

@ -135,6 +135,7 @@ main_menu() {
install_or_menu() {
STATUS_NS=$(get_docker_status "ns-server")
#shellcheck disable=SC2034
lastTimeSpaceInfo=$(get_space_info)
if [ "$STATUS_NS" = "missing" ]; then

@ -124,6 +124,7 @@ parse_commandline_args() {
shift
;;
--update-ns)
#shellcheck disable=SC2034
NONINTERACTIVE_MODE=true
action="update-ns"
shift

@ -3,9 +3,9 @@
# shellcheck disable=SC2155
# shellcheck disable=SC2034
if [ "EXECUTED" != "true" ]; then
if [ "$EXECUTED" != "true" ]; then
msgerr "Headers USED!"
echo "Headers USED!"
#=======================================
# HEADERS
#=======================================
@ -25,7 +25,63 @@ if [ "EXECUTED" != "true" ]; then
MIKRUS_APIKEY=''
MIKRUS_HOST=''
else
msgdebug "Headers ignored"
#---------------------------------------
# UNICODE LITERALS
#---------------------------------------
emoji_check="\U2705"
emoji_ok="\U1F197"
emoji_err="\U274C"
emoji_note="\U1F4A1"
emoji_debug="\U1F4DC"
uni_bullet=" $(printf '\u2022') "
uni_copyright="$(printf '\uA9\uFE0F')"
uni_bullet_pad=" "
uni_warn="$(printf "\U26A0")"
uni_exit=" $(printf '\U274C') Wyjdź "
uni_start=" $(printf '\U1F984') Zaczynamy "
uni_menu=" $(printf '\U1F6E0') Menu "
uni_finish=" $(printf '\U1F984') Zamknij "
uni_reenter=" $(printf '\U21AA') Tak "
uni_noenter=" $(printf '\U2716') Nie "
uni_back=" $(printf '\U2B05') Wróć "
uni_select=" Wybierz "
uni_excl="$(printf '\U203C')"
uni_confirm_del=" $(printf '\U1F4A3') Tak "
uni_confirm_ch=" $(printf '\U1F199') Zmień "
uni_confirm_upd=" $(printf '\U1F199') Aktualizuj "
uni_confirm_ed=" $(printf '\U1F4DD') Edytuj "
uni_install=" $(printf '\U1F680') Instaluj "
uni_resign=" $(printf '\U1F6AB') Rezygnuję "
uni_send=" $(printf '\U1F4E7') Wyślij "
uni_delete=" $(printf '\U1F5D1') Usuń "
uni_leave_logs=" $(printf '\U1F4DC') Zostaw "
uni_ns_ok="$(printf '\U1F7E2') działa"
uni_leave_logs=''
uni_back=''
uni_resign=''
uni_confirm_del=''
uni_confirm_ch=''
uni_confirm_ed=''
uni_select=''
uni_bullet=''
uni_bullet_pad=''
uni_warn=''
uni_send=''
uni_watchdog_ok=''
uni_exit=''
uni_ns_ok=''
uni_start=''
uni_install=''
uni_noenter=''
tty_blue=''
tty_red=''
tty_bold=''
tty_reset=''
fi
#dev-end

@ -156,4 +156,3 @@ MIKRUS_HOST=''
#include app_update.sh
#include app_diagnostics.sh
#include app_main.sh

@ -17,6 +17,7 @@ update_logto() {
if [[ "$UPDATE_CHANNEL" == "develop" || "$FORCE_DEBUG_LOG" == "1" ]]; then
LOGTO="$DEBUG_LOG_FILE"
else
#shellcheck disable=SC2034
LOGTO=/dev/null
fi
}

@ -24,19 +24,19 @@ get_docker_status() {
install_containers() {
if [[ "$FORCE_DEBUG_LOG" == "1" && "$NONINTERACTIVE_MODE" = "true" ]]; then
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE up --no-recreate -d
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up --no-recreate -d
else
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE up --no-recreate -d >>"$LOGTO" 2>&1
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up --no-recreate -d >>"$LOGTO" 2>&1
fi
}
update_containers() {
if [[ "$FORCE_DEBUG_LOG" == "1" && "$NONINTERACTIVE_MODE" = "true" ]]; then
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE pull
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE up -d
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" pull
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up -d
else
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE pull >>"$LOGTO" 2>&1
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE up -d >>"$LOGTO" 2>&1
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" pull >>"$LOGTO" 2>&1
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" up -d >>"$LOGTO" 2>&1
fi
}
@ -49,9 +49,9 @@ install_containers_progress() {
uninstall_containers() {
if [[ "$FORCE_DEBUG_LOG" == "1" && "$NONINTERACTIVE_MODE" = "true" ]]; then
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE down
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" down
else
docker compose --env-file $ENV_FILE_DEP -f $DOCKER_COMPOSE_FILE down >>"$LOGTO" 2>&1
docker compose --env-file "$ENV_FILE_DEP" -f "$DOCKER_COMPOSE_FILE" down >>"$LOGTO" 2>&1
fi
}

@ -83,7 +83,7 @@ event_label() {
}
event_count() {
if [ ! -f ${EVENTS_DB} ]; then
if [ ! -f "${EVENTS_DB}" ]; then
echo "0"
else
local eventsJSON=$(dotenv-tool parse -r -f "${EVENTS_DB}")
@ -134,7 +134,7 @@ event_count() {
}
event_list() {
if [ ! -f ${EVENTS_DB} ]; then
if [ ! -f "${EVENTS_DB}" ]; then
echo "Nie odnotowano zdarzeń"
else
local eventsJSON=$(dotenv-tool parse -r -f "${EVENTS_DB}")

@ -29,6 +29,8 @@ patch_docker_compose() {
if grep -q "bitnami/mongodb" "$DOCKER_COMPOSE_FILE"; then
ohai "Patching docker-compose.yml MongoDB image..."
# Replace bitnami/mongodb with official mongo image
# This is BY PURPOSE left as var in yaml - as it is replaced wit env vars
# shellcheck disable=SC2016
sed -i -E 's|image:\s*"*(bitnami/)?mongodb:.*"|image: "mongo:${NS_MONGODB_TAG}"|g' "$DOCKER_COMPOSE_FILE"
patched=1
fi

@ -128,8 +128,7 @@ download_if_needed() {
local lastCheck=$(read_or_default "$UPDATES_DIR/timestamp")
local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "")
local timestampNow=$(date +%s)
local updateCheck=$UPDATE_CHECK]
#shellcheck disable=SC2154
local updateCheck=$UPDATE_CHECK
if (((timestampNow - lastCheck) > updateCheck)) || [ "$lastDownload" == "" ] || [ "$lastDownload" == "error" ] || ((forceUpdateCheck == 1)) || [ $# -eq 1 ]; then
echo "$timestampNow" >"$UPDATES_DIR/timestamp"
ohai "Checking if new version is available..."

@ -1,5 +1,6 @@
# shellcheck disable=SC2148
# shellcheck disable=SC2155
# shellcheck disable=SC2034
#dev-begin
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@ -1,6 +1,7 @@
# shellcheck disable=SC2148
# shellcheck disable=SC2155
# shellcheck disable=SC2059
#
#dev-begin
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# IMPORTS
@ -47,6 +48,7 @@ ohai() {
}
msgprint() {
#shellcheck disable=SC2046
printf $(all_join "$@")
}

@ -1 +1 @@
2026-01-06T01:30:06.751Z
2026-01-06T15:22:16.552Z
Loading…
Cancel
Save