committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 1567 additions and 1002 deletions
-
2README.md
-
12check_process
-
6conf/app.src.default
-
18conf/nextcloud-deps.control
-
34conf/nginx.conf
-
21conf/owncloud-migration.sh
-
13conf/owncloud_migration
-
45conf/owncloud_post_migration.sh
-
388conf/php-fpm.conf
-
12manifest.json
-
509scripts/_common.sh
-
110scripts/backup
-
363scripts/install
-
104scripts/remove
-
204scripts/restore
-
549scripts/upgrade
-
64scripts/upgrade.d/owncloud.sh
-
15scripts/upgrade.d/upgrade.10.sh
-
15scripts/upgrade.d/upgrade.11.sh
-
15scripts/upgrade.d/upgrade.9.sh
-
53scripts/upgrade.d/upgrade.generic.sh
-
17scripts/upgrade.d/upgrade.last.sh
-
0sources/patches/00-add-logout_url-conf.patch
@ -0,0 +1,6 @@ |
|||
SOURCE_URL=https://download.nextcloud.com/server/releases/nextcloud-__VERSION__.tar.bz2 |
|||
SOURCE_SUM=__SHA256_SUM__ |
|||
SOURCE_SUM_PRG=sha256sum |
|||
SOURCE_FORMAT=tar.bz2 |
|||
SOURCE_IN_SUBDIR=true |
|||
SOURCE_FILENAME= |
|||
@ -1,18 +0,0 @@ |
|||
Section: misc |
|||
Priority: optional |
|||
Homepage: https://owncloud.org/ |
|||
Standards-Version: 3.9.2 |
|||
|
|||
Package: nextcloud-deps |
|||
Version: 11.0-1 |
|||
Depends: php5-gd, php5-json, php5-intl, php5-mcrypt |
|||
, php5-curl, php5-apcu, php5-imagick |
|||
, acl, tar, smbclient |
|||
Architecture: all |
|||
Description: meta package for nextcloud dependencies |
|||
Nextcloud gives you universal access to your files through a web |
|||
interface or WebDAV. It also provides a platform to easily view & sync |
|||
your contacts, calendars and bookmarks across all your devices and |
|||
enables basic editing right on the web. |
|||
. |
|||
This meta-package is only responsible of installing its dependencies. |
|||
@ -1,21 +0,0 @@ |
|||
#!/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 |
|||
@ -0,0 +1,13 @@ |
|||
# File to migrate from Owncloud |
|||
|
|||
# Final path |
|||
/var/www/$app |
|||
|
|||
# Data directory |
|||
/home/yunohost.app/$app |
|||
|
|||
# Nginx config |
|||
/etc/nginx/conf.d/$domain.d/$app.conf |
|||
|
|||
# php-fpm config |
|||
/etc/php5/fpm/pool.d/$app.conf |
|||
@ -0,0 +1,45 @@ |
|||
#!/bin/bash |
|||
|
|||
# Ending the migration process from Owncloud to Nextcloud |
|||
|
|||
set -u |
|||
|
|||
#================================================= |
|||
# IMPORT GENERIC HELPERS |
|||
#================================================= |
|||
|
|||
source /usr/share/yunohost/helpers |
|||
|
|||
#================================================= |
|||
# SET VARIABLES |
|||
#================================================= |
|||
|
|||
old_app="__OLD_APP__" |
|||
new_app="__NEW_APP__" |
|||
script_name="$0" |
|||
|
|||
#================================================= |
|||
# MOVE HOOKS |
|||
#================================================= |
|||
|
|||
hooks_dir="/etc/yunohost/hooks.d/" |
|||
mv "$hooks_dir/post_user_create/50-$old_app" "$hooks_dir/post_user_create/50-$new_app" |
|||
|
|||
#================================================= |
|||
# DELETE OLD APP'S SETTINGS |
|||
#================================================= |
|||
|
|||
ynh_secure_remove "/etc/yunohost/apps/$old_app" |
|||
yunohost app ssowatconf |
|||
|
|||
#================================================= |
|||
# REMOVE THE OLD USER |
|||
#================================================= |
|||
|
|||
ynh_system_user_delete $old_app |
|||
|
|||
#================================================= |
|||
# DELETE THIS SCRIPT |
|||
#================================================= |
|||
|
|||
echo "rm $script_name" | at now + 1 minutes |
|||
@ -1,48 +1,88 @@ |
|||
#!/bin/bash |
|||
|
|||
set -eu |
|||
#================================================= |
|||
# GENERIC START |
|||
#================================================= |
|||
|
|||
#================================================= |
|||
# IMPORT GENERIC HELPERS |
|||
#================================================= |
|||
|
|||
if [ ! -e _common.sh ]; then |
|||
# Get the _common.sh file if it's not in the current directory |
|||
cp ../settings/scripts/_common.sh ./_common.sh |
|||
chmod a+rx _common.sh |
|||
fi |
|||
source _common.sh |
|||
source /usr/share/yunohost/helpers |
|||
|
|||
#================================================= |
|||
# MANAGE SCRIPT FAILURE |
|||
#================================================= |
|||
|
|||
# Exit if an error occurs during the execution of the script |
|||
ynh_abort_if_errors |
|||
|
|||
#================================================= |
|||
# LOAD SETTINGS |
|||
#================================================= |
|||
|
|||
# Get multi-instances specific variables |
|||
app=$YNH_APP_INSTANCE_NAME |
|||
|
|||
# Set app specific variables |
|||
dbname=$app |
|||
dbuser=$app |
|||
final_path=$(ynh_app_setting_get $app final_path) |
|||
domain=$(ynh_app_setting_get $app domain) |
|||
db_name=$(ynh_app_setting_get $app db_name) |
|||
|
|||
# Source app helpers |
|||
source /usr/share/yunohost/helpers |
|||
#================================================= |
|||
# STANDARD BACKUP STEPS |
|||
#================================================= |
|||
# BACKUP THE APP MAIN DIR |
|||
#================================================= |
|||
|
|||
# Retrieve app settings |
|||
domain=$(ynh_app_setting_get "$app" domain) |
|||
path=$(ynh_app_setting_get "$app" path) |
|||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd) |
|||
ynh_backup "$final_path" |
|||
|
|||
# Copy the app source files |
|||
DESTDIR="/var/www/$app" |
|||
ynh_backup "$DESTDIR" "www" |
|||
#================================================= |
|||
# BACKUP THE NGINX CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Copy the data directory |
|||
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) |
|||
if [ -z $backup_core_only ] # Si backup_core_only a une valeur dans le fichier settings.yml, ne sauvegarde pas le dossier data |
|||
then |
|||
DATADIR="/home/yunohost.app/${app}/data" |
|||
ynh_backup "$DATADIR" "data" 1 |
|||
else |
|||
echo "Data dir will not saved, because backup_core_only is set." >&2 |
|||
fi |
|||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" |
|||
|
|||
#================================================= |
|||
# BACKUP THE PHP-FPM CONFIGURATION |
|||
#================================================= |
|||
|
|||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" |
|||
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" |
|||
|
|||
#================================================= |
|||
# BACKUP THE MYSQL DATABASE |
|||
#================================================= |
|||
|
|||
ynh_mysql_dump_db "$db_name" > db.sql |
|||
|
|||
#================================================= |
|||
# SPECIFIC BACKUP |
|||
#================================================= |
|||
# BACKUP LOGROTATE |
|||
#================================================= |
|||
|
|||
# Copy the conf files |
|||
mkdir ./conf |
|||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf" |
|||
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf" |
|||
ynh_backup "/etc/cron.d/${app}" "conf/cron" |
|||
ynh_backup "/etc/logrotate.d/$app" |
|||
|
|||
# Dump the database |
|||
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql |
|||
#================================================= |
|||
# BACKUP THE CRON FILE |
|||
#================================================= |
|||
|
|||
# Copy the control file of the dependency package |
|||
# FIXME: find a way to retrieve package name from _common.sh? |
|||
dpkg-query -s nextcloud-deps > ./nextcloud-deps.control |
|||
ynh_backup "/etc/cron.d/$app" |
|||
|
|||
# Backup the logrotate configuration file |
|||
ynh_backup "/etc/logrotate.d/$app" "logrotate" |
|||
#================================================= |
|||
# BACKUP THE DATA DIRECTORY |
|||
#================================================= |
|||
|
|||
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) |
|||
# If backup_core_only have any value in the settings.yml file, do not backup the data directory |
|||
if [ -z $backup_core_only ] |
|||
then |
|||
ynh_backup "/home/yunohost.app/${app}/data" |
|||
else |
|||
echo "Data dir will not be saved, because backup_core_only is set." >&2 |
|||
fi |
|||
@ -1,192 +1,273 @@ |
|||
#!/bin/bash |
|||
|
|||
set -eu |
|||
#================================================= |
|||
# GENERIC START |
|||
#================================================= |
|||
# IMPORT GENERIC HELPERS |
|||
#================================================= |
|||
|
|||
# Retrieve arguments |
|||
domain=$1 |
|||
path=${2%/} |
|||
admin=$3 |
|||
user_home=$4 |
|||
source _common.sh |
|||
source /usr/share/yunohost/helpers |
|||
|
|||
# Load common variables |
|||
source ./_common.sh |
|||
#================================================= |
|||
# MANAGE SCRIPT FAILURE |
|||
#================================================= |
|||
|
|||
# Set app specific variables |
|||
app=$APPNAME |
|||
dbname=$app |
|||
dbuser=$app |
|||
# Exit if an error occurs during the execution of the script |
|||
ynh_abort_if_errors |
|||
|
|||
# Source app helpers |
|||
source /usr/share/yunohost/helpers |
|||
#================================================= |
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST |
|||
#================================================= |
|||
|
|||
# Comments of this code was deleted, because it were in french... |
|||
if [ "${path:0:1}" != "/" ] && [ ${#path} -gt 0 ]; then |
|||
path="/$path" |
|||
fi |
|||
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then |
|||
path="${path:0:${#path}-1}" |
|||
fi |
|||
domain=$YNH_APP_ARG_DOMAIN |
|||
path_url=$YNH_APP_ARG_PATH |
|||
admin=$YNH_APP_ARG_ADMIN |
|||
user_home=$YNH_APP_ARG_USER_HOME |
|||
|
|||
# TODO: Check domain/path availability with app helper |
|||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \ |
|||
|| ynh_die "The path ${domain}${path} is not available for app installation." |
|||
app=$YNH_APP_INSTANCE_NAME |
|||
|
|||
# Check user parameter |
|||
ynh_user_exists "$admin" \ |
|||
|| ynh_die "The chosen admin user does not exist." |
|||
ynh_app_setting_set $app admin_user $admin |
|||
#================================================= |
|||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS |
|||
#================================================= |
|||
|
|||
# Check destination directory |
|||
DESTDIR="/var/www/$app" |
|||
[[ -d $DESTDIR ]] && ynh_die \ |
|||
"The destination directory '$DESTDIR' already exists.\ |
|||
You should safely delete it before installing this app." |
|||
final_path=/var/www/$app |
|||
test ! -e "$final_path" || ynh_die "This path already contains a folder" |
|||
|
|||
# Define app's data directory |
|||
DATADIR="/home/yunohost.app/${app}/data" |
|||
# Normalize the url path syntax |
|||
path_url=$(ynh_normalize_url_path $path_url) |
|||
|
|||
# Install dependencies |
|||
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \ |
|||
|| ynh_die "Unable to install dependencies" |
|||
# Check web path availability |
|||
ynh_webpath_available $domain $path_url |
|||
# Register (book) web path |
|||
ynh_webpath_register $app $domain $path_url |
|||
|
|||
# Generate random password |
|||
dbpass=$(ynh_string_random) |
|||
#================================================= |
|||
# STORE SETTINGS FROM MANIFEST |
|||
#================================================= |
|||
|
|||
# Initialize database |
|||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" |
|||
ynh_app_setting_set $app domain $domain |
|||
ynh_app_setting_set $app path $path_url |
|||
ynh_app_setting_set $app admin $admin |
|||
ynh_app_setting_set $app user_home $user_home |
|||
|
|||
# Create a system account for Nextcloud |
|||
sudo useradd -c "$app system account" \ |
|||
-d /var/lib/$app --system --user-group $app \ |
|||
|| ynh_die "Unable to create $app system account" |
|||
#================================================= |
|||
# STANDARD MODIFICATIONS |
|||
#================================================= |
|||
# INSTALL DEPENDENCIES |
|||
#================================================= |
|||
|
|||
# Set system group in hooks |
|||
sed -i "s@#GROUP#@${app}@g" ../hooks/post_user_create |
|||
ynh_install_app_dependencies $pkg_dependencies |
|||
|
|||
# Create app folders |
|||
sudo mkdir -p "$DESTDIR" "$DATADIR" |
|||
|
|||
# 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 "$nc_conf" |
|||
|
|||
# Copy and set nginx configuration |
|||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" |
|||
sed -i "s@#APP#@${app}@g" ../conf/nginx.conf |
|||
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf |
|||
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf |
|||
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf |
|||
# do not serve .well-known if it's already served on the domain |
|||
#================================================= |
|||
# CREATE A MYSQL DATABASE |
|||
#================================================= |
|||
|
|||
db_name=$(ynh_sanitize_dbid $app) |
|||
ynh_app_setting_set $app db_name $db_name |
|||
ynh_mysql_setup_db $db_name $db_name |
|||
|
|||
#================================================= |
|||
# DOWNLOAD, CHECK AND UNPACK SOURCE |
|||
#================================================= |
|||
|
|||
# Load the last available version |
|||
source upgrade.d/upgrade.last.sh |
|||
# Create an app.src for the last version of nextcloud |
|||
cp ../conf/app.src.default ../conf/app.src |
|||
ynh_replace_string "__VERSION__" "$next_version" "../conf/app.src" |
|||
ynh_replace_string "__SHA256_SUM__" "$nextcloud_source_sha256" "../conf/app.src" |
|||
|
|||
ynh_app_setting_set $app final_path $final_path |
|||
# Download, check integrity, uncompress and patch the source from app.src |
|||
ynh_setup_source "$final_path" |
|||
|
|||
#================================================= |
|||
# NGINX CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Do not serve .well-known if it's already served on the domain |
|||
if is_url_handled "https://${domain}/.well-known/caldav" ; then |
|||
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ |
|||
../conf/nginx.conf |
|||
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ |
|||
"../conf/nginx.conf" |
|||
fi |
|||
sudo cp ../conf/nginx.conf "$nginx_conf" |
|||
|
|||
# Copy and set php-fpm configuration |
|||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" |
|||
sed -i "s@#USER#@${app}@g" ../conf/php-fpm.conf |
|||
sed -i "s@#GROUP#@${app}@g" ../conf/php-fpm.conf |
|||
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf |
|||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf |
|||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf" |
|||
sudo chown root: $phpfpm_conf |
|||
sudo chmod 644 $phpfpm_conf |
|||
|
|||
# Handle root path, avoid double slash. |
|||
# Temporary fix, in waiting for an upgrade of the helper. (#361) |
|||
path_url_slash_less=${path_url%/} |
|||
ynh_replace_string "__PATH__/" "$path_url_slash_less/" "../conf/nginx.conf" |
|||
|
|||
# Create a dedicated nginx config |
|||
ynh_add_nginx_config |
|||
|
|||
#================================================= |
|||
# CREATE DEDICATED USER |
|||
#================================================= |
|||
|
|||
# Create a system user |
|||
ynh_system_user_create $app |
|||
|
|||
#================================================= |
|||
# PHP-FPM CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Create a dedicated php-fpm config |
|||
ynh_add_fpm_config |
|||
|
|||
# occ helper for the current installation |
|||
_exec_occ() { |
|||
exec_occ "$DESTDIR" "$app" $@ |
|||
} |
|||
#================================================= |
|||
# SPECIFIC SETUP |
|||
#================================================= |
|||
# CREATE THE DATA DIRECTORY |
|||
#================================================= |
|||
|
|||
# Set app folders ownership |
|||
sudo chown -R $app: "$DESTDIR" "$DATADIR" |
|||
# Define app's data directory |
|||
datadir="/home/yunohost.app/${app}/data" |
|||
# Create app folders |
|||
mkdir -p "$datadir" |
|||
|
|||
#================================================= |
|||
# INSTALL NEXTCLOUD |
|||
#================================================= |
|||
|
|||
# Retrieve Nextcloud sources |
|||
VERSION=$LAST_VERSION |
|||
NEXTCLOUD_SOURCE_SHA256=$(grep "NEXTCLOUD_SOURCE_SHA256=" "upgrade.d/upgrade.last.sh" | cut -d= -f2) |
|||
extract_nextcloud "$DESTDIR" "$app" |
|||
# Set write access for the following commands |
|||
chown -R $app: "$final_path" "$datadir" |
|||
|
|||
# Install Nextcloud using a temporary admin user |
|||
_exec_occ maintenance:install \ |
|||
--database "mysql" --database-name "$dbname" \ |
|||
--database-user "$dbuser" --database-pass "$dbpass" \ |
|||
exec_occ maintenance:install \ |
|||
--database "mysql" --database-name "$db_name" \ |
|||
--database-user "$db_name" --database-pass "$db_pwd" \ |
|||
--admin-user "admin" --admin-pass "$(ynh_string_random 6)" \ |
|||
--data-dir "$DATADIR" \ |
|||
--data-dir "$datadir" \ |
|||
|| ynh_die "Unable to install Nextcloud" |
|||
|
|||
#================================================= |
|||
# CONFIGURE NEXTCLOUD |
|||
#================================================= |
|||
|
|||
nc_conf="${final_path}/config.json" |
|||
cp ../conf/config.json "$nc_conf" |
|||
ynh_replace_string "#DOMAIN#" "$domain" "$nc_conf" |
|||
ynh_replace_string "#DATADIR#" "$datadir" "$nc_conf" |
|||
|
|||
# Ensure that UpdateNotification app is disabled |
|||
_exec_occ app:disable updatenotification |
|||
exec_occ app:disable updatenotification |
|||
|
|||
# Enable plugins |
|||
exec_occ app:enable user_ldap |
|||
exec_occ ldap:create-empty-config |
|||
|
|||
# Enable plugins and set Nextcloud configuration |
|||
_exec_occ app:enable user_ldap |
|||
_exec_occ ldap:create-empty-config |
|||
_exec_occ config:import "$nc_conf" |
|||
sudo rm -f "$nc_conf" |
|||
# Load the config file in nextcloud |
|||
exec_occ config:import "$nc_conf" |
|||
# Then remove it |
|||
rm -f "$nc_conf" |
|||
|
|||
# Check LDAP configuratio to see if everything worked well |
|||
_exec_occ ldap:test-config \'\' \ |
|||
#================================================= |
|||
# CHECK THE LDAP CONFIG |
|||
#================================================= |
|||
|
|||
# Check LDAP configuration to see if everything worked well |
|||
exec_occ ldap:test-config \'\' \ |
|||
|| ynh_die "An error occured during LDAP configuration" |
|||
|
|||
#================================================= |
|||
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE |
|||
#================================================= |
|||
|
|||
# Enable External Storage and create local mount to home folder |
|||
if [[ $user_home -eq 1 ]]; then |
|||
_exec_occ app:enable files_external |
|||
create_home_external_storage '_exec_occ' |
|||
if [ $user_home -eq 1 ]; then |
|||
exec_occ app:enable files_external |
|||
create_home_external_storage |
|||
fi |
|||
|
|||
#================================================= |
|||
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD |
|||
#================================================= |
|||
|
|||
# Add dynamic logout URL to the config |
|||
_exec_occ config:system:get logout_url >/dev/null 2>&1 \ |
|||
|| sudo su -c "echo \" |
|||
exec_occ config:system:get logout_url >/dev/null 2>&1 \ |
|||
|| echo " |
|||
//-YunoHost- |
|||
// set logout_url according to main domain |
|||
\\\$main_domain = exec('cat /etc/yunohost/current_host'); |
|||
\\\$CONFIG['logout_url'] = 'https://'.\\\$main_domain.'/yunohost/sso/?action=logout'; |
|||
\$main_domain = exec('cat /etc/yunohost/current_host'); |
|||
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout'; |
|||
//-YunoHost- |
|||
\" >> ${DESTDIR}/config/config.php" -- $app |
|||
" >> "${final_path}/config/config.php" |
|||
|
|||
#================================================= |
|||
# REMOVE THE TEMPORARY ADMIN AND SET THE TRUE ONE |
|||
#================================================= |
|||
|
|||
# Set the user as admin and delete admin user |
|||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \ |
|||
# Set the user as admin |
|||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \ |
|||
<<< "INSERT INTO oc_group_user VALUES ('admin','$admin');" |
|||
_exec_occ user:delete admin |
|||
# And delete admin user |
|||
exec_occ user:delete admin |
|||
|
|||
#================================================= |
|||
# STORE THE CHECKSUM OF THE CONFIG FILE |
|||
#================================================= |
|||
|
|||
# Calculate and store the config file checksum into the app settings |
|||
ynh_store_file_checksum "${final_path}/config/config.php" |
|||
|
|||
#================================================= |
|||
# ADD A CRON JOB |
|||
#================================================= |
|||
|
|||
cron_path="/etc/cron.d/$app" |
|||
cp -a ../conf/nextcloud.cron "$cron_path" |
|||
|
|||
ynh_replace_string "#USER#" "$app" "$cron_path" |
|||
ynh_replace_string "#DESTDIR#" "$final_path" "$cron_path" |
|||
|
|||
exec_occ background:cron |
|||
|
|||
#================================================= |
|||
# CONFIGURE THE HOOK FILE FOR USER CREATE |
|||
#================================================= |
|||
|
|||
# Set system group in hooks |
|||
ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create |
|||
|
|||
#================================================= |
|||
# GENERIC FINALIZATION |
|||
#================================================= |
|||
# SECURE FILES AND DIRECTORIES |
|||
#================================================= |
|||
|
|||
# Fix app ownerships & permissions |
|||
chown -R $app: "$final_path" "$datadir" |
|||
find ${final_path}/ -type f -print0 | xargs -0 chmod 0644 |
|||
find ${final_path}/ -type d -print0 | xargs -0 chmod 0755 |
|||
find ${datadir}/ -type f -print0 | xargs -0 chmod 0640 |
|||
find ${datadir}/ -type d -print0 | xargs -0 chmod 0750 |
|||
chmod 640 "${final_path}/config/config.php" |
|||
chmod 755 /home/yunohost.app |
|||
|
|||
# Iterate over users to extend their home folder permissions - for the external |
|||
# storage plugin usage - and create relevant Nextcloud directories |
|||
for u in $(ynh_user_list); do |
|||
sudo mkdir -p "${DATADIR}/${u}" |
|||
sudo setfacl -m g:$app:rwx "/home/$u" || true |
|||
mkdir -p "${datadir}/${u}" |
|||
setfacl -m g:$app:rwx "/home/$u" || true |
|||
done |
|||
|
|||
# Fix app ownerships & permissions |
|||
sudo chown -R $app: "$DESTDIR" "$DATADIR" |
|||
sudo find ${DESTDIR}/ -type f -print0 | sudo xargs -0 chmod 0644 |
|||
sudo find ${DESTDIR}/ -type d -print0 | sudo xargs -0 chmod 0755 |
|||
sudo find ${DATADIR}/ -type f -print0 | sudo xargs -0 chmod 0640 |
|||
sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750 |
|||
sudo chmod 640 "${DESTDIR}/config/config.php" |
|||
sudo chmod 755 /home/yunohost.app |
|||
|
|||
# Store app settings |
|||
ynh_app_setting_set "$app" user_home "$user_home" |
|||
ynh_app_setting_set "$app" mysqlpwd "$dbpass" |
|||
|
|||
# Set SSOwat rules |
|||
ynh_app_setting_set "$app" unprotected_uris "/" |
|||
ynh_app_setting_set "$app" skipped_regex \ |
|||
"$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*" |
|||
#================================================= |
|||
# SETUP LOGROTATE |
|||
#================================================= |
|||
|
|||
# Reload services |
|||
sudo service php5-fpm restart || true |
|||
sudo service nginx reload || true |
|||
# Use logrotate to manage application logfile |
|||
ynh_use_logrotate "/home/yunohost.app/nextcloud/data/nextcloud.log" |
|||
|
|||
# Add cron job |
|||
cron_path="/etc/cron.d/$app" |
|||
sed -i "s@#USER#@${app}@g" ../conf/nextcloud.cron |
|||
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nextcloud.cron |
|||
sudo cp ../conf/nextcloud.cron "$cron_path" |
|||
sudo chmod 644 "$cron_path" |
|||
_exec_occ background:cron |
|||
#================================================= |
|||
# SETUP SSOWAT |
|||
#================================================= |
|||
|
|||
# Setup log rotation |
|||
ynh_use_logrotate "/home/yunohost.app/nextcloud/data/nextcloud.log" |
|||
ynh_app_setting_set $app unprotected_uris "/" |
|||
ynh_app_setting_set $app skipped_regex \ |
|||
"$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*" |
|||
|
|||
#================================================= |
|||
# RELOAD NGINX |
|||
#================================================= |
|||
|
|||
systemctl reload nginx |
|||
@ -1,50 +1,92 @@ |
|||
#!/bin/bash |
|||
|
|||
# Load common variables and helpers |
|||
source ./_common.sh |
|||
#================================================= |
|||
# GENERIC START |
|||
#================================================= |
|||
# IMPORT GENERIC HELPERS |
|||
#================================================= |
|||
|
|||
# Source app helpers |
|||
source _common.sh |
|||
source /usr/share/yunohost/helpers |
|||
|
|||
# Set app specific variables |
|||
#================================================= |
|||
# LOAD SETTINGS |
|||
#================================================= |
|||
|
|||
app=$YNH_APP_INSTANCE_NAME |
|||
dbname=$app |
|||
dbuser=$app |
|||
|
|||
# Remove cron job |
|||
# TODO: Ensure that cron job is not running |
|||
sudo rm -f "/etc/cron.d/${app}" |
|||
domain=$(ynh_app_setting_get $app domain) |
|||
db_name=$(ynh_app_setting_get $app db_name) |
|||
final_path=$(ynh_app_setting_get $app final_path) |
|||
|
|||
#================================================= |
|||
# STANDARD REMOVE |
|||
#================================================= |
|||
# REMOVE DEPENDENCIES |
|||
#================================================= |
|||
|
|||
# Remove metapackage and its dependencies |
|||
ynh_remove_app_dependencies |
|||
|
|||
#================================================= |
|||
# REMOVE THE MYSQL DATABASE |
|||
#================================================= |
|||
|
|||
# Remove a database if it exists, along with the associated user |
|||
ynh_mysql_remove_db $db_name $db_name |
|||
|
|||
#================================================= |
|||
# REMOVE APP MAIN DIR |
|||
#================================================= |
|||
|
|||
# Remove the app directory securely |
|||
ynh_secure_remove "$final_path" |
|||
|
|||
#================================================= |
|||
# REMOVE NGINX CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Remove the dedicated nginx config |
|||
ynh_remove_nginx_config |
|||
|
|||
#================================================= |
|||
# REMOVE PHP-FPM CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Drop MySQL database and user |
|||
ynh_mysql_drop_db "$dbname" |
|||
ynh_mysql_drop_user "$dbuser" |
|||
# Remove the dedicated php-fpm config |
|||
ynh_remove_fpm_config |
|||
|
|||
# Retrieve domain from app settings |
|||
domain=$(ynh_app_setting_get "$app" domain) |
|||
#================================================= |
|||
# REMOVE LOGROTATE CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Delete app directory and configurations |
|||
[[ "/var/www" =~ "/var/www/${app}" ]] \ |
|||
|| (test -n "$app" && sudo rm -r "/var/www/${app}" ) |
|||
# Remove the app-specific logrotate config |
|||
ynh_remove_logrotate |
|||
|
|||
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf" |
|||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf" |
|||
#================================================= |
|||
# SPECIFIC REMOVE |
|||
#================================================= |
|||
# REMOVE THE CRON FILE |
|||
#================================================= |
|||
|
|||
# Reload services |
|||
sudo service php5-fpm reload |
|||
sudo service nginx reload |
|||
# Remove a cron file |
|||
# TODO: Ensure that cron job is not running (How !?) |
|||
ynh_secure_remove "/etc/cron.d/$app" |
|||
|
|||
# Remove app dependencies |
|||
ynh_package_autoremove "$DEPS_PKG_NAME" |
|||
#================================================= |
|||
# CLEAN ACL IN HOME DIRECTORIES |
|||
#================================================= |
|||
|
|||
# Clean home folders ACLs |
|||
for i in $(ls /home); do |
|||
[[ ! $i == yunohost.* ]] \ |
|||
&& sudo setfacl -x g:$app:rwx >/dev/null 2>&1 |
|||
&& setfacl -x g:$app:rwx 2>&1 |
|||
done |
|||
|
|||
# Remove the user account |
|||
id "$app" >/dev/null 2>&1 \ |
|||
&& sudo deluser --quiet --remove-home "$app" >/dev/null |
|||
#================================================= |
|||
# GENERIC FINALIZATION |
|||
#================================================= |
|||
# REMOVE DEDICATED USER |
|||
#================================================= |
|||
|
|||
# Remove logrotate configuration |
|||
ynh_remove_logrotate |
|||
# Delete a system user |
|||
ynh_system_user_delete $app |
|||
@ -1,96 +1,144 @@ |
|||
#!/bin/bash |
|||
|
|||
set -eu |
|||
#================================================= |
|||
# GENERIC START |
|||
#================================================= |
|||
|
|||
#================================================= |
|||
# IMPORT GENERIC HELPERS |
|||
#================================================= |
|||
|
|||
if [ ! -e _common.sh ]; then |
|||
# Get the _common.sh file if it's not in the current directory |
|||
cp ../settings/scripts/_common.sh ./_common.sh |
|||
chmod a+rx _common.sh |
|||
fi |
|||
source _common.sh |
|||
source /usr/share/yunohost/helpers |
|||
|
|||
#================================================= |
|||
# MANAGE SCRIPT FAILURE |
|||
#================================================= |
|||
|
|||
# Exit if an error occurs during the execution of the script |
|||
ynh_abort_if_errors |
|||
|
|||
#================================================= |
|||
# LOAD SETTINGS |
|||
#================================================= |
|||
|
|||
# Get multi-instances specific variables |
|||
app=$YNH_APP_INSTANCE_NAME |
|||
|
|||
# Set app specific variables |
|||
dbname=$app |
|||
dbuser=$app |
|||
domain=$(ynh_app_setting_get $app domain) |
|||
path_url=$(ynh_app_setting_get $app path) |
|||
final_path=$(ynh_app_setting_get $app final_path) |
|||
db_name=$(ynh_app_setting_get $app db_name) |
|||
|
|||
# Source app helpers |
|||
source /usr/share/yunohost/helpers |
|||
#================================================= |
|||
# CHECK IF THE APP CAN BE RESTORED |
|||
#================================================= |
|||
|
|||
# Retrieve old app settings |
|||
domain=$(ynh_app_setting_get "$app" domain) |
|||
path=$(ynh_app_setting_get "$app" path) |
|||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd) |
|||
ynh_webpath_available $domain $path_url \ |
|||
|| ynh_die "Path not available: ${domain}${path_url}" |
|||
test ! -d $final_path \ |
|||
|| ynh_die "There is already a directory: $final_path " |
|||
|
|||
# TODO: Check domain/path availability with app helper |
|||
# Temporarily conditioned, see https://dev.yunohost.org/issues/593 |
|||
if [ ${#path} -gt 1 ]; then |
|||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \ |
|||
|| ynh_die "The path ${domain}${path} is not available for app installation." |
|||
fi |
|||
#================================================= |
|||
# STANDARD RESTORATION STEPS |
|||
#================================================= |
|||
# RESTORE THE NGINX CONFIGURATION |
|||
#================================================= |
|||
|
|||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" |
|||
|
|||
#================================================= |
|||
# RESTORE THE APP MAIN DIR |
|||
#================================================= |
|||
|
|||
ynh_restore_file "$final_path" |
|||
|
|||
#================================================= |
|||
# RESTORE THE MYSQL DATABASE |
|||
#================================================= |
|||
|
|||
db_pwd=$(ynh_app_setting_get $app mysqlpwd) |
|||
ynh_mysql_setup_db $db_name $db_name $db_pwd |
|||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql |
|||
|
|||
#================================================= |
|||
# RECREATE THE DEDICATED USER |
|||
#================================================= |
|||
|
|||
# Create the dedicated user (if not existing) |
|||
ynh_system_user_create $app |
|||
|
|||
# Check destination directory |
|||
DESTDIR="/var/www/$app" |
|||
[[ -d $DESTDIR ]] && ynh_die \ |
|||
"The destination directory '$DESTDIR' already exists.\ |
|||
You should safely delete it before restoring this app." |
|||
|
|||
# Define app's data directory |
|||
DATADIR="/home/yunohost.app/${app}/data" |
|||
|
|||
# Check configuration files |
|||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" |
|||
[[ -f $nginx_conf ]] && ynh_die \ |
|||
"The NGINX configuration already exists at '${nginx_conf}'. |
|||
You should safely delete it before restoring this app." |
|||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" |
|||
[[ -f $phpfpm_conf ]] && ynh_die \ |
|||
"The PHP FPM configuration already exists at '${phpfpm_conf}'. |
|||
You should safely delete it before restoring this app." |
|||
|
|||
# Install dependencies |
|||
ynh_package_install_from_equivs ./nextcloud-deps.control \ |
|||
|| ynh_die "Unable to install dependencies" |
|||
|
|||
# Create a system account for Nextcloud |
|||
sudo useradd -c "$app system account" \ |
|||
-d /var/lib/$app --system --user-group $app \ |
|||
|| ynh_die "Unable to create $app system account" |
|||
|
|||
# Restore the app files |
|||
sudo cp -a ./www "$DESTDIR" |
|||
sudo mkdir -p "$DATADIR" |
|||
if [ -d ./data ] # Le dossier data est restauré seulement si il existe. Si le backup a été fait avec l'option backup_core_only, ce dossier n'a pas été sauvegardé. |
|||
#================================================= |
|||
# RESTORE THE PHP-FPM CONFIGURATION |
|||
#================================================= |
|||
|
|||
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" |
|||
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" |
|||
|
|||
#================================================= |
|||
# SPECIFIC RESTORATION |
|||
#================================================= |
|||
# REINSTALL DEPENDENCIES |
|||
#================================================= |
|||
|
|||
# Define and install dependencies |
|||
ynh_install_app_dependencies $pkg_dependencies |
|||
|
|||
#================================================= |
|||
# RESTORE THE CRON FILE |
|||
#================================================= |
|||
|
|||
ynh_restore_file "/etc/cron.d/$app" |
|||
|
|||
#================================================= |
|||
# BACKUP THE LOGROTATE CONFIGURATION |
|||
#================================================= |
|||
|
|||
ynh_restore_file "/etc/logrotate.d/$app" |
|||
|
|||
#================================================= |
|||
# RESTORE THE DATA DIRECTORY |
|||
#================================================= |
|||
|
|||
datadir="/home/yunohost.app/${app}/data" |
|||
|
|||
# The data directory will be restored only if it exists in the backup archive |
|||
# So only if it was backup previously. |
|||
if [ -d "$YNH_BACKUP_DIR/apps/$app/backup/home/yunohost.app/$app" ] |
|||
then |
|||
sudo cp -a ./data/. "$DATADIR" |
|||
ynh_restore_file "$datadir" |
|||
else |
|||
# Create app folders |
|||
mkdir -p "$datadir" |
|||
fi |
|||
ynh_app_setting_delete $app backup_core_only # Retire l'option backup_core_only du fichier settings.yml le cas échéant |
|||
# Remove the option backup_core_only if it's in the settings.yml file |
|||
ynh_app_setting_delete $app backup_core_only |
|||
|
|||
# Create and restore the database |
|||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" |
|||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql |
|||
#================================================= |
|||
# RESTORE USER RIGHTS |
|||
#================================================= |
|||
|
|||
# Fix app ownerships & permissions |
|||
chown -R $app: "$final_path" "$datadir" |
|||
chmod 640 "${final_path}/config/config.php" |
|||
chmod 755 /home/yunohost.app |
|||
|
|||
# Iterate over users to extend their home folder permissions - for the external |
|||
# storage plugin usage - and create relevant Nextcloud directories |
|||
for u in $(ynh_user_list); do |
|||
sudo mkdir -p "${DATADIR}/${u}" |
|||
sudo setfacl -m g:$app:rwx "/home/$u" || true |
|||
mkdir -p "${datadir}/${u}" |
|||
setfacl -m g:$app:rwx "/home/$u" || true |
|||
done |
|||
|
|||
# Fix app ownerships & permissions |
|||
sudo chown -R $app: "$DESTDIR" "$DATADIR" |
|||
sudo find ${DESTDIR}/ -type f -print0 | sudo xargs -0 chmod 0644 |
|||
sudo find ${DESTDIR}/ -type d -print0 | sudo xargs -0 chmod 0755 |
|||
sudo find ${DATADIR}/ -type f -print0 | sudo xargs -0 chmod 0640 |
|||
sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750 |
|||
sudo chmod 640 "${DESTDIR}/config/config.php" |
|||
sudo chmod 755 /home/yunohost.app |
|||
|
|||
# Restore configuration files |
|||
sudo cp -a ./conf/nginx.conf "$nginx_conf" |
|||
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf" |
|||
|
|||
# Restore cron job |
|||
sudo cp -a ./conf/cron "/etc/cron.d/${app}" |
|||
|
|||
# Restore logrotate configuration file |
|||
sudo cp -a ./logrotate /etc/logrotate.d/$app |
|||
|
|||
# Reload services |
|||
sudo service php5-fpm restart || true |
|||
sudo service nginx reload || true |
|||
#================================================= |
|||
# GENERIC FINALIZATION |
|||
#================================================= |
|||
# RELOAD NGINX AND PHP-FPM |
|||
#================================================= |
|||
|
|||
systemctl reload php5-fpm |
|||
systemctl reload nginx |
|||
@ -1,251 +1,374 @@ |
|||
#!/bin/bash |
|||
|
|||
# Load common variables and helpers |
|||
source ./_common.sh |
|||
#================================================= |
|||
# GENERIC START |
|||
#================================================= |
|||
# IMPORT GENERIC HELPERS |
|||
#================================================= |
|||
|
|||
# Source app helpers |
|||
source _common.sh |
|||
source /usr/share/yunohost/helpers |
|||
|
|||
# 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 |
|||
backup_number=1 |
|||
old_backup_number=2 |
|||
if sudo yunohost backup list | grep -q $real_app-before-upgrade1 > /dev/null 2>&1; then # Vérifie l'existence d'une archive déjà numéroté à 1. |
|||
backup_number=2 # Et passe le numéro de l'archive à 2 |
|||
old_backup_number=1 |
|||
#================================================= |
|||
# LOAD SETTINGS |
|||
#================================================= |
|||
|
|||
app=$YNH_APP_INSTANCE_NAME |
|||
|
|||
domain=$(ynh_app_setting_get $app domain) |
|||
path_url=$(ynh_app_setting_get $app path) |
|||
admin=$(ynh_app_setting_get $app admin) |
|||
final_path=$(ynh_app_setting_get $app final_path) |
|||
db_name=$(ynh_app_setting_get $app db_name) |
|||
user_home=$(ynh_app_setting_get $app user_home) |
|||
|
|||
#================================================= |
|||
# ENSURE DOWNWARD COMPATIBILITY |
|||
#================================================= |
|||
|
|||
# If db_name doesn't exist, create it |
|||
if [ -z $db_name ]; then |
|||
db_name=$(ynh_sanitize_dbid $app) |
|||
ynh_app_setting_set $app db_name $db_name |
|||
fi |
|||
|
|||
# If final_path doesn't exist, create it |
|||
if [ -z $final_path ]; then |
|||
final_path=/var/www/$app |
|||
ynh_app_setting_set $app final_path $final_path |
|||
fi |
|||
ynh_app_setting_set $app backup_core_only 1 # Indique au backup/restore de ne pas sauvegarder le dossier de data, uniquement le core de nextcloud. |
|||
|
|||
if [ "$(cat /var/www/$real_app/version.php | grep OC_VersionString | cut -d\' -f2)" \> "11.0.0" ] |
|||
then # Pas de backup avant la version suivant 11.0.0 (soit 11.0.1), car le backup incluera les dossiers data. |
|||
sudo yunohost backup create --ignore-hooks --apps $real_app --name $real_app-before-upgrade$backup_number # Créer un backup différent de celui existant. |
|||
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente. |
|||
if sudo yunohost backup list | grep -q $real_app-before-upgrade$old_backup_number > /dev/null 2>&1; then # Vérifie l'existence de l'ancienne archive avant de la supprimer, pour éviter une erreur. |
|||
sudo yunohost backup delete $real_app-before-upgrade$old_backup_number > /dev/null |
|||
fi |
|||
else # Si le backup a échoué |
|||
ynh_die "Backup failed, the upgrade process was aborted." |
|||
fi |
|||
|
|||
#================================================= |
|||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP |
|||
#================================================= |
|||
|
|||
# Made a backup only after the version 11.0.0 |
|||
# Before, the datas will be always saved. |
|||
|
|||
# Get the current version number of nextcloud/owncloud |
|||
current_version=$(grep OC_VersionString "$final_path/version.php" | cut -d\' -f2) |
|||
current_major_version=${current_version%%.*} |
|||
|
|||
if [ $current_major_version -gt 11 ] |
|||
then |
|||
# Inform the backup/restore process that it should not save the data directory |
|||
ynh_app_setting_set $app backup_core_only 1 |
|||
|
|||
# Backup the current version of the app |
|||
ynh_backup_before_upgrade |
|||
ynh_clean_setup () { |
|||
# Remove the post migration script before its execution ! |
|||
ynh_secure_remove "/tmp/owncloud_post_migration.sh" 2>&1 |
|||
|
|||
# restore it if the upgrade fails |
|||
ynh_restore_upgradebackup |
|||
} |
|||
fi |
|||
|
|||
EXIT_PROPERLY () { |
|||
exit_code=$? |
|||
if [ "$exit_code" -eq 0 ]; then |
|||
ynh_app_setting_delete $real_app backup_core_only |
|||
exit 0 # Quitte sans erreur si le script se termine correctement. |
|||
fi |
|||
trap '' EXIT |
|||
set +eu |
|||
echo "Upgrade failed." >&2 |
|||
if sudo yunohost backup list | grep -q $real_app-before-upgrade$backup_number > /dev/null 2>&1; then # Vérifie l'existence de l'archive avant de supprimer l'application et de restaurer |
|||
sudo yunohost app remove $real_app # Supprime l'application avant de la restaurer. |
|||
sudo yunohost backup restore --ignore-hooks $real_app-before-upgrade$backup_number --apps $real_app --force # Restore the backup if upgrade failed |
|||
ynh_die "The app was restored to the way it was before the failed upgrade." |
|||
fi |
|||
} |
|||
set -eu |
|||
trap EXIT_PROPERLY EXIT |
|||
|
|||
# Migrate from ownCloud to Nextcloud |
|||
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" |
|||
# real_app=$YNH_APP_INSTANCE_NAME # real_app prend le nom de owncloud. |
|||
./upgrade.d/owncloud.sh # Prépare la migration de owncloud vers nextcloud. |
|||
else |
|||
real_app=$app |
|||
|
|||
# handle old migrations from ownCloud |
|||
curr_dbname=$(sudo cat "/var/www/${app}/config/config.php" \ |
|||
| 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") # Prend le nom d'utilisateur de la bdd |
|||
dbpass=$(ynh_app_setting_get "$real_app" mysqlpwd) |
|||
|
|||
# rename the MySQL database |
|||
rename_mysql_db "$curr_dbname" "$curr_dbuser" "$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" |
|||
fi |
|||
# Exit if an error occurs during the script execution |
|||
ynh_abort_if_errors |
|||
|
|||
#================================================= |
|||
# HANDLE MIGRATION FROM OWNCLOUD |
|||
#================================================= |
|||
|
|||
ynh_handle_app_migration "owncloud" "owncloud_migration" |
|||
if [ $migration_process -eq 1 ] |
|||
then |
|||
# If a migration has been perform |
|||
# Reload some values changed by the migration process |
|||
final_path=$(ynh_app_setting_get $app final_path) |
|||
db_name=$(ynh_app_setting_get $app db_name) |
|||
|
|||
# Remove the old fake package for owncloud. |
|||
# Its name is specific, so the migration process can't remove it |
|||
ynh_package_autopurge owncloud-deps |
|||
|
|||
# Change the database access in the config |
|||
ynh_replace_string "\('dbname' =>\).*" "\1 '$db_name'," "$final_path/config/config.php" |
|||
ynh_replace_string "\('dbuser' =>\).*" "\1 '$db_name'," "$final_path/config/config.php" |
|||
|
|||
# Change the path of the data directory |
|||
ynh_replace_string "\('dbuser' =>\).*" "\1 '$db_name'," "$final_path/config/config.php" |
|||
ynh_replace_string "\('datadirectory' =>.*\)$old_app" "\1$app" "$final_path/config/config.php" |
|||
fi |
|||
|
|||
# Retrieve app settings |
|||
domain=$(ynh_app_setting_get "$real_app" domain) |
|||
path=$(ynh_app_setting_get "$real_app" path) |
|||
path=${path%/} |
|||
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" |
|||
[[ ! -d $DESTDIR ]] && ynh_die \ |
|||
"The destination directory '$DESTDIR' does not exist.\ |
|||
The app is not correctly installed, you should remove it first." |
|||
|
|||
# Check app's data directory |
|||
DATADIR="/home/yunohost.app/${app}/data" |
|||
[[ ! -d $DATADIR ]] && ynh_die \ |
|||
"The data directory '$DATADIR' does not exist.\ |
|||
The app is not correctly installed, you should remove it first." |
|||
|
|||
# Upgrade dependencies |
|||
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \ |
|||
|| ynh_die "Unable to upgrade dependencies" |
|||
|
|||
# FIXME: Delete current nginx configuration to be able to check if |
|||
# .well-known is already served. See https://dev.yunohost.org/issues/400 |
|||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" |
|||
sudo rm -f "$nginx_conf" |
|||
sudo service nginx reload |
|||
|
|||
# Copy and set nginx configuration |
|||
sed -i "s@#APP#@${app}@g" ../conf/nginx.conf |
|||
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf |
|||
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf |
|||
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf |
|||
# do not serve .well-known if it's already served on the domain |
|||
#================================================= |
|||
# CHECK THE PATH |
|||
#================================================= |
|||
|
|||
# Normalize the URL path syntax |
|||
path_url=$(ynh_normalize_url_path $path_url) |
|||
|
|||
#================================================= |
|||
# STANDARD UPGRADE STEPS |
|||
#================================================= |
|||
# NGINX CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Delete current nginx configuration to be able to check if .well-known is already served. |
|||
ynh_remove_nginx_config |
|||
ynh_app_setting_delete $app "checksum__etc_nginx_conf.d_$domain.d_$app.conf" || true |
|||
# Do not serve .well-known if it's already served on the domain |
|||
if is_url_handled "https://${domain}/.well-known/caldav" ; then |
|||
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ |
|||
../conf/nginx.conf |
|||
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ |
|||
"../conf/nginx.conf" |
|||
fi |
|||
sudo cp ../conf/nginx.conf "$nginx_conf" |
|||
|
|||
# Copy and set php-fpm configuration |
|||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" |
|||
sed -i "s@#USER#@${app}@g" ../conf/php-fpm.conf |
|||
sed -i "s@#GROUP#@${app}@g" ../conf/php-fpm.conf |
|||
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf |
|||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf |
|||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf" |
|||
sudo chown root: $phpfpm_conf |
|||
sudo chmod 644 $phpfpm_conf |
|||
|
|||
# Handle root path, avoid double slash. |
|||
# Temporary fix, in waiting for an upgrade of the helper. (#361) |
|||
path_url_slash_less=${path_url%/} |
|||
ynh_replace_string "__PATH__/" "$path_url_slash_less/" "../conf/nginx.conf" |
|||
|
|||
# Create a dedicated nginx config |
|||
ynh_add_nginx_config |
|||
|
|||
#================================================= |
|||
# CREATE DEDICATED USER |
|||
#================================================= |
|||
|
|||
# Create a system user |
|||
ynh_system_user_create $app |
|||
|
|||
#================================================= |
|||
# PHP-FPM CONFIGURATION |
|||
#================================================= |
|||
|
|||
# Create a dedicated php-fpm config |
|||
ynh_add_fpm_config |
|||
|
|||
# Set system group in hooks |
|||
sed -i "s@#GROUP#@${app}@g" ../hooks/post_user_create |
|||
|
|||
# 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. |
|||
} |
|||
|
|||
|
|||
# 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%%.*} |
|||
_exec_occ -V # Affiche la 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%%.*} |
|||
_exec_occ -V # Affiche la version |
|||
#================================================= |
|||
# UPGRADE DEPENDENCIES |
|||
#================================================= |
|||
|
|||
ynh_install_app_dependencies $pkg_dependencies |
|||
|
|||
#================================================= |
|||
# SPECIFIC UPGRADE |
|||
#================================================= |
|||
# MAKE SEQUENTIAL UPGRADES FROM EACH MAJOR |
|||
# VERSION TO THE NEXT ONE |
|||
#================================================= |
|||
|
|||
# Load the last available version |
|||
source upgrade.d/upgrade.last.sh |
|||
last_version=$next_version |
|||
|
|||
# Define app's data directory |
|||
datadir="/home/yunohost.app/${app}/data" |
|||
|
|||
# Set write access for the following commands |
|||
chown -R $app: "$final_path" "$datadir" |
|||
|
|||
# Print the current version number of nextcloud |
|||
exec_occ -V |
|||
|
|||
# While the current version is not the last version, do an upgrade |
|||
while [ "$last_version" != "$current_version" ] |
|||
do |
|||
|
|||
# The major version is the first part of the version number |
|||
# major_version=${next_version%%.*} |
|||
major_version=${last_version%%.*} |
|||
current_major_version=${current_version%%.*} |
|||
|
|||
# If the current version has the same major version than the next one, |
|||
# then it's the last upgrade to do |
|||
if [ "$major_version" -eq "$current_major_version" ]; then |
|||
current_major_version=last |
|||
fi |
|||
|
|||
# Load the value for this version |
|||
source upgrade.d/upgrade.$current_major_version.sh |
|||
|
|||
echo -e "\nUpgrade to nextcloud $next_version" >&2 |
|||
|
|||
# Create an app.src for this version of nextcloud |
|||
cp ../conf/app.src.default ../conf/app.src |
|||
ynh_replace_string "__VERSION__" "$next_version" "../conf/app.src" |
|||
ynh_replace_string "__SHA256_SUM__" "$nextcloud_source_sha256" "../conf/app.src" |
|||
|
|||
# Create a temporary directory |
|||
tmpdir=$(mktemp -d) |
|||
|
|||
# Install the next nextcloud version in $tmpdir |
|||
ynh_setup_source "$tmpdir" |
|||
|
|||
# Enable maintenance mode |
|||
exec_occ maintenance:mode --on |
|||
|
|||
# Backup the config file in the temp dir |
|||
cp -a "$final_path/config/config.php" "$tmpdir/config/config.php" |
|||
|
|||
# Backup 3rd party applications from the current nextcloud |
|||
# But do not overwrite if there is any upgrade |
|||
cp -a --update "$final_path/apps" "$tmpdir/apps" |
|||
|
|||
# Replace the old nextcloud by the new one |
|||
ynh_secure_remove "$final_path" |
|||
mv "$tmpdir" "$final_path" |
|||
|
|||
# Set write access for the following commands |
|||
chown -R $app: "$final_path" "$datadir" |
|||
|
|||
# Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3) |
|||
exec_occ maintenance:mode --off |
|||
exec_occ upgrade \ |
|||
|| ([[ $? -eq 3 ]] || ynh_die "Unable to upgrade Nextcloud") |
|||
|
|||
# Get the new current version number |
|||
current_version=$(grep OC_VersionString "$final_path/version.php" | cut -d\' -f2) |
|||
current_major_version=${current_version%%.*} |
|||
|
|||
# Print the current version number of nextcloud |
|||
exec_occ -V |
|||
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 |
|||
|
|||
#================================================= |
|||
# CONFIGURE NEXTCLOUD |
|||
#================================================= |
|||
|
|||
# Verify the checksum and backup the file if it's different |
|||
ynh_backup_if_checksum_is_different "${final_path}/config/config.php" |
|||
|
|||
nc_conf="${final_path}/config.json" |
|||
cp ../conf/config.json "$nc_conf" |
|||
ynh_replace_string "#DOMAIN#" "$domain" "$nc_conf" |
|||
ynh_replace_string "#DATADIR#" "$datadir" "$nc_conf" |
|||
|
|||
# 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" |
|||
|
|||
# Guess user_home value if empty |
|||
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 # 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 |
|||
exec_occ app:disable updatenotification |
|||
|
|||
# Enable External Storage and create local mount to home folder as needed |
|||
if [[ ${user_home} -eq 1 ]]; then |
|||
_exec_occ app:enable files_external |
|||
_exec_occ files_external:list --output=json \ |
|||
| grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ |
|||
|| create_home_external_storage '_exec_occ' |
|||
fi |
|||
# Enable plugins |
|||
exec_occ app:enable user_ldap |
|||
|
|||
# Load the config file in nextcloud |
|||
exec_occ config:import "$nc_conf" |
|||
# Then remove it |
|||
rm -f "$nc_conf" |
|||
|
|||
#================================================= |
|||
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD |
|||
#================================================= |
|||
|
|||
# Add dynamic logout URL to the config |
|||
# TODO: if changes are made to this section, replace it with new one. |
|||
_exec_occ config:system:get logout_url >/dev/null 2>&1 \ |
|||
|| sudo su -c "echo \" |
|||
exec_occ config:system:get logout_url >/dev/null 2>&1 \ |
|||
|| echo " |
|||
//-YunoHost- |
|||
// set logout_url according to main domain |
|||
\\\$main_domain = exec('cat /etc/yunohost/current_host'); |
|||
\\\$CONFIG['logout_url'] = 'https://'.\\\$main_domain.'/yunohost/sso/?action=logout'; |
|||
\$main_domain = exec('cat /etc/yunohost/current_host'); |
|||
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout'; |
|||
//-YunoHost- |
|||
\" >> ${DESTDIR}/config/config.php" -- $app |
|||
" >> "${final_path}/config/config.php" |
|||
|
|||
#================================================= |
|||
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE |
|||
#================================================= |
|||
|
|||
# Enable External Storage and create local mount to home folder as needed |
|||
if [ $user_home -eq 1 ]; then |
|||
exec_occ app:enable files_external |
|||
exec_occ files_external:list --output=json \ |
|||
| grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ |
|||
|| create_home_external_storage |
|||
fi |
|||
|
|||
#================================================= |
|||
# STORE THE CHECKSUM OF THE CONFIG FILE |
|||
#================================================= |
|||
|
|||
# Calculate and store the config file checksum into the app settings |
|||
ynh_store_file_checksum "${final_path}/config/config.php" |
|||
|
|||
#================================================= |
|||
# UPDATE THE CRON JOB |
|||
#================================================= |
|||
|
|||
cron_path="/etc/cron.d/$app" |
|||
cp -a ../conf/nextcloud.cron "$cron_path" |
|||
|
|||
ynh_replace_string "#USER#" "$app" "$cron_path" |
|||
ynh_replace_string "#DESTDIR#" "$final_path" "$cron_path" |
|||
|
|||
exec_occ background:cron |
|||
|
|||
#================================================= |
|||
# UPDATE THE HOOK FILE FOR USER CREATE |
|||
#================================================= |
|||
|
|||
# Set system group in hooks |
|||
ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create |
|||
|
|||
#================================================= |
|||
# GENERIC FINALIZATION |
|||
#================================================= |
|||
# SECURE FILES AND DIRECTORIES |
|||
#================================================= |
|||
|
|||
# Fix app ownerships & permissions |
|||
chown -R $app: "$final_path" "$datadir" |
|||
find ${final_path}/ -type f -print0 | xargs -0 chmod 0644 |
|||
find ${final_path}/ -type d -print0 | xargs -0 chmod 0755 |
|||
find ${datadir}/ -type f -print0 | xargs -0 chmod 0640 |
|||
find ${datadir}/ -type d -print0 | xargs -0 chmod 0750 |
|||
chmod 640 "${final_path}/config/config.php" |
|||
chmod 755 /home/yunohost.app |
|||
|
|||
# Iterate over users to extend their home folder permissions - for the external |
|||
# storage plugin usage - and create relevant Nextcloud directories |
|||
for u in $(ynh_user_list); do |
|||
sudo mkdir -p "${DATADIR}/${u}" |
|||
sudo setfacl -m g:$app:rwx "/home/$u" || true |
|||
mkdir -p "${datadir}/${u}" |
|||
setfacl -m g:$app:rwx "/home/$u" || true |
|||
done |
|||
|
|||
# Fix app ownerships & permissions |
|||
sudo find ${DESTDIR}/ -type f -print0 | sudo xargs -0 chmod 0644 |
|||
sudo find ${DESTDIR}/ -type d -print0 | sudo xargs -0 chmod 0755 |
|||
sudo find ${DATADIR}/ -type f -print0 | sudo xargs -0 chmod 0640 |
|||
sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750 |
|||
sudo chmod 640 "${DESTDIR}/config/config.php" |
|||
sudo chmod 755 /home/yunohost.app |
|||
|
|||
# Set SSOwat rules |
|||
ynh_app_setting_set "$real_app" unprotected_uris "/" |
|||
ynh_app_setting_set "$real_app" skipped_regex \ |
|||
#================================================= |
|||
# WARNING ABOUT THIRD-PARTY APPS |
|||
#================================================= |
|||
|
|||
# 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 enable them again." >&2 |
|||
|
|||
#================================================= |
|||
# SETUP LOGROTATE |
|||
#================================================= |
|||
|
|||
# Use logrotate to manage app-specific logfile(s) |
|||
ynh_use_logrotate |
|||
|
|||
#================================================= |
|||
# GENERIC FINALIZATION |
|||
#================================================= |
|||
# SETUP SSOWAT |
|||
#================================================= |
|||
|
|||
ynh_app_setting_set $app unprotected_uris "/" |
|||
ynh_app_setting_set $app skipped_regex \ |
|||
"$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*" |
|||
|
|||
# Reload services |
|||
sudo service php5-fpm restart || true |
|||
sudo service nginx reload || true |
|||
#================================================= |
|||
# RELOAD NGINX |
|||
#================================================= |
|||
|
|||
# Add cron job |
|||
cron_path="/etc/cron.d/$app" |
|||
sed -i "s@#USER#@${app}@g" ../conf/nextcloud.cron |
|||
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nextcloud.cron |
|||
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! \ |
|||
systemctl reload nginx |
|||
|
|||
#================================================= |
|||
# FINISH MIGRATION PROCESS |
|||
#================================================= |
|||
|
|||
if [ $migration_process -eq 1 ] |
|||
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 |
|||
|
|||
# Setup log rotation |
|||
if [ ! -f "/etc/logrotate.d/$app" ]; then |
|||
# Don't change the logrotate conf file if already existing |
|||
# (the helper only appends the log file configuration) |
|||
ynh_use_logrotate "/home/yunohost.app/nextcloud/data/nextcloud.log" |
|||
# Execute a post migration script after the end of this upgrade. |
|||
# Mainly for some cleaning |
|||
script_post_migration=owncloud_post_migration.sh |
|||
ynh_replace_string "__OLD_APP__" "$old_app" ../conf/$script_post_migration |
|||
ynh_replace_string "__NEW_APP__" "$app" ../conf/$script_post_migration |
|||
cp ../conf/$script_post_migration /tmp |
|||
chmod +x /tmp/$script_post_migration |
|||
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes) |
|||
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 |
|||
@ -1,64 +0,0 @@ |
|||
#!/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" |
|||
|
|||
echo "Migration to nextcloud." >&2 |
|||
|
|||
# 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" |
|||
@ -1,18 +1,7 @@ |
|||
#!/bin/bash |
|||
|
|||
# Version cible de la mise à jour de Nextcloud |
|||
VERSION="11.0.0" |
|||
next_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 |
|||
nextcloud_source_sha256="5bdfcb36c5cf470b9a6679034cabf88bf1e50a9f3e47c08d189cc2280b621429" |
|||
@ -1,18 +1,7 @@ |
|||
#!/bin/bash |
|||
|
|||
# Version cible de la mise à jour de Nextcloud |
|||
VERSION="12.0.0" |
|||
next_version="12.0.0" |
|||
|
|||
# Nextcloud tarball checksum |
|||
NEXTCLOUD_SOURCE_SHA256="1b9d9cf05e657cd564a552b418fbf42d669ca51e0fd1f1f118fe44cbf93a243f" |
|||
|
|||
# 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 |
|||
nextcloud_source_sha256="1b9d9cf05e657cd564a552b418fbf42d669ca51e0fd1f1f118fe44cbf93a243f" |
|||
@ -1,18 +1,7 @@ |
|||
#!/bin/bash |
|||
|
|||
# Version cible de la mise à jour de Nextcloud |
|||
VERSION="10.0.2" |
|||
next_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 |
|||
nextcloud_source_sha256="a687a818778413484f06bb23b4e98589c73729fe2aa9feb1bf5584e3bd37103c" |
|||
@ -1,53 +0,0 @@ |
|||
#!/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 |
|||
|
|||
echo -e "\nUpdate to nextcloud $VERSION" >&2 |
|||
|
|||
# Retrieve new Nextcloud sources in a temporary directory |
|||
TMPDIR=$(mktemp -d) |
|||
|
|||
# Set temp folder ownership |
|||
sudo chown -R $app: "$TMPDIR" |
|||
extract_nextcloud "$TMPDIR" "$app" # 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") |
|||
} |
|||
@ -1,18 +1,7 @@ |
|||
#!/bin/bash |
|||
|
|||
# Version cible de la mise à jour de Nextcloud |
|||
VERSION=12.0.2 |
|||
# Last available nextcloud version |
|||
next_version="12.0.4" |
|||
|
|||
# Nextcloud tarball checksum sha256 |
|||
NEXTCLOUD_SOURCE_SHA256=eb34d6cb9f55ee84bf2ad847b4b08cdb925321848ffa2264a9b1566e7b21a17c |
|||
|
|||
# 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 |
|||
nextcloud_source_sha256="654161a74ceaf9a60c7731d7d6702e6710a972633a97955d16f01abeb09d09b6" |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue