mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
Mise à jour séquentielle des versions majeures
This commit is contained in:
parent
0adefb1055
commit
301ad274e1
7 changed files with 185 additions and 84 deletions
|
@ -5,7 +5,7 @@
|
||||||
APPNAME="nextcloud"
|
APPNAME="nextcloud"
|
||||||
|
|
||||||
# Nextcloud version
|
# Nextcloud version
|
||||||
VERSION="11.0.0"
|
LAST_VERSION="11.0.0"
|
||||||
|
|
||||||
# Package name for Nextcloud dependencies
|
# Package name for Nextcloud dependencies
|
||||||
DEPS_PKG_NAME="nextcloud-deps"
|
DEPS_PKG_NAME="nextcloud-deps"
|
||||||
|
@ -13,9 +13,6 @@ DEPS_PKG_NAME="nextcloud-deps"
|
||||||
# Remote URL to fetch Nextcloud tarball
|
# Remote URL to fetch Nextcloud tarball
|
||||||
NEXTCLOUD_SOURCE_URL="https://download.nextcloud.com/server/releases/nextcloud-${VERSION}.tar.bz2"
|
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
|
# App package root directory should be the parent folder
|
||||||
PKGDIR=$(cd ../; pwd)
|
PKGDIR=$(cd ../; pwd)
|
||||||
|
|
||||||
|
|
100
scripts/upgrade
100
scripts/upgrade
|
@ -5,14 +5,15 @@ source ./_common.sh
|
||||||
|
|
||||||
# Set app specific variables
|
# Set app specific variables
|
||||||
app=$APPNAME
|
app=$APPNAME
|
||||||
|
real_app=$YNH_APP_INSTANCE_NAME # real_app prendra la valeur nextcloud ou owncloud dans le cas d'une migration
|
||||||
dbname=$app
|
dbname=$app
|
||||||
dbuser=$app
|
dbuser=$app
|
||||||
|
|
||||||
# Backup the current version of the app, restore it if the upgrade fails
|
# 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
|
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 $app-before-upgrade
|
sudo yunohost backup delete $real_app-before-upgrade
|
||||||
fi
|
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_PROPERLY () {
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
if [ "$exit_code" -eq 0 ]; then
|
||||||
|
@ -20,8 +21,8 @@ EXIT_PROPERLY () {
|
||||||
fi
|
fi
|
||||||
trap '' EXIT
|
trap '' EXIT
|
||||||
set +eu
|
set +eu
|
||||||
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
|
sudo yunohost app remove $real_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 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."
|
ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade."
|
||||||
}
|
}
|
||||||
set -eu
|
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.
|
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_APP_ID == owncloud ]] \
|
||||||
|| ynh_die "Incompatible application to migrate to Nextcloud"
|
|| 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.
|
real_app=$YNH_APP_INSTANCE_NAME # real_app prend le nom de owncloud.
|
||||||
domain=$(ynh_app_setting_get "$real_app" domain)
|
./upgrade.d/owncloud.sh # Prépare la migration de owncloud vers nextcloud.
|
||||||
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"
|
|
||||||
else
|
else
|
||||||
real_app=$app
|
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.
|
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
|
# Effectue les mises à majeures une à une. Le saut de mise à jour n'étant pas supporté.
|
||||||
nc_conf="${DESTDIR}/config.json"
|
major_version=${LAST_VERSION%%.*} # La version majeure correspond à la première partie du numéro de version.
|
||||||
sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json
|
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
|
||||||
sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json
|
actual_major_version=${actual_version%%.*}
|
||||||
sudo cp ../conf/config.json "${TMPDIR}/config.json"
|
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
|
||||||
# Enable maintenance mode
|
actual_version=$(cat "$DESTDIR/version.php" | grep OC_VersionString | cut -d\' -f2) # Relève le nouveau numéro de version, après mise à jour.
|
||||||
_exec_occ maintenance:mode --on
|
actual_major_version=${actual_version%%.*}
|
||||||
|
|
||||||
# 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
|
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
|
# Ensure that UpdateNotification app is disabled
|
||||||
_exec_occ app:disable updatenotification
|
_exec_occ app:disable updatenotification
|
||||||
|
|
||||||
# Enable plugins and set Nextcloud configuration
|
# Enable plugins and set Nextcloud configuration
|
||||||
_exec_occ app:enable user_ldap
|
_exec_occ app:enable user_ldap
|
||||||
|
nc_conf="${DESTDIR}/config.json"
|
||||||
_exec_occ config:import "$nc_conf"
|
_exec_occ config:import "$nc_conf"
|
||||||
sudo rm -f "$nc_conf"
|
sudo rm -f "$nc_conf"
|
||||||
|
|
||||||
|
|
62
scripts/upgrade.d/owncloud.sh
Executable file
62
scripts/upgrade.d/owncloud.sh
Executable file
|
@ -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"
|
18
scripts/upgrade.d/upgrade.10.sh
Executable file
18
scripts/upgrade.d/upgrade.10.sh
Executable file
|
@ -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
|
18
scripts/upgrade.d/upgrade.9.sh
Executable file
18
scripts/upgrade.d/upgrade.9.sh
Executable file
|
@ -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
|
48
scripts/upgrade.d/upgrade.generic.sh
Executable file
48
scripts/upgrade.d/upgrade.generic.sh
Executable file
|
@ -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")
|
||||||
|
}
|
18
scripts/upgrade.d/upgrade.last.sh
Executable file
18
scripts/upgrade.d/upgrade.last.sh
Executable file
|
@ -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
|
Loading…
Add table
Reference in a new issue