mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
[enh] Handle the migration from ownCloud app
This commit is contained in:
parent
b7fc5e184a
commit
91d3d800b2
3 changed files with 121 additions and 16 deletions
36
README.md
36
README.md
|
@ -11,10 +11,6 @@ you can synchronize your files over your devices.
|
|||
|
||||

|
||||
|
||||
## TODO
|
||||
|
||||
* Manage the upgrade from ownCloud
|
||||
|
||||
## Features
|
||||
|
||||
In addition to Nextcloud core features, the following are made available with
|
||||
|
@ -36,6 +32,38 @@ Also, note we made the choice to disable third-parties applications at the
|
|||
upgrade. It allows to prevent an unstable - and sometimes broken - Nextcloud
|
||||
installation. You will just have to manually activate them after the upgrade.
|
||||
|
||||
## Migrate from ownCloud
|
||||
|
||||
**This is not considered as stable yet, please do it with care and only for
|
||||
testing!**
|
||||
|
||||
This package handle the migration from ownCloud to Nextcloud. For that, your
|
||||
ownCloud application must be **up-to-date** in YunoHost.
|
||||
|
||||
You will then have to upgrade your ownCloud application with this repository.
|
||||
This can only be done from the command-line interface - e.g. through SSH. Once
|
||||
you're connected, you simply have to execute the following:
|
||||
|
||||
```bash
|
||||
sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/nextcloud_ynh owncloud --verbose
|
||||
```
|
||||
|
||||
The `--verbose` option will let you see the full output. If you encounter any
|
||||
issue, please paste it.
|
||||
|
||||
Note that a cron job will be executed at some time after the end of this
|
||||
command. You must wait that before doing any other application operations!
|
||||
You should see that Nextcloud is installed after that.
|
||||
|
||||
Note that it does not change the application label nor the URL. To rename
|
||||
the label, you can execute the following - replace `Nextcloud` with whatever
|
||||
you want:
|
||||
|
||||
```bash
|
||||
sudo yunohost app setting nextcloud label -v "Nextcloud"
|
||||
sudo yunohost app ssowatconf
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://dev.yunohost.org/projects/apps/issues
|
||||
|
|
21
conf/owncloud-migration.sh
Normal file
21
conf/owncloud-migration.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -u
|
||||
|
||||
app="#APP#"
|
||||
|
||||
# rename hook
|
||||
hooks_dir="/etc/yunohost/hooks.d/post_user_create"
|
||||
[[ -f "${hooks_dir}/50-${app}" ]] \
|
||||
&& mv "${hooks_dir}/50-${app}" "${hooks_dir}/50-nextcloud"
|
||||
|
||||
# move yunohost app settings
|
||||
apps_dir="/etc/yunohost/apps"
|
||||
if [[ -d "${apps_dir}/${app}" ]]; then
|
||||
yunohost app setting "$app" id -v nextcloud
|
||||
mv "${apps_dir}/${app}" "${apps_dir}/nextcloud"
|
||||
yunohost app ssowatconf --quiet
|
||||
fi
|
||||
|
||||
# remove cron job
|
||||
rm /etc/cron.d/owncloud-migration
|
|
@ -10,20 +10,59 @@ app=$APPNAME
|
|||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# FIXME: Upgrading from ownCloud is not supported yet,
|
||||
# see http://blog.jospoortvliet.com/2016/06/migrating-to-nextcloud-9.html
|
||||
[[ $YNH_APP_INSTANCE_NAME == $app ]] || ynh_die \
|
||||
"Upgrading from ownCloud to Nextcloud is not supported yet."
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Migrate from ownCloud to Nextcloud
|
||||
if [[ $YNH_APP_INSTANCE_NAME != $app ]]; then
|
||||
[[ $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 domain setting
|
||||
real_app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$real_app" domain)
|
||||
|
||||
# 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 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"
|
||||
sudo rm -rf "$DESTDIR" "/home/yunohost.app/$app"
|
||||
|
||||
# rename ownCloud folders
|
||||
sudo mv "/var/www/$real_app" "$DESTDIR"
|
||||
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"
|
||||
|
||||
# rename ownCloud system group and account
|
||||
sudo groupmod -n "$app" "$real_app"
|
||||
sudo usermod -l "$app" "$real_app"
|
||||
else
|
||||
real_app=$app
|
||||
fi
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
domain=$(ynh_app_setting_get "$real_app" domain)
|
||||
path=$(ynh_app_setting_get "$real_app" path)
|
||||
path=${path%/}
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
user_home=$(ynh_app_setting_get "$app" user_home)
|
||||
dbpass=$(ynh_app_setting_get "$real_app" mysqlpwd)
|
||||
user_home=$(ynh_app_setting_get "$real_app" user_home)
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
|
@ -122,7 +161,7 @@ if [[ -z "${user_home:-}" ]]; then
|
|||
sudo cat "${DATADIR}/mount.json" >/dev/null 2>&1 \
|
||||
&& user_home=1 \
|
||||
|| user_home=0
|
||||
ynh_app_setting_set "$app" user_home "$user_home"
|
||||
ynh_app_setting_set "$real_app" user_home "$user_home"
|
||||
fi
|
||||
|
||||
# Enable External Storage and create local mount to home folder as needed
|
||||
|
@ -161,8 +200,8 @@ sudo chmod 640 "${DESTDIR}/config/config.php"
|
|||
sudo chmod 755 /home/yunohost.app
|
||||
|
||||
# Set SSOwat rules
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
ynh_app_setting_set "$app" skipped_regex \
|
||||
ynh_app_setting_set "$real_app" unprotected_uris "/"
|
||||
ynh_app_setting_set "$real_app" skipped_regex \
|
||||
"$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*"
|
||||
|
||||
# Reload services
|
||||
|
@ -177,6 +216,23 @@ sudo cp ../conf/nextcloud.cron "$cron_path"
|
|||
sudo chmod 644 "$cron_path"
|
||||
_exec_occ background:cron
|
||||
|
||||
# Finish ownCloud migration
|
||||
if [[ $real_app != $app ]]; then
|
||||
echo "ownCloud has been successfully migrated to Nextcloud! \
|
||||
A last scheduled operation will run in a couple of minutes to finish the \
|
||||
migration in YunoHost side. Do not proceed any application operation while \
|
||||
you don't see Nextcloud as installed." >&2
|
||||
|
||||
# install cron job and script for final migration step
|
||||
script_path="/usr/local/sbin/owncloud-migration.sh"
|
||||
sed -i "s@#APP#@${real_app}@g" ../conf/owncloud-migration.sh
|
||||
sudo cp ../conf/owncloud-migration.sh "$script_path"
|
||||
sudo chmod 755 "$script_path"
|
||||
cron_path="/etc/cron.d/owncloud-migration"
|
||||
echo "*/1 * * * * root $script_path" | sudo tee "$cron_path" >/dev/null
|
||||
sudo chmod 644 "$cron_path"
|
||||
fi
|
||||
|
||||
# Warn about possible disabled apps
|
||||
echo "Note that if you've installed some third-parties Nextcloud applications, \
|
||||
they are probably disabled and you'll have to manually activate them again." >&2
|
||||
|
|
Loading…
Add table
Reference in a new issue