Improve update code

This commit is contained in:
Alexandre
2023-03-30 10:07:22 +02:00
parent 8604fbde95
commit 828ac14b82
3 changed files with 54 additions and 52 deletions

View File

@@ -10,29 +10,26 @@ if [ -f /data/config/www/nextcloud/version.php ]; then
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); }'; }
# Inform if new version available
function nextcloud_download {
mkdir -p /app
if [ -f /app/nextcloud.tar.bz2 ]; then rm /app/nextcloud.tar.bz2; fi
curl -o /app/nextcloud.tar.bz2 -L "https://download.nextcloud.com/server/releases/$1.tar.bz2"
}
# Updater code
if bashio::config.true 'auto_updater'; then
if ! bashio::config.true "disable_updates"; then
bashio::log.green "Auto_updater set, checking for updates"
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"
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 "-----------------------------------------------------------------------"
updater.phar --no-interaction
occ upgrade
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
elif [ "$(version "$CONTAINERVERSION")" -gt "$(version "$CURRENTVERSION")" ]; then
elif bashio::config.true "disable_updates" && [ "$(version "$CONTAINERVERSION")" -gt "$(version "$CURRENTVERSION")" ]; then
bashio::log.yellow " "
bashio::log.yellow "New version available : $CONTAINERVERSION"
bashio::log.yellow "...auto_updater not set in addon options, please update from nextcloud settings"
@@ -42,14 +39,4 @@ fi
# RESET PERMISSIONS #
#####################
PUID=$(bashio::config "PUID")
PGID=$(bashio::config "PGID")
datadirectory=$(bashio::config 'data_directory')
echo "Checking permissions"
mkdir -p /data/config
mkdir -p "$datadirectory"
chmod 755 -R "$datadirectory"
chmod 755 -R /data/config
chown -R "$PUID:$PGID" "$datadirectory"
chown -R "$PUID:$PGID" "/data/config"
/./01-folders.sh