diff --git a/install.sh b/install.sh index 4630a83..e9b1a95 100644 --- a/install.sh +++ b/install.sh @@ -1094,12 +1094,18 @@ read_or_default() { download_updates() { ohai "Downloading updated scripts and config files" - 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" + local onlineUpdated="$(curl -fsSL "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/updated")" + 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" + else + onlineUpdated="error" + fi + echo "$onlineUpdated" >"$UPDATES_DIR/downloaded" } download_if_needed() { @@ -1107,7 +1113,7 @@ download_if_needed() { local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "") local timestampNow=$(date +%s) local updateCheck=$UPDATE_CHECK - if (((timestampNow - lastCheck) > updateCheck)) || [ "$lastDownload" == "" ] || ((forceUpdateCheck == 1)); then + if (((timestampNow - lastCheck) > updateCheck)) || [ "$lastDownload" == "" ] || [ "$lastDownload" == "error" ] || ((forceUpdateCheck == 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")" @@ -1115,7 +1121,6 @@ download_if_needed() { if [ "$onlineUpdated" == "$lastDownload" ] && ((forceUpdateCheck == 0)); then msgok "Latest update already downloaded" else - echo "$onlineUpdated" >"$UPDATES_DIR/downloaded" download_updates fi else @@ -1129,7 +1134,7 @@ update_background_check() { local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "") local updateInstalled=$(read_or_default "$UPDATES_DIR/updated" "") - if [ ! "$lastDownload" == "$updateInstalled" ]; then + 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 @@ -1168,107 +1173,114 @@ update_if_needed() { msgok "Scripts and config files are up to date" else - 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 [ "$lastDownload" == "error" ]; then + msgerr "Download update failed" + if [ $# -eq 1 ]; then + okdlg "Aktualizacja niemożliwa" "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" + fi + else - if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then - changed=$((changed + 1)) - msgInst="$(printf "\U1F534") $instLocalVer $(printf "\U27A1") $instOnlineVer" - fi + local changed=0 + local redeploy=0 - if ! [ "$depEnvLocalVer" == "$depEnvOnlineVer" ]; then - changed=$((changed + 1)) - redeploy=$((redeploy + 1)) - msgDep="$(printf "\U1F534") $depEnvLocalVer $(printf "\U27A1") $depEnvOnlineVer" - fi + 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")") - if ! [ "$nsEnvLocalVer" == "$nsEnvOnlineVer" ]; then - changed=$((changed + 1)) - redeploy=$((redeploy + 1)) - msgNs="$(printf "\U1F534") $nsEnvLocalVer $(printf "\U27A1") $nsEnvOnlineVer" - fi + 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")") - if ! [ "$compLocalVer" == "$compOnlineVer" ]; then - changed=$((changed + 1)) - redeploy=$((redeploy + 1)) - msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer" - fi + local msgInst="$(printf "\U1F7E2") $instLocalVer" + local msgDep="$(printf "\U1F7E2") $depEnvLocalVer" + local msgNs="$(printf "\U1F7E2") $nsEnvLocalVer" + local msgComp="$(printf "\U1F7E2") $compLocalVer" - if [ "$changed" -eq 0 ]; then - if [ $# -eq 1 ]; then - msgok "Scripts and config files are up to date" - okdlg "Aktualizacja skryptów" "$1" - fi - else - local okTxt="" - if [ "$redeploy" -gt 0 ]; then - okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}" + if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then + changed=$((changed + 1)) + msgInst="$(printf "\U1F534") $instLocalVer $(printf "\U27A1") $instOnlineVer" fi - local versionMsg="${TL}Build: ${updateInstalled}" - if [ ! "$lastDownload" == "$updateInstalled" ]; then - versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")" + if ! [ "$depEnvLocalVer" == "$depEnvOnlineVer" ]; then + changed=$((changed + 1)) + redeploy=$((redeploy + 1)) + msgDep="$(printf "\U1F534") $depEnvLocalVer $(printf "\U27A1") $depEnvOnlineVer" fi - yesnodlg "Aktualizacja skryptów" "$uni_confirm_upd" "$uni_resign" \ - "Zalecana jest 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" - - if ! [ $? -eq 1 ]; then + if ! [ "$nsEnvLocalVer" == "$nsEnvOnlineVer" ]; then + changed=$((changed + 1)) + redeploy=$((redeploy + 1)) + msgNs="$(printf "\U1F534") $nsEnvLocalVer $(printf "\U27A1") $nsEnvOnlineVer" + fi - clear_last_time "update_needed" + if ! [ "$compLocalVer" == "$compOnlineVer" ]; then + changed=$((changed + 1)) + redeploy=$((redeploy + 1)) + msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer" + fi + if [ "$changed" -eq 0 ]; then + if [ $# -eq 1 ]; then + msgok "Scripts and config files are up to date" + okdlg "Aktualizacja skryptów" "$1" + fi + else + local okTxt="" if [ "$redeploy" -gt 0 ]; then - docker_compose_down + okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}" fi - if ! [ "$compOnlineVer" == "$compLocalVer" ]; then - ohai "Updating $DOCKER_COMPOSE_FILE" - cp -fr "$UPDATES_DIR/docker-compose.yml" "$DOCKER_COMPOSE_FILE" + local versionMsg="${TL}Build: ${updateInstalled}" + if [ ! "$lastDownload" == "$updateInstalled" ]; then + versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")" 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 + yesnodlg "Aktualizacja skryptów" "$uni_confirm_upd" "$uni_resign" \ + "Zalecana jest 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" - 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 + if ! [ $? -eq 1 ]; then - echo "$lastDownload" >"$UPDATES_DIR/updated" + clear_last_time "update_needed" - if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then - ohai "Updating $TOOL_FILE" - cp -fr "$UPDATES_DIR/install.sh" "$TOOL_FILE" - okdlg "Aktualizacja zakończona" "Narzędzie zostanie uruchomione ponownie" - ohai "Restarting tool" - exec "$TOOL_FILE" - fi + if [ "$redeploy" -gt 0 ]; then + docker_compose_down + 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" + okdlg "Aktualizacja zakończona" "Narzędzie zostanie uruchomione ponownie" + ohai "Restarting tool" + exec "$TOOL_FILE" + fi + fi fi fi fi diff --git a/src/lib.sh b/src/lib.sh index b78eb32..f660c35 100644 --- a/src/lib.sh +++ b/src/lib.sh @@ -1078,12 +1078,18 @@ read_or_default() { download_updates() { ohai "Downloading updated scripts and config files" - 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" + local onlineUpdated="$(curl -fsSL "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/$UPDATE_CHANNEL/updated")" + 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" + else + onlineUpdated="error" + fi + echo "$onlineUpdated" >"$UPDATES_DIR/downloaded" } download_if_needed() { @@ -1091,7 +1097,7 @@ download_if_needed() { local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "") local timestampNow=$(date +%s) local updateCheck=$UPDATE_CHECK - if (((timestampNow - lastCheck) > updateCheck)) || [ "$lastDownload" == "" ] || ((forceUpdateCheck == 1)); then + if (((timestampNow - lastCheck) > updateCheck)) || [ "$lastDownload" == "" ] || [ "$lastDownload" == "error" ] || ((forceUpdateCheck == 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")" @@ -1099,7 +1105,6 @@ download_if_needed() { if [ "$onlineUpdated" == "$lastDownload" ] && ((forceUpdateCheck == 0)); then msgok "Latest update already downloaded" else - echo "$onlineUpdated" >"$UPDATES_DIR/downloaded" download_updates fi else @@ -1113,7 +1118,7 @@ update_background_check() { local lastDownload=$(read_or_default "$UPDATES_DIR/downloaded" "") local updateInstalled=$(read_or_default "$UPDATES_DIR/updated" "") - if [ ! "$lastDownload" == "$updateInstalled" ]; then + 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 @@ -1152,107 +1157,114 @@ update_if_needed() { msgok "Scripts and config files are up to date" else - 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 [ "$lastDownload" == "error" ]; then + msgerr "Download update failed" + if [ $# -eq 1 ]; then + okdlg "Aktualizacja niemożliwa" "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" + fi + else - if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then - changed=$((changed + 1)) - msgInst="$(printf "\U1F534") $instLocalVer $(printf "\U27A1") $instOnlineVer" - fi + local changed=0 + local redeploy=0 - if ! [ "$depEnvLocalVer" == "$depEnvOnlineVer" ]; then - changed=$((changed + 1)) - redeploy=$((redeploy + 1)) - msgDep="$(printf "\U1F534") $depEnvLocalVer $(printf "\U27A1") $depEnvOnlineVer" - fi + 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")") - if ! [ "$nsEnvLocalVer" == "$nsEnvOnlineVer" ]; then - changed=$((changed + 1)) - redeploy=$((redeploy + 1)) - msgNs="$(printf "\U1F534") $nsEnvLocalVer $(printf "\U27A1") $nsEnvOnlineVer" - fi + 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")") - if ! [ "$compLocalVer" == "$compOnlineVer" ]; then - changed=$((changed + 1)) - redeploy=$((redeploy + 1)) - msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer" - fi + local msgInst="$(printf "\U1F7E2") $instLocalVer" + local msgDep="$(printf "\U1F7E2") $depEnvLocalVer" + local msgNs="$(printf "\U1F7E2") $nsEnvLocalVer" + local msgComp="$(printf "\U1F7E2") $compLocalVer" - if [ "$changed" -eq 0 ]; then - if [ $# -eq 1 ]; then - msgok "Scripts and config files are up to date" - okdlg "Aktualizacja skryptów" "$1" - fi - else - local okTxt="" - if [ "$redeploy" -gt 0 ]; then - okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}" + if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then + changed=$((changed + 1)) + msgInst="$(printf "\U1F534") $instLocalVer $(printf "\U27A1") $instOnlineVer" fi - local versionMsg="${TL}Build: ${updateInstalled}" - if [ ! "$lastDownload" == "$updateInstalled" ]; then - versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")" + if ! [ "$depEnvLocalVer" == "$depEnvOnlineVer" ]; then + changed=$((changed + 1)) + redeploy=$((redeploy + 1)) + msgDep="$(printf "\U1F534") $depEnvLocalVer $(printf "\U27A1") $depEnvOnlineVer" fi - yesnodlg "Aktualizacja skryptów" "$uni_confirm_upd" "$uni_resign" \ - "Zalecana jest 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" - - if ! [ $? -eq 1 ]; then + if ! [ "$nsEnvLocalVer" == "$nsEnvOnlineVer" ]; then + changed=$((changed + 1)) + redeploy=$((redeploy + 1)) + msgNs="$(printf "\U1F534") $nsEnvLocalVer $(printf "\U27A1") $nsEnvOnlineVer" + fi - clear_last_time "update_needed" + if ! [ "$compLocalVer" == "$compOnlineVer" ]; then + changed=$((changed + 1)) + redeploy=$((redeploy + 1)) + msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer" + fi + if [ "$changed" -eq 0 ]; then + if [ $# -eq 1 ]; then + msgok "Scripts and config files are up to date" + okdlg "Aktualizacja skryptów" "$1" + fi + else + local okTxt="" if [ "$redeploy" -gt 0 ]; then - docker_compose_down + okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}" fi - if ! [ "$compOnlineVer" == "$compLocalVer" ]; then - ohai "Updating $DOCKER_COMPOSE_FILE" - cp -fr "$UPDATES_DIR/docker-compose.yml" "$DOCKER_COMPOSE_FILE" + local versionMsg="${TL}Build: ${updateInstalled}" + if [ ! "$lastDownload" == "$updateInstalled" ]; then + versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")" 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 + yesnodlg "Aktualizacja skryptów" "$uni_confirm_upd" "$uni_resign" \ + "Zalecana jest 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" - 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 + if ! [ $? -eq 1 ]; then - echo "$lastDownload" >"$UPDATES_DIR/updated" + clear_last_time "update_needed" - if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then - ohai "Updating $TOOL_FILE" - cp -fr "$UPDATES_DIR/install.sh" "$TOOL_FILE" - okdlg "Aktualizacja zakończona" "Narzędzie zostanie uruchomione ponownie" - ohai "Restarting tool" - exec "$TOOL_FILE" - fi + if [ "$redeploy" -gt 0 ]; then + docker_compose_down + 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" + okdlg "Aktualizacja zakończona" "Narzędzie zostanie uruchomione ponownie" + ohai "Restarting tool" + exec "$TOOL_FILE" + fi + fi fi fi fi diff --git a/updated b/updated index d06e6c2..b3ea143 100644 --- a/updated +++ b/updated @@ -1 +1 @@ -2024-10-25T13:51:37.691Z \ No newline at end of file +2024-10-25T14:24:06.020Z \ No newline at end of file