@ -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,72 +229,83 @@ shell_join() {
done
}
all_join( ) {
local arg
printf " $1 "
shift
for arg in " $@ " ; do
printf " "
printf " ${ arg } "
done
}
chomp( ) {
printf "%s" " ${ 1 / " $'\n' " / } "
}
ohai( ) {
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
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
}
msgprint( ) {
printf "%s\n" " $( shell_join " $@ " ) "
#shellcheck disable=SC2046
printf $( all_join " $@ " )
}
msgok( ) {
if [ " $NONINTERACTIVE_MODE " = "true" ] ; then
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_ok $1 \n "
fi
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_ok $1 \n "
fi
}
msgnote( ) {
if [ " $NONINTERACTIVE_MODE " = "true" ] ; then
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_note $1 \n "
fi
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_note $1 \n "
fi
}
msgcheck( ) {
if [ " $NONINTERACTIVE_MODE " = "true" ] ; then
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_check $1 \n "
fi
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_check $1 \n "
fi
}
msgerr( ) {
if [ " $NONINTERACTIVE_MODE " = "true" ] ; then
# shellcheck disable=SC2059
printf " $1 \n "
else
# shellcheck disable=SC2059
printf " $emoji_err $1 \n "
fi
# 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
if [ " $NONINTERACTIVE_MODE " = "true" ] ; then
# shellcheck disable=SC2059
printf " $1 \n "
else
printf " $emoji_debug $1 \n "
fi
fi
}
hline( ) {
@ -292,15 +318,19 @@ hline() {
warn( ) {
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
# shellcheck disable=SC2059
printf "Warning: %s\n" " $( chomp " $1 " ) " >& 2
else
printf " ${ tty_red } Warning ${ tty_reset } : %s\n " " $( chomp " $1 " ) " >& 2
fi
}
# 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
#=======================================
@ -1020,7 +1067,7 @@ setup_firewall() {
# Extract the last 3 digits from the hostname
port_number = $( echo " $host " | grep -oE '[0-9]{3}$' )
ohai " Firewall port: $port_number "
ohai " Firewall port: $port_number "
port1 = $(( 10000 + port_number))
port2 = $(( 20000 + port_number))
@ -1073,6 +1120,10 @@ uninstall_cron() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# SETUP CHECKS
#=======================================
@ -1104,10 +1155,10 @@ add_if_not_ok_compose() {
msgcheck " $1 installed "
else
ohai " Installing $1 ... "
mkdir -p "~/.docker/cli-plugins" >> " $LOGTO " 2>& 1
curl -SL "https://github.com/docker/compose/releases/download/v2.29.7/docker-compose-linux-x86_64" -o "~/.docker/cli-plugins/docker-compose" >> " $LOGTO " 2>& 1
chmod +x "~/.docker/cli-plugins/docker-compose" >> " $LOGTO " 2>& 1
msgcheck " Installing $1 successfull "
mkdir -p "~/.docker/cli-plugins" >>" $LOGTO " 2>& 1
curl -SL "https://github.com/docker/compose/releases/download/v2.29.7/docker-compose-linux-x86_64" -o "~/.docker/cli-plugins/docker-compose" >>" $LOGTO " 2>& 1
chmod +x "~/.docker/cli-plugins/docker-compose" >>" $LOGTO " 2>& 1
msgcheck " Installing $1 successfull "
fi
}
@ -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
@ -1213,10 +1271,10 @@ patch_docker_compose() {
msgcheck "Docker compose file patched"
# Restart containers only if they were already running
if [ " $containers_running " -eq 1 ] ; then
do_cleanup_sys
do_cleanup_sys
ohai "Restarting containers to apply patched configuration..."
update_containers
do_cleanup_docker
do_cleanup_docker
msgcheck "Containers restarted"
fi
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
#=======================================
@ -1475,7 +1559,7 @@ get_watchdog_status() {
watchdog_check( ) {
echo "---------------------------"
echo " Nightscout Watchdog mode"
echo " Nightscout Watchdog mode"
echo "---------------------------"
WATCHDOG_LAST_TIME = $( date -u +"%Y-%m-%dT%H:%M:%SZ" )
@ -1632,6 +1716,10 @@ watchdog_check() {
# shellcheck disable=SC2148
# shellcheck disable=SC2155
#=======================================
# CLEANUP LOGIC
#=======================================
@ -1716,25 +1804,28 @@ cleanup_stats() {
savedTxt = "---"
fi
hline
printf " Dostępne: %s\n Zwolniono: %s\n Zajęte: %s (z %s)\n" " ${ remainingTxt } " " ${ savedTxt } " " ${ fixedPerc } " " ${ totalTxt } "
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 "Sprzątanie..."
lastTimeSpaceInfo = $( get_space_info)
hline
lastTimeSpaceInfo = $( get_space_info)
hline
do_cleanup_container_logs
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
}
@ -2076,7 +2324,7 @@ startup_version() {
msgnote "Licensed under CC BY-NC-ND 4.0"
if [ [ -f $UPDATE_CHANNEL_FILE ] ] ; then
msgok " Loaded update channel: $UPDATE_CHANNEL "
fi
fi
}
startup_debug( ) {
@ -2085,9 +2333,27 @@ 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
#=======================================
# OTHER UI
#=======================================
@ -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
@ -2603,7 +2894,11 @@ parse_commandline_args() {
eval set -- " $CMDARGS "
WATCHDOGMODE = false
NONINTERACTIVE_MODE = 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
FORCE_DEBUG_LOG = "1"
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
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