From 134f67d2a0a357badfcbafd5e66a0d5af6ee3b8d Mon Sep 17 00:00:00 2001 From: jeromelebleu Date: Fri, 6 Jan 2017 10:21:14 +0100 Subject: [PATCH 1/3] I'm not the maintainer anymore regarding last changes --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index ebb2827..a521c27 100644 --- a/manifest.json +++ b/manifest.json @@ -10,8 +10,8 @@ "license": "AGPL-3", "version": "11.0.0", "maintainer": { - "name": "jerome", - "email": "jerome@yunohost.org" + "name": "-", + "email": "-" }, "multi_instance": false, "services": [ From 0adefb10555e576856534b730d47b1a24db06b0f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 6 Jan 2017 13:13:42 +0100 Subject: [PATCH 2/3] SECURE_REMOVE et commentaires --- scripts/_common.sh | 28 ++++++++++++++++++++++++++++ scripts/upgrade | 33 +++++++++++++++++---------------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index fcbfc4b..f285497 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -108,3 +108,31 @@ rename_mysql_db() { ynh_mysql_drop_user "$DBUSER" rm "$SQLPATH" } + +SECURE_REMOVE () { # Suppression de dossier avec vérification des variables + chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables. + no_var=0 + while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine + do + no_var=1 + global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée. + only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière. + real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable. + if test -z "$real_var" || [ "$real_var" = "/" ]; then + echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2 + return 1 + fi + chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine. + done + if [ "$no_var" -eq 1 ] + then + if [ -e "$chaine" ]; then + echo "Delete directory $chaine" + sudo rm -rf "$chaine" + fi + return 0 + else + echo "No detected variable." >&2 + return 1 + fi +} diff --git a/scripts/upgrade b/scripts/upgrade index 526e0ee..1e81c40 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,7 +31,7 @@ trap EXIT_PROPERLY EXIT source /usr/share/yunohost/helpers # Migrate from ownCloud to Nextcloud -if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then +if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then # Si le nom de l'app donné lors de la commande n'est pas nextcloud, vérifie si c'est owncloud pour lancer la migration. [[ $YNH_APP_ID == owncloud ]] \ || ynh_die "Incompatible application to migrate to Nextcloud" @@ -40,7 +40,7 @@ if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then && ynh_die "Nextcloud is already installed" # retrieve ownCloud app settings - real_app=$YNH_APP_INSTANCE_NAME + real_app=$YNH_APP_INSTANCE_NAME # real_app prend le nom de owncloud. domain=$(ynh_app_setting_get "$real_app" domain) oc_dbpass=$(ynh_app_setting_get "$real_app" mysqlpwd) oc_dbname=$real_app @@ -52,7 +52,7 @@ if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then "/etc/php5/fpm/pool.d/${real_app}.conf" \ "/etc/cron.d/${real_app}" - # reload services to disable ownCloud + # reload services to disable php-fpm and nginx config for ownCloud sudo service php5-fpm reload || true sudo service nginx reload || true @@ -62,13 +62,14 @@ if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then # clean new destination and data directories DESTDIR="/var/www/$app" DATADIR="/home/yunohost.app/${app}/data" - sudo rm -rf "$DESTDIR" "/home/yunohost.app/$app" + SECURE_REMOVE '$DESTDIR' # Supprime le dossier de nextcloud dans /var/www le cas échéant + SECURE_REMOVE '/home/yunohost.app/$app' # Et dans yunohost.app # rename ownCloud folders - sudo mv "/var/www/$real_app" "$DESTDIR" + sudo mv "/var/www/$real_app" "$DESTDIR" # Puis renomme les dossiers de owncloud en nextcloud sudo mv "/home/yunohost.app/$real_app" "/home/yunohost.app/$app" sudo sed -ri "s#^(\s*'datadirectory' =>).*,#\1 '${DATADIR}',#" \ - "/var/www/${app}/config/config.php" + "/var/www/${app}/config/config.php" # Change l'emplacement du dossier de data dans le fichier de config # rename the MySQL database rename_mysql_db "$oc_dbname" "$oc_dbuser" "$oc_dbpass" "$dbname" "$dbuser" @@ -85,10 +86,10 @@ else # handle old migrations from ownCloud curr_dbname=$(sudo cat "/var/www/${app}/config/config.php" \ - | grep dbname | sed "s|.*=> '\(.*\)'.*|\1|g") - if [[ $curr_dbname != $dbname ]]; then + | grep dbname | sed "s|.*=> '\(.*\)'.*|\1|g") # Prend le nom de la bdd dans le fichier de config + if [[ $curr_dbname != $dbname ]]; then # Si le nom de la base de donnée n'est pas nextcloud, renomme la base de donnée. curr_dbuser=$(sudo cat "/var/www/${app}/config/config.php" \ - | grep dbuser | sed "s|.*=> '\(.*\)'.*|\1|g") + | grep dbuser | sed "s|.*=> '\(.*\)'.*|\1|g") # Prend le nom d'utilisateur de la bdd dbpass=$(ynh_app_setting_get "$real_app" mysqlpwd) # rename the MySQL database @@ -156,12 +157,12 @@ sed -i "s@#GROUP#@${app}@g" ../hooks/post_user_create # occ helper for the current installation _exec_occ() { - exec_occ "$DESTDIR" "$app" $@ + exec_occ "$DESTDIR" "$app" $@ # Appel de php occ avec les droits de l'user nextcloud. A noter que ce n'est là que la déclaration de la fonction qui sera appelée plus tard. } # Retrieve new Nextcloud sources in a temporary directory -TMPDIR=$(ynh_mkdir_tmp) -extract_nextcloud "$TMPDIR" +TMPDIR=$(mktemp -d) +extract_nextcloud "$TMPDIR" # Télécharge nextcloud, vérifie sa somme de contrôle et le décompresse. # Copy Nextcloud configuration file nc_conf="${DESTDIR}/config.json" @@ -180,8 +181,8 @@ for a in $(sudo ls "${DESTDIR}/apps"); do done # Rename existing app directory and move new one -sudo rm -rf "${DESTDIR}" -sudo mv "$TMPDIR" "$DESTDIR" +SECURE_REMOVE '${DESTDIR}' # Supprime le dossier actuel de nextcloud +sudo mv "$TMPDIR" "$DESTDIR" # Et le remplace par la nouvelle version du dossier temporaire # Set app folders ownership sudo chown -R $app: "$DESTDIR" "$DATADIR" @@ -201,10 +202,10 @@ _exec_occ config:import "$nc_conf" sudo rm -f "$nc_conf" # Guess user_home value if empty -if [[ -z "${user_home:-}" ]]; then +if [[ -z "${user_home:-}" ]]; then # user_home correspond au champs "Access the users home folder from Nextcloud?" du manifest sudo cat "${DATADIR}/mount.json" >/dev/null 2>&1 \ && user_home=1 \ - || user_home=0 + || user_home=0 # Test l'existence du fichier mount.json pour connaître la valeur de user_home, dans le cas où la valeur ne serait pas renseignée. (Mais ce fichier semble ne plus exister...) ynh_app_setting_set "$real_app" user_home "$user_home" fi From 301ad274e1eb061153527efe5a26242d2a332cc1 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 7 Jan 2017 02:29:55 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Mise=20=C3=A0=20jour=20s=C3=A9quentielle=20?= =?UTF-8?q?des=20versions=20majeures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/_common.sh | 5 +- scripts/upgrade | 100 ++++++--------------------- scripts/upgrade.d/owncloud.sh | 62 +++++++++++++++++ scripts/upgrade.d/upgrade.10.sh | 18 +++++ scripts/upgrade.d/upgrade.9.sh | 18 +++++ scripts/upgrade.d/upgrade.generic.sh | 48 +++++++++++++ scripts/upgrade.d/upgrade.last.sh | 18 +++++ 7 files changed, 185 insertions(+), 84 deletions(-) create mode 100755 scripts/upgrade.d/owncloud.sh create mode 100755 scripts/upgrade.d/upgrade.10.sh create mode 100755 scripts/upgrade.d/upgrade.9.sh create mode 100755 scripts/upgrade.d/upgrade.generic.sh create mode 100755 scripts/upgrade.d/upgrade.last.sh diff --git a/scripts/_common.sh b/scripts/_common.sh index f285497..743434c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ APPNAME="nextcloud" # Nextcloud version -VERSION="11.0.0" +LAST_VERSION="11.0.0" # Package name for Nextcloud dependencies DEPS_PKG_NAME="nextcloud-deps" @@ -13,9 +13,6 @@ DEPS_PKG_NAME="nextcloud-deps" # Remote URL to fetch Nextcloud tarball NEXTCLOUD_SOURCE_URL="https://download.nextcloud.com/server/releases/nextcloud-${VERSION}.tar.bz2" -# Remote URL to fetch Nextcloud tarball checksum -NEXTCLOUD_SOURCE_SHA256="5bdfcb36c5cf470b9a6679034cabf88bf1e50a9f3e47c08d189cc2280b621429" - # App package root directory should be the parent folder PKGDIR=$(cd ../; pwd) diff --git a/scripts/upgrade b/scripts/upgrade index 1e81c40..fb84763 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -5,14 +5,15 @@ source ./_common.sh # Set app specific variables app=$APPNAME +real_app=$YNH_APP_INSTANCE_NAME # real_app prendra la valeur nextcloud ou owncloud dans le cas d'une migration dbname=$app dbuser=$app # Backup the current version of the app, restore it if the upgrade fails -if sudo yunohost backup list | grep -q $app-before-upgrade > /dev/null 2>&1; then # Supprime l'ancienne archive seulement si elle existe - sudo yunohost backup delete $app-before-upgrade +if sudo yunohost backup list | grep -q $real_app-before-upgrade > /dev/null 2>&1; then # Supprime l'ancienne archive seulement si elle existe + sudo yunohost backup delete $real_app-before-upgrade fi -sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade +sudo yunohost backup create --ignore-hooks --apps $real_app --name $real_app-before-upgrade EXIT_PROPERLY () { exit_code=$? if [ "$exit_code" -eq 0 ]; then @@ -20,8 +21,8 @@ EXIT_PROPERLY () { fi trap '' EXIT set +eu - sudo yunohost app remove $app # Supprime l'application avant de la restaurer. - sudo yunohost backup restore --ignore-hooks $app-before-upgrade --apps $app --force # Restore the backup if upgrade failed + sudo yunohost app remove $real_app # Supprime l'application avant de la restaurer. + sudo yunohost backup restore --ignore-hooks $real_app-before-upgrade --apps $real_app --force # Restore the backup if upgrade failed ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade." } set -eu @@ -34,53 +35,8 @@ source /usr/share/yunohost/helpers if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then # Si le nom de l'app donné lors de la commande n'est pas nextcloud, vérifie si c'est owncloud pour lancer la migration. [[ $YNH_APP_ID == owncloud ]] \ || ynh_die "Incompatible application to migrate to Nextcloud" - - # check that Nextcloud is not already installed - (sudo yunohost app list --installed -f "$app" | grep -q id) \ - && ynh_die "Nextcloud is already installed" - - # retrieve ownCloud app settings real_app=$YNH_APP_INSTANCE_NAME # real_app prend le nom de owncloud. - domain=$(ynh_app_setting_get "$real_app" domain) - oc_dbpass=$(ynh_app_setting_get "$real_app" mysqlpwd) - oc_dbname=$real_app - oc_dbuser=$real_app - - # remove nginx and php-fpm configuration files - sudo rm -f \ - "/etc/nginx/conf.d/${domain}.d/${real_app}.conf" \ - "/etc/php5/fpm/pool.d/${real_app}.conf" \ - "/etc/cron.d/${real_app}" - - # reload services to disable php-fpm and nginx config for ownCloud - sudo service php5-fpm reload || true - sudo service nginx reload || true - - # remove dependencies package - ynh_package_remove owncloud-deps || true - - # clean new destination and data directories - DESTDIR="/var/www/$app" - DATADIR="/home/yunohost.app/${app}/data" - SECURE_REMOVE '$DESTDIR' # Supprime le dossier de nextcloud dans /var/www le cas échéant - SECURE_REMOVE '/home/yunohost.app/$app' # Et dans yunohost.app - - # rename ownCloud folders - sudo mv "/var/www/$real_app" "$DESTDIR" # Puis renomme les dossiers de owncloud en nextcloud - sudo mv "/home/yunohost.app/$real_app" "/home/yunohost.app/$app" - sudo sed -ri "s#^(\s*'datadirectory' =>).*,#\1 '${DATADIR}',#" \ - "/var/www/${app}/config/config.php" # Change l'emplacement du dossier de data dans le fichier de config - - # rename the MySQL database - rename_mysql_db "$oc_dbname" "$oc_dbuser" "$oc_dbpass" "$dbname" "$dbuser" - sudo sed -ri "s#^(\s*'dbname' =>).*,#\1 '${dbname}',#" \ - "/var/www/${app}/config/config.php" - sudo sed -ri "s#^(\s*'dbuser' =>).*,#\1 '${dbuser}',#" \ - "/var/www/${app}/config/config.php" - - # rename ownCloud system group and account - sudo groupmod -n "$app" "$real_app" - sudo usermod -l "$app" "$real_app" + ./upgrade.d/owncloud.sh # Prépare la migration de owncloud vers nextcloud. else real_app=$app @@ -160,44 +116,28 @@ _exec_occ() { exec_occ "$DESTDIR" "$app" $@ # Appel de php occ avec les droits de l'user nextcloud. A noter que ce n'est là que la déclaration de la fonction qui sera appelée plus tard. } -# Retrieve new Nextcloud sources in a temporary directory -TMPDIR=$(mktemp -d) -extract_nextcloud "$TMPDIR" # Télécharge nextcloud, vérifie sa somme de contrôle et le décompresse. -# Copy Nextcloud configuration file -nc_conf="${DESTDIR}/config.json" -sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json -sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json -sudo cp ../conf/config.json "${TMPDIR}/config.json" - -# Enable maintenance mode -_exec_occ maintenance:mode --on - -# Copy config and 3rd party applications from current directory -sudo cp -a "${DESTDIR}/config/config.php" "${TMPDIR}/config/config.php" -for a in $(sudo ls "${DESTDIR}/apps"); do - [[ ! -d "${TMPDIR}/apps/$a" ]] \ - && sudo cp -a "${DESTDIR}/apps/$a" "${TMPDIR}/apps/$a" +# Effectue les mises à majeures une à une. Le saut de mise à jour n'étant pas supporté. +major_version=${LAST_VERSION%%.*} # La version majeure correspond à la première partie du numéro de version. +actual_version=$(cat "$DESTDIR/version.php" | grep OC_VersionString | cut -d\' -f2) # Relève le numéro de version de l'instance nextcloud installée +actual_major_version=${actual_version%%.*} +while [ "$major_version" -ne "$actual_major_version" ]; do # Si la version majeure actuelle ne correspond à la dernière version majeure. + ./upgrade.d/upgrade.$actual_major_version.sh # Exécute la mise à jour vers la version majeure suivante + actual_version=$(cat "$DESTDIR/version.php" | grep OC_VersionString | cut -d\' -f2) # Relève le nouveau numéro de version, après mise à jour. + actual_major_version=${actual_version%%.*} done +if [ "$LAST_VERSION" != "$actual_version" ] # Si la version actuelle ne correspond à la dernière version, une mise à jour est nécessaire pour passer à la dernière version mineure. +then + ./upgrade.d/upgrade.last.sh # Exécute la mise à jour vers la dernière version prise en charge. +fi -# Rename existing app directory and move new one -SECURE_REMOVE '${DESTDIR}' # Supprime le dossier actuel de nextcloud -sudo mv "$TMPDIR" "$DESTDIR" # Et le remplace par la nouvelle version du dossier temporaire - -# Set app folders ownership -sudo chown -R $app: "$DESTDIR" "$DATADIR" - -# Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3) -# TODO: Restore old directory in case of failure? -_exec_occ maintenance:mode --off -_exec_occ upgrade \ - || ([[ $? -eq 3 ]] || ynh_die "Unable to upgrade Nextcloud") # Ensure that UpdateNotification app is disabled _exec_occ app:disable updatenotification # Enable plugins and set Nextcloud configuration _exec_occ app:enable user_ldap +nc_conf="${DESTDIR}/config.json" _exec_occ config:import "$nc_conf" sudo rm -f "$nc_conf" diff --git a/scripts/upgrade.d/owncloud.sh b/scripts/upgrade.d/owncloud.sh new file mode 100755 index 0000000..308a498 --- /dev/null +++ b/scripts/upgrade.d/owncloud.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Préparation à la migration de owncloud 9 vers nextcloud. +# La migration sera effective lors de la mise à joru qui suivra + +# Load common variables and helpers +source ./_common.sh + +# Source app helpers +source /usr/share/yunohost/helpers + +# Set app specific variables +app=$APPNAME +dbname=$app +dbuser=$app + +# check that Nextcloud is not already installed +(sudo yunohost app list --installed -f "$app" | grep -q id) \ +&& ynh_die "Nextcloud is already installed" + +# retrieve ownCloud app settings +real_app=$YNH_APP_INSTANCE_NAME # real_app prend le nom de owncloud. +domain=$(ynh_app_setting_get "$real_app" domain) +oc_dbpass=$(ynh_app_setting_get "$real_app" mysqlpwd) +oc_dbname=$real_app +oc_dbuser=$real_app + +# remove nginx and php-fpm configuration files +sudo rm -f \ + "/etc/nginx/conf.d/${domain}.d/${real_app}.conf" \ + "/etc/php5/fpm/pool.d/${real_app}.conf" \ + "/etc/cron.d/${real_app}" + +# reload services to disable php-fpm and nginx config for ownCloud +sudo service php5-fpm reload || true +sudo service nginx reload || true + +# remove dependencies package +ynh_package_remove owncloud-deps || true + +# clean new destination and data directories +DESTDIR="/var/www/$app" +DATADIR="/home/yunohost.app/${app}/data" +SECURE_REMOVE '$DESTDIR' # Supprime le dossier de nextcloud dans /var/www le cas échéant +SECURE_REMOVE '/home/yunohost.app/$app' # Et dans yunohost.app + +# rename ownCloud folders +sudo mv "/var/www/$real_app" "$DESTDIR" # Puis renomme les dossiers de owncloud en nextcloud +sudo mv "/home/yunohost.app/$real_app" "/home/yunohost.app/$app" +sudo sed -ri "s#^(\s*'datadirectory' =>).*,#\1 '${DATADIR}',#" \ + "/var/www/${app}/config/config.php" # Change l'emplacement du dossier de data dans le fichier de config + +# rename the MySQL database +rename_mysql_db "$oc_dbname" "$oc_dbuser" "$oc_dbpass" "$dbname" "$dbuser" +sudo sed -ri "s#^(\s*'dbname' =>).*,#\1 '${dbname}',#" \ + "/var/www/${app}/config/config.php" +sudo sed -ri "s#^(\s*'dbuser' =>).*,#\1 '${dbuser}',#" \ + "/var/www/${app}/config/config.php" + +# rename ownCloud system group and account +sudo groupmod -n "$app" "$real_app" +sudo usermod -l "$app" "$real_app" diff --git a/scripts/upgrade.d/upgrade.10.sh b/scripts/upgrade.d/upgrade.10.sh new file mode 100755 index 0000000..802fc8d --- /dev/null +++ b/scripts/upgrade.d/upgrade.10.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Version cible de la mise à jour de Nextcloud +VERSION="11.0.0" + +# Nextcloud tarball checksum +NEXTCLOUD_SOURCE_SHA256="5bdfcb36c5cf470b9a6679034cabf88bf1e50a9f3e47c08d189cc2280b621429" + +# Load common variables and helpers +source ./_common.sh + +# Source app helpers +source /usr/share/yunohost/helpers + +# Load common upgrade function +source ./upgrade.d/upgrade.generic.sh + +COMMON_UPGRADE # Met à jour Nextcloud vers la version suivante diff --git a/scripts/upgrade.d/upgrade.9.sh b/scripts/upgrade.d/upgrade.9.sh new file mode 100755 index 0000000..f4a9985 --- /dev/null +++ b/scripts/upgrade.d/upgrade.9.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Version cible de la mise à jour de Nextcloud +VERSION="10.0.2" + +# Nextcloud tarball checksum +NEXTCLOUD_SOURCE_SHA256="a687a818778413484f06bb23b4e98589c73729fe2aa9feb1bf5584e3bd37103c" + +# Load common variables and helpers +source ./_common.sh + +# Source app helpers +source /usr/share/yunohost/helpers + +# Load common upgrade function +source ./upgrade.d/upgrade.generic.sh + +COMMON_UPGRADE # Met à jour Nextcloud vers la version suivante diff --git a/scripts/upgrade.d/upgrade.generic.sh b/scripts/upgrade.d/upgrade.generic.sh new file mode 100755 index 0000000..a80d706 --- /dev/null +++ b/scripts/upgrade.d/upgrade.generic.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Fonction rassemblant les opérations communes de mise à jour. + +# occ helper for the current installation +_exec_occ() { + exec_occ "$DESTDIR" "$app" $@ # Appel de php occ avec les droits de l'user nextcloud. A noter que ce n'est là que la déclaration de la fonction qui sera appelée plus tard. +} + +COMMON_UPGRADE () { + app=$APPNAME + DESTDIR="/var/www/$app" + DATADIR="/home/yunohost.app/$app/data" + domain=$(ynh_app_setting_get "$YNH_APP_INSTANCE_NAME" domain) # Utilise $YNH_APP_INSTANCE_NAME au lieu de $app pour utiliser la config de owncloud en cas de migration + + # Retrieve new Nextcloud sources in a temporary directory + TMPDIR=$(mktemp -d) + extract_nextcloud "$TMPDIR" # Télécharge nextcloud, vérifie sa somme de contrôle et le décompresse. + + # Copy Nextcloud configuration file + sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json + sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json + sudo cp ../conf/config.json "${TMPDIR}/config.json" + + # Enable maintenance mode + _exec_occ maintenance:mode --on + + # Copy config and 3rd party applications from current directory + sudo cp -a "${DESTDIR}/config/config.php" "${TMPDIR}/config/config.php" + for a in $(sudo ls "${DESTDIR}/apps"); do + [[ ! -d "${TMPDIR}/apps/$a" ]] \ + && sudo cp -a "${DESTDIR}/apps/$a" "${TMPDIR}/apps/$a" + done + + # Rename existing app directory and move new one + SECURE_REMOVE '$DESTDIR' # Supprime le dossier actuel de nextcloud + sudo mv "$TMPDIR" "$DESTDIR" # Et le remplace par la nouvelle version du dossier temporaire + sudo chmod +x "$DESTDIR" + + # Set app folders ownership + sudo chown -R $app: "$DESTDIR" "$DATADIR" + + # Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3) + # TODO: Restore old directory in case of failure? + _exec_occ maintenance:mode --off + _exec_occ upgrade \ + || ([[ $? -eq 3 ]] || ynh_die "Unable to upgrade Nextcloud") +} diff --git a/scripts/upgrade.d/upgrade.last.sh b/scripts/upgrade.d/upgrade.last.sh new file mode 100755 index 0000000..802fc8d --- /dev/null +++ b/scripts/upgrade.d/upgrade.last.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Version cible de la mise à jour de Nextcloud +VERSION="11.0.0" + +# Nextcloud tarball checksum +NEXTCLOUD_SOURCE_SHA256="5bdfcb36c5cf470b9a6679034cabf88bf1e50a9f3e47c08d189cc2280b621429" + +# Load common variables and helpers +source ./_common.sh + +# Source app helpers +source /usr/share/yunohost/helpers + +# Load common upgrade function +source ./upgrade.d/upgrade.generic.sh + +COMMON_UPGRADE # Met à jour Nextcloud vers la version suivante