mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-31 02:10:32 +02:00
Improve update code
This commit is contained in:
@@ -3,14 +3,24 @@
|
|||||||
|
|
||||||
PUID=$(bashio::config "PUID")
|
PUID=$(bashio::config "PUID")
|
||||||
PGID=$(bashio::config "PGID")
|
PGID=$(bashio::config "PGID")
|
||||||
datadirectory=$(bashio::config 'data_directory')
|
|
||||||
|
|
||||||
echo "Checking permissions"
|
# Check current version
|
||||||
|
if [ -f /data/config/www/nextcloud/config/config.php ]; then
|
||||||
|
datadirectory="$(sed -n "s|.*datadirectory' => '*\(.*[^ ]\) *',.*|\1|p" /data/config/www/nextcloud/config/config.php)"
|
||||||
|
else
|
||||||
|
datadirectory=/share/nextcloud
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Updating permissions..."
|
||||||
|
echo "... Config directory : /data"
|
||||||
mkdir -p /data/config
|
mkdir -p /data/config
|
||||||
|
chmod 755 -R /data/config
|
||||||
|
chown -R "$PUID:$PGID" "/data/config"
|
||||||
|
|
||||||
|
echo "... Data directory detected : $datadirectory"
|
||||||
mkdir -p "$datadirectory"
|
mkdir -p "$datadirectory"
|
||||||
chmod 755 -R "$datadirectory"
|
chmod 755 -R "$datadirectory"
|
||||||
chmod 755 -R /data/config
|
|
||||||
chown -R "$PUID:$PGID" "$datadirectory"
|
chown -R "$PUID:$PGID" "$datadirectory"
|
||||||
chown -R "$PUID:$PGID" "/data/config"
|
|
||||||
echo "...done"
|
echo "...done"
|
||||||
echo " "
|
echo " "
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ fi
|
|||||||
# Get launcher
|
# Get launcher
|
||||||
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ"
|
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ"
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
|
||||||
# Check current version
|
# Check current version
|
||||||
if [ -f /data/config/www/nextcloud/version.php ]; then
|
if [ -f /data/config/www/nextcloud/version.php ]; then
|
||||||
CURRENTVERSION="$(sed -n "s|.*\OC_VersionString = '*\(.*[^ ]\) *';.*|\1|p" /data/config/www/nextcloud/version.php)"
|
CURRENTVERSION="$(sed -n "s|.*\OC_VersionString = '*\(.*[^ ]\) *';.*|\1|p" /data/config/www/nextcloud/version.php)"
|
||||||
@@ -55,23 +62,31 @@ if [[ $($LAUNCHER -V 2>&1) == *"not installed"* ]] || [ ! -f /data/config/www/ne
|
|||||||
exit 0
|
exit 0
|
||||||
# Is there an error
|
# Is there an error
|
||||||
elif [[ $($LAUNCHER -V 2>&1) == *"Composer autoloader not found"* ]]; then
|
elif [[ $($LAUNCHER -V 2>&1) == *"Composer autoloader not found"* ]]; then
|
||||||
bashio::log.red "--------------------------------------------------------"
|
bashio::log.red "--------------------------------------------------"
|
||||||
bashio::log.red "Issue in installation detected, Nextcloud will reinstall"
|
bashio::log.red " Missing files detected, Nextcloud will reinstall "
|
||||||
bashio::log.red "--------------------------------------------------------"
|
bashio::log.red "--------------------------------------------------"
|
||||||
touch /reinstall
|
touch /reinstall
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair-share-owner"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off"
|
||||||
elif [[ $($LAUNCHER -V 2>&1) == *"Nextcloud"* ]] || grep -q "/mnt/" /data/config/www/nextcloud/config/config.php &>/dev/null; then
|
elif [[ $($LAUNCHER -V 2>&1) == *"Nextcloud"* ]] || grep -q "/mnt/" /data/config/www/nextcloud/config/config.php &>/dev/null; then
|
||||||
# Log
|
# Log
|
||||||
bashio::log.green "--------------------------------------"
|
bashio::log.green "----------------------------------------"
|
||||||
bashio::log.green " Nextcloud $CURRENTVERSION is installed "
|
bashio::log.green " Nextcloud $CURRENTVERSION is installed "
|
||||||
bashio::log.green "--------------------------------------"
|
bashio::log.green "----------------------------------------"
|
||||||
elif ! grep -q "/mnt/" /data/config/www/nextcloud/config/config.php; then
|
elif ! grep -q "/mnt/" /data/config/www/nextcloud/config/config.php; then
|
||||||
bashio::log.red "------------------------------------------------------------------"
|
bashio::log.red "-------------------------------------------------"
|
||||||
bashio::log.red "Unknown error detected, please create issue in github or reinstall"
|
bashio::log.red " Unknown error detected, auto-repair will launch "
|
||||||
bashio::log.red "------------------------------------------------------------------"
|
bashio::log.red "-------------------------------------------------"
|
||||||
bashio::log.red "Error message:"
|
bashio::log.red "Error message:"
|
||||||
bashio::log.red "$($LAUNCHER -V 2>&1)"
|
bashio::log.red "$($LAUNCHER -V 2>&1)"
|
||||||
bashio::log.red "------------------------------------------------------------------"
|
bashio::log.red "------------------------------------------------------------------"
|
||||||
bashio::exit.nok
|
bashio::exit.nok
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair-share-owner"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " "
|
echo " "
|
||||||
@@ -95,22 +110,12 @@ if [ -f /reinstall ]; then
|
|||||||
# Reinstall
|
# Reinstall
|
||||||
bashio::log.green "... reinstall ongoing, please wait"
|
bashio::log.green "... reinstall ongoing, please wait"
|
||||||
if [ -f /data/config/www/nextcloud/index.php ]; then rm /data/config/www/nextcloud/index.php; fi && \
|
if [ -f /data/config/www/nextcloud/index.php ]; then rm /data/config/www/nextcloud/index.php; fi && \
|
||||||
|
# INSTALL
|
||||||
/./etc/s6-overlay/s6-rc.d/init-nextcloud-config/run
|
/./etc/s6-overlay/s6-rc.d/init-nextcloud-config/run
|
||||||
occ upgrade &>/proc/1/fd/1 || true
|
# RESET PERMISSIONS
|
||||||
|
/./etc/cont-init.d/01-folders.sh
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:repair-share-owner"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||||
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ maintenance:mode --off"
|
||||||
fi
|
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"
|
|
||||||
|
|||||||
@@ -10,29 +10,26 @@ if [ -f /data/config/www/nextcloud/version.php ]; then
|
|||||||
else
|
else
|
||||||
CURRENTVERSION="Not found"
|
CURRENTVERSION="Not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check container version
|
# Check container version
|
||||||
CONTAINERVERSION="$(cat /nextcloudversion)"
|
CONTAINERVERSION="$(cat /nextcloudversion)"
|
||||||
|
|
||||||
# Inform if new version available
|
# Inform if new version available
|
||||||
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
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
|
# 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"
|
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
|
while [[ $(occ update:check 2>&1) == *"update available"* ]]; do
|
||||||
bashio::log.yellow "-----------------------------------------------------------------------"
|
bashio::log.yellow "-----------------------------------------------------------------------"
|
||||||
bashio::log.yellow " new version available, updating. Please do not turn off your addon! "
|
bashio::log.yellow " new version available, updating. Please do not turn off your addon! "
|
||||||
bashio::log.yellow "-----------------------------------------------------------------------"
|
bashio::log.yellow "-----------------------------------------------------------------------"
|
||||||
updater.phar --no-interaction
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/updater/updater.phar --no-interaction"
|
||||||
occ upgrade
|
sudo -u abc -s /bin/bash -c "php /data/config/www/nextcloud/occ upgrade"
|
||||||
done
|
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 " "
|
||||||
bashio::log.yellow "New version available : $CONTAINERVERSION"
|
bashio::log.yellow "New version available : $CONTAINERVERSION"
|
||||||
bashio::log.yellow "...auto_updater not set in addon options, please update from nextcloud settings"
|
bashio::log.yellow "...auto_updater not set in addon options, please update from nextcloud settings"
|
||||||
@@ -42,14 +39,4 @@ fi
|
|||||||
# RESET PERMISSIONS #
|
# RESET PERMISSIONS #
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
PUID=$(bashio::config "PUID")
|
/./01-folders.sh
|
||||||
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"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user