From 2967efaddf62ce73f1ef8e9842330bacd770f59f Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:19:36 +0200 Subject: [PATCH] Update 98-upgrade.sh --- .../rootfs/etc/cont-init.d/98-upgrade.sh | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/nextcloud/rootfs/etc/cont-init.d/98-upgrade.sh b/nextcloud/rootfs/etc/cont-init.d/98-upgrade.sh index da73b2c43..814d02418 100755 --- a/nextcloud/rootfs/etc/cont-init.d/98-upgrade.sh +++ b/nextcloud/rootfs/etc/cont-init.d/98-upgrade.sh @@ -4,30 +4,44 @@ # Only execute if installed if [ -f /notinstalled ]; then exit 0; fi +# Check current version +if [ -f /data/config/www/nextcloud/version.php ]; then + CURRENTVERSION="$(sed -n "s|.*\OC_VersionString = '*\(.*[^ ]\) *';.*|\1|p" /data/config/www/nextcloud/version.php)" +else + CURRENTVERSION="Not found" +fi + +# Check container version +CONTAINERVERSION="$(cat /nextcloudversion)" + # Inform if new version available function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } # Updater code -bashio::log.green "Checking for nextcloud updates" -# Install new version -sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/updater/updater.phar --no-interaction" -sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade" -# Install additional versions -while [[ $(occ update:check 2>&1) == *"update available"* ]]; do - bashio::log.yellow "-----------------------------------------------------------------------" - bashio::log.yellow " new version available, updating. Please do not turn off your addon! " - bashio::log.yellow "-----------------------------------------------------------------------" +if ! bashio::config.true "disable_updates"; then + bashio::log.green "Auto_updater set, checking for updates" + # Install new version sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/updater/updater.phar --no-interaction" sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade" -done - -if ! bashio::config.true "disable_updates"; then - bashio::log.green "---" - bashio::log.green "Updating apps" sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ app:update --all" -else - bashio::log.green "disable_updates set, please update the apps manually" + # Install additional versions + while [[ $(occ update:check 2>&1) == *"update available"* ]]; do + bashio::log.yellow "-----------------------------------------------------------------------" + bashio::log.yellow " new version available, updating. Please do not turn off your addon! " + bashio::log.yellow "-----------------------------------------------------------------------" + sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/updater/updater.phar --no-interaction" + sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade" + done + # Reset permissions + /./etc/cont-init.d/01-folders.sh +elif bashio::config.true "disable_updates" && [ "$(version "$CONTAINERVERSION")" -gt "$(version "$CURRENTVERSION")" ]; then + bashio::log.warning " " + bashio::log.warning "----------------------------------------- " + bashio::log.warning "New version available : $CONTAINERVERSION" + bashio::log.warning "-----------------------------------------" + bashio::log.warning " " + bashio::log.warning "...auto_updater not set in addon options, please update from nextcloud settings" + bashio::log.warning "If you don't update you risk an addon breakage !" + bashio::log.warning " " + bashio::log.warning "-----------------------------------------" fi - -# Reset permissions -/./etc/cont-init.d/01-folders.sh