Fixed unatended update

develop
Dominik Dzienia 3 weeks ago
parent e897ad8d66
commit dbefb5f55f

@ -87,6 +87,7 @@ parse_commandline_args() {
shift shift
;; ;;
-u | --update) -u | --update)
NONINTERACTIVE_MODE=true
action="update" action="update"
shift shift
;; ;;

@ -157,7 +157,7 @@ download_update_forced() {
onlineUpdated=$(curl -fsSL "$url" 2>>"$LOGTO") onlineUpdated=$(curl -fsSL "$url" 2>>"$LOGTO")
fi fi
if [ "$onlineUpdated" == "$lastDownload" ] then if [ "$onlineUpdated" == "$lastDownload" ]; then
msgdebug "Downloaded update will be the same as last downloaded" msgdebug "Downloaded update will be the same as last downloaded"
fi fi
@ -178,8 +178,8 @@ do_update_tool() {
else else
if [ "$UPDATE_CHANNEL" == "master" ] && [[ "$lastDownload" < "$updateInstalled" ]]; then if [ "$UPDATE_CHANNEL" == "master" ] && [[ "$lastDownload" < "$updateInstalled" ]]; then
msgerr "Downgrade niemożliwy na produkcyjnym kanale aktualizacji" warn "Downgrade na produkcyjnym kanale aktualizacji!"
else fi
local changed=0 local changed=0
local redeploy=0 local redeploy=0
@ -222,11 +222,6 @@ do_update_tool() {
msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer" msgComp="$(printf "\U1F534") $compLocalVer $(printf "\U27A1") $compOnlineVer"
fi fi
if [ "$changed" -eq 0 ]; then
if [ $# -eq 1 ]; then
msgok "Aktualizacja skryptów nie jest potrzebna"
fi
else
local okTxt="" local okTxt=""
if [ "$redeploy" -gt 0 ]; then if [ "$redeploy" -gt 0 ]; then
okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}" okTxt="${TL}${uni_warn} Aktualizacja zrestartuje i zaktualizuje kontenery ${uni_warn}"
@ -237,7 +232,8 @@ do_update_tool() {
versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")" versionMsg="$(pad_multiline "${TL}Masz build: ${updateInstalled}${NL} Dostępny: ${lastDownload}")"
fi fi
okhaimsgprint "Aktualizacja plików: ${versionMsg}" \ hline
echo -e "Aktualizacja plików:" "${versionMsg}" \
"$( "$(
pad_multiline \ pad_multiline \
"${TL}${uni_bullet}Skrypt instalacyjny: $msgInst" \ "${TL}${uni_bullet}Skrypt instalacyjny: $msgInst" \
@ -246,13 +242,13 @@ do_update_tool() {
"${NL}${uni_bullet}Kompozycja usług: $msgComp${NL}" "${NL}${uni_bullet}Kompozycja usług: $msgComp${NL}"
)" \ )" \
"$okTxt" "$okTxt"
hline
if ! [ $? -eq 1 ]; then
clear_last_time "update_needed" clear_last_time "update_needed"
if [ "$redeploy" -gt 0 ]; then if [ "$redeploy" -gt 0 ]; then
docker_compose_down ohai "Redeploy - uninstalling containers"
uninstall_containers
fi fi
if ! [ "$compOnlineVer" == "$compLocalVer" ]; then if ! [ "$compOnlineVer" == "$compLocalVer" ]; then
@ -275,10 +271,15 @@ do_update_tool() {
if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then if ! [ "$instOnlineVer" == "$instLocalVer" ] || ! [ "$lastDownload" == "$updateInstalled" ]; then
ohai "Updating $TOOL_FILE" ohai "Updating $TOOL_FILE"
cp -fr "$UPDATES_DIR/install.sh" "$TOOL_FILE" cp -fr "$UPDATES_DIR/install.sh" "$TOOL_FILE"
msgok "Aktualizacja zakończona"
fi
fi
fi fi
if [ "$redeploy" -gt 0 ]; then
ohai "Redeploy - installing containers"
install_containers
fi fi
hline
msgok "Aktualizacja zakończona"
# fi
fi fi
} }

@ -12,6 +12,16 @@ shell_join() {
done done
} }
all_join() {
local arg
printf "$1"
shift
for arg in "$@"; do
printf " "
printf "${arg}"
done
}
chomp() { chomp() {
printf "%s" "${1/"$'\n'"/}" printf "%s" "${1/"$'\n'"/}"
} }
@ -25,6 +35,10 @@ ohai() {
fi fi
} }
msgprint() {
printf $(all_join "$@")
}
msgok() { msgok() {
if [ "$NONINTERACTIVE_MODE" = "true" ]; then if [ "$NONINTERACTIVE_MODE" = "true" ]; then
# shellcheck disable=SC2059 # shellcheck disable=SC2059

Loading…
Cancel
Save