diff --git a/README.md b/README.md index 146d35d..83e2e54 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ -Nextcloud for YunoHost ---------------------- +# Nextcloud for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/nextcloud.svg)](https://dash.yunohost.org/appci/app/nextcloud) +[![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=nextcloud) + +> *This package allow you to install Nextcloud quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + +## Overview [Nextcloud](https://nextcloud.com) gives you freedom and control over your own data. A personal cloud which run on your own server. With Nextcloud @@ -7,10 +14,23 @@ you can synchronize your files over your devices. **Shipped version:** 15.0.2 -[![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=nextcloud) +## Screenshots + ![](https://raw.githubusercontent.com/nextcloud/screenshots/master/files/Files%20Overview.png) -## Features +## Demo + +* [YunoHost demo](https://demo.yunohost.org/nextcloud/) +* [Official demo](https://demo.nextcloud.com/) + +## Configuration + +## Documentation + + * Official documentation: https://docs.nextcloud.com/server/15/user_manual/ + * YunoHost documentation: https://github.com/YunoHost/doc/blob/master/app_nextcloud_fr.md + +## YunoHost specific features In addition to Nextcloud core features, the following are made available with this package: @@ -23,6 +43,14 @@ this package: * Serve `/.well-known` paths for CalDAV and CardDAV on the domain only if it's not already served - i.e. by Baïkal +#### Multi-users support + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/nextcloud%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/nextcloud/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/nextcloud%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/nextcloud/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/nextcloud%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/nextcloud/) + ## Limitations To integrate the logout button to the SSO, we have to patch Nextcloud sources. @@ -38,7 +66,9 @@ Finally, the following error message in Nextcloud logs can be safely ignored: Following symlinks is not allowed ('/home/yunohost.multimedia/user/Share' -> '/home/yunohost.multimedia/share/' not inside '/home/yunohost.multimedia/user/') ``` -## Migrate from ownCloud +## Additionnal informations + +#### Migrate from ownCloud **This is not considered as stable yet, please do it with care and only for testing!** @@ -72,6 +102,20 @@ sudo yunohost app ssowatconf ## Links - * Report a bug: https://dev.yunohost.org/projects/apps/issues + * Report a bug: https://github.com/YunoHost-Apps/nextcloud_ynh/issues * Nextcloud website: https://nextcloud.com/ * YunoHost website: https://yunohost.org/ + +--- + +Developers infos +---------------- + +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing --debug +or +sudo yunohost app upgrade nextcloud -u https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing --debug +``` diff --git a/conf/config_install.json b/conf/config_install.json index 52bff54..10db7cf 100644 --- a/conf/config_install.json +++ b/conf/config_install.json @@ -1,9 +1,9 @@ { "system": { - "datadirectory": "#DATADIR#", + "datadirectory": "__DATADIR__", "trusted_domains": [ "localhost", - "#DOMAIN#" + "__DOMAIN__" ] } } diff --git a/conf/nextcloud.cron b/conf/nextcloud.cron index 294325b..93fde63 100644 --- a/conf/nextcloud.cron +++ b/conf/nextcloud.cron @@ -1 +1 @@ -*/15 * * * * #USER# /usr/bin/php -f #DESTDIR#/cron.php +*/15 * * * * __USER__ /usr/bin/php -f __DESTDIR__/cron.php diff --git a/conf/nginx.conf b/conf/nginx.conf index 1691095..6d217e1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,8 +6,11 @@ location = /.well-known/caldav { } location ^~ __PATH__ { + + # Path to source alias __FINALPATH__/; + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -24,12 +27,12 @@ location ^~ __PATH__ { # Set max upload size client_max_body_size 10G; fastcgi_buffers 64 4K; - + # Extend timeouts client_body_timeout 60m; proxy_read_timeout 60m; fastcgi_read_timeout 60m; - + # Disable gzip to avoid the removal of the ETag header gzip off; diff --git a/hooks/post_user_create b/hooks/post_user_create index f215f00..da6bb53 100644 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -2,4 +2,4 @@ user=$1 -sudo setfacl -m g:#GROUP#:rwx /home/$user +sudo setfacl --modify g:__GROUP__:rwx /home/$user diff --git a/scripts/_common.sh b/scripts/_common.sh index 566494d..540c024 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,44 +9,6 @@ if [ "$(lsb_release --codename --short)" != "jessie" ]; then pkg_dependencies="$pkg_dependencies php-zip php-apcu php-mbstring php-xml" fi -#================================================= -# COMMON HELPERS -#================================================= - -# Execute a command with occ -exec_occ() { - (cd "$final_path" && exec_as "$app" \ - php occ --no-interaction --no-ansi "$@") -} - -# Create the external storage for the given folders and enable sharing -create_external_storage() { - local datadir="$1" - local mount_name="$2" - local mount_id=`exec_occ files_external:create --output=json \ - "$2" 'local' 'null::null' -c "datadir=$datadir" || true` - ! [[ $mount_id =~ ^[0-9]+$ ]] \ - && echo "Unable to create external storage" >&2 \ - || exec_occ files_external:option "$mount_id" enable_sharing true -} - -# Rename a MySQL database and user -# Usage: rename_mysql_db DBNAME DBUSER DBPASS NEW_DBNAME_AND_USER -rename_mysql_db() { - local db_name=$1 db_user=$2 db_pwd=$3 new_db_name=$4 - local sqlpath="/tmp/${db_name}-$(date '+%s').sql" - - # Dump the old database - mysqldump -u "$db_user" -p"$db_pwd" --no-create-db "$db_name" > "$sqlpath" - - # Create the new database and user - ynh_mysql_create_db "$new_db_name" "$new_db_name" "$db_pwd" - ynh_mysql_connect_as "$new_db_name" "$db_pwd" "$new_db_name" < "$sqlpath" - - # Remove the old database - ynh_mysql_remove_db $db_name $db_name - ynh_secure_remove "$sqlpath" -} #================================================= # COMMON HELPERS -- SHOULD BE ADDED TO YUNOHOST diff --git a/scripts/backup b/scripts/backup index 0a1f69c..a41fb88 100755 --- a/scripts/backup +++ b/scripts/backup @@ -2,18 +2,11 @@ #================================================= # 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 ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -77,11 +70,7 @@ ynh_backup "/etc/cron.d/$app" # 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 +# The 1 parameter indicates the directory is "big", +# so that it won't be backed up before upgrade +# This argument has to be the third one. +ynh_backup "/home/yunohost.app/${app}/data" "/home/yunohost.app/${app}/data" 1 diff --git a/scripts/install b/scripts/install index 5bc37bf..2c301c0 100755 --- a/scripts/install +++ b/scripts/install @@ -37,8 +37,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -89,16 +87,11 @@ ynh_setup_source "$final_path" #================================================= # Do not serve .well-known if it's already served on the domain -if is_url_handled "https://${domain}/.well-known/caldav" ; then +if is_url_handled "https://$domain/.well-known/caldav" ; then sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ - "../conf/nginx.conf" + "../conf/nginx.conf" fi -# 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 @@ -123,7 +116,7 @@ ynh_add_fpm_config #================================================= # Define app's data directory -datadir="/home/yunohost.app/${app}/data" +datadir="/home/yunohost.app/$app/data" # Create app folders mkdir -p "$datadir" @@ -131,16 +124,22 @@ mkdir -p "$datadir" # INSTALL NEXTCLOUD #================================================= +# Define a function to execute commands with `occ` +exec_occ() { + (cd "$final_path" && exec_as "$app" \ + php occ --no-interaction --no-ansi "$@") +} + # 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 "$db_name" \ - --database-user "$db_name" --database-pass "$db_pwd" \ + --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" \ - || ynh_die "Unable to install Nextcloud" + || ynh_die "Unable to install Nextcloud" #================================================= # CONFIGURE NEXTCLOUD @@ -149,24 +148,28 @@ exec_occ maintenance:install \ # Ensure that UpdateNotification app is disabled exec_occ app:disable updatenotification -# Enable plugins +# Enable ldap plugins exec_occ app:enable user_ldap exec_occ ldap:create-empty-config # Load the installation config file in nextcloud -nc_conf="${final_path}/config_install.json" +nc_conf="$final_path/config_install.json" cp ../conf/config_install.json "$nc_conf" -ynh_replace_string "#DOMAIN#" "$domain" "$nc_conf" -ynh_replace_string "#DATADIR#" "$datadir" "$nc_conf" + +ynh_replace_string "__DOMAIN__" "$domain" "$nc_conf" +ynh_replace_string "__DATADIR__" "$datadir" "$nc_conf" exec_occ config:import "$nc_conf" -# Then remove it + +# Then remove the config file rm -f "$nc_conf" # Load the additional config file (used also for upgrade) -nc_conf="${final_path}/config_install.json" +nc_conf="$final_path/config.json" cp ../conf/config.json "$nc_conf" + exec_occ config:import "$nc_conf" -# Then remove it + +# Then remove the config file rm -f "$nc_conf" #================================================= @@ -181,13 +184,26 @@ exec_occ ldap:test-config \'\' \ # MOUNT HOME FOLDERS AS EXTERNAL STORAGE #================================================= +# Define a function to add an external storage +# Create the external storage for the given folders and enable sharing +create_external_storage() { + local datadir="$1" + local mount_name="$2" + local mount_id=`exec_occ files_external:create --output=json \ + "$mount_name" 'local' 'null::null' -c "datadir=$datadir" || true` + ! [[ $mount_id =~ ^[0-9]+$ ]] \ + && echo "Unable to create external storage" >&2 \ + || exec_occ files_external:option "$mount_id" enable_sharing true +} + # Enable External Storage and create local mount to home folder -if [ $user_home -eq 1 ]; then +if [ $user_home -eq 1 ] +then exec_occ app:enable files_external create_external_storage "/home/\$user" "Home" # Iterate over users to extend their home folder permissions for u in $(ynh_user_list); do - setfacl -m g:$app:rwx "/home/$u" || true + setfacl --modify g:$app:rwx "/home/$u" || true done fi @@ -203,7 +219,7 @@ exec_occ config:system:get logout_url >/dev/null 2>&1 \ \$main_domain = exec('cat /etc/yunohost/current_host'); \$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout'; //-YunoHost- -" >> "${final_path}/config/config.php" +" >> "$final_path/config/config.php" #================================================= # REMOVE THE TEMPORARY ADMIN AND SET THE TRUE ONE @@ -220,7 +236,7 @@ exec_occ user:delete admin #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "${final_path}/config/config.php" +ynh_store_file_checksum "$final_path/config/config.php" #================================================= # ADD A CRON JOB @@ -231,14 +247,15 @@ cp -a ../conf/nextcloud.cron "$cron_path" chown root: "$cron_path" chmod 644 "$cron_path" -ynh_replace_string "#USER#" "$app" "$cron_path" -ynh_replace_string "#DESTDIR#" "$final_path" "$cron_path" +ynh_replace_string "__USER__" "$app" "$cron_path" +ynh_replace_string "__DESTDIR__" "$final_path" "$cron_path" exec_occ background:cron #================================================= # POST-INSTALL MAINTENANCE #================================================= + (cd /tmp ; at now + 10 minutes <<< "(cd $final_path ; sudo -u $app php occ db:add-missing-indices ; sudo -u $app php occ db:convert-filecache-bigint -n) > /tmp/${app}_maintenance.log") #================================================= @@ -246,7 +263,7 @@ exec_occ background:cron #================================================= # Set system group in hooks -ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create +ynh_replace_string "__GROUP__" "$app" ../hooks/post_user_create #================================================= # YUNOHOST MULTIMEDIA INTEGRATION @@ -269,19 +286,19 @@ ynh_multimedia_addaccess $app # 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" +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 #================================================= # SETUP LOGROTATE #================================================= -# Use logrotate to manage application logfile -ynh_use_logrotate "${datadir}/nextcloud.log" +# Use logrotate to manage application logfile(s) +ynh_use_logrotate "$datadir/nextcloud.log" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index b21d030..907a7e7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -78,8 +78,9 @@ ynh_secure_remove "/etc/cron.d/$app" #================================================= for i in $(ls /home); do + # Clean ACL in every directories in /home, except those which start with 'yunohost.' [[ ! $i == yunohost.* ]] \ - && setfacl -x g:$app:rwx 2>&1 + && setfacl --remove g:$app:rwx 2>&1 done #================================================= diff --git a/scripts/restore b/scripts/restore index 7f601db..157128a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -2,18 +2,11 @@ #================================================= # 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 ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -103,7 +96,7 @@ ynh_restore_file "/etc/logrotate.d/$app" # RESTORE THE DATA DIRECTORY #================================================= -datadir="/home/yunohost.app/${app}/data" +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. @@ -114,8 +107,6 @@ else # Create app folders mkdir -p "$datadir" fi -# Remove the option backup_core_only if it's in the settings.yml file -ynh_app_setting_delete $app backup_core_only #================================================= # RESTORE USER RIGHTS @@ -123,14 +114,14 @@ ynh_app_setting_delete $app backup_core_only # Fix app ownerships & permissions chown -R $app: "$final_path" "$datadir" -chmod 640 "${final_path}/config/config.php" +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 - mkdir -p "${datadir}/${u}" - setfacl -m g:$app:rwx "/home/$u" || true + mkdir -p "$datadir/$u" + setfacl --modify g:$app:rwx "/home/$u" || true done #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d0c6329..78bdce9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,34 +38,33 @@ if [ -z $final_path ]; then ynh_app_setting_set $app final_path $final_path fi +# Remove the option backup_core_only if it's in the settings.yml file +ynh_app_setting_delete $app backup_core_only + #================================================= # 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 + # 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 + # restore it if the upgrade fails + ynh_restore_upgradebackup } fi -# Exit if an error occurs during the script execution +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -75,7 +74,7 @@ ynh_abort_if_errors ynh_handle_app_migration "owncloud" "owncloud_migration" if [ $migration_process -eq 1 ] then - # If a migration has been perform + # If a migration has been performed # 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) @@ -106,19 +105,17 @@ path_url=$(ynh_normalize_url_path $path_url) # NGINX CONFIGURATION #================================================= +ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain.d/$app.conf" + # 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" -fi -# 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" +# 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" +fi # Create a dedicated nginx config ynh_add_nginx_config @@ -127,7 +124,7 @@ ynh_add_nginx_config # CREATE DEDICATED USER #================================================= -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create $app #================================================= @@ -149,13 +146,20 @@ ynh_install_app_dependencies $pkg_dependencies # MAKE SEQUENTIAL UPGRADES FROM EACH MAJOR # VERSION TO THE NEXT ONE #================================================= +ynh_print_info "Upgrading nextcloud..." + +# Define a function to execute commands with `occ` +exec_occ() { + (cd "$final_path" && exec_as "$app" \ + php occ --no-interaction --no-ansi "$@") +} # 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" +datadir="/home/yunohost.app/$app/data" # Set write access for the following commands chown -R $app: "$final_path" "$datadir" @@ -183,7 +187,7 @@ do # Load the value for this version source upgrade.d/upgrade.$current_major_version.sh - echo -e "\nUpgrade to nextcloud $next_version" >&2 + ynh_print_info "Upgrade to nextcloud $next_version" # Create an app.src for this version of nextcloud cp ../conf/app.src.default ../conf/app.src @@ -217,7 +221,7 @@ do # Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3) exec_occ maintenance:mode --off exec_occ upgrade \ - || ([[ $? -eq 3 ]] || ynh_die "Unable to upgrade Nextcloud") + || ([ $? -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) @@ -232,12 +236,13 @@ done #================================================= # Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different "${final_path}/config/config.php" +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" + +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 @@ -247,7 +252,8 @@ exec_occ app:enable user_ldap # Load the config file in nextcloud exec_occ config:import "$nc_conf" -# Then remove it + +# Then remove the config file rm -f "$nc_conf" #================================================= @@ -262,12 +268,24 @@ exec_occ config:system:get logout_url >/dev/null 2>&1 \ \$main_domain = exec('cat /etc/yunohost/current_host'); \$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout'; //-YunoHost- -" >> "${final_path}/config/config.php" +" >> "$final_path/config/config.php" #================================================= # MOUNT HOME FOLDERS AS EXTERNAL STORAGE #================================================= +# Define a function to add an external storage +# Create the external storage for the given folders and enable sharing +create_external_storage() { + local datadir="$1" + local mount_name="$2" + local mount_id=`exec_occ files_external:create --output=json \ + "$mount_name" 'local' 'null::null' -c "datadir=$datadir" || true` + ! [[ $mount_id =~ ^[0-9]+$ ]] \ + && echo "Unable to create external storage" >&2 \ + || exec_occ files_external:option "$mount_id" enable_sharing true +} + # Enable External Storage and create local mount to home folder as needed if [ $user_home -eq 1 ]; then exec_occ app:enable files_external @@ -276,7 +294,7 @@ if [ $user_home -eq 1 ]; then || create_external_storage "/home/\$user" "Home" # Iterate over users to extend their home folder permissions for u in $(ynh_user_list); do - setfacl -m g:$app:rwx "/home/$u" || true + setfacl --modify g:$app:rwx "/home/$u" || true done fi @@ -296,8 +314,8 @@ cp -a ../conf/nextcloud.cron "$cron_path" chown root: "$cron_path" chmod 644 "$cron_path" -ynh_replace_string "#USER#" "$app" "$cron_path" -ynh_replace_string "#DESTDIR#" "$final_path" "$cron_path" +ynh_replace_string "__USER__" "$app" "$cron_path" +ynh_replace_string "__DESTDIR__" "$final_path" "$cron_path" exec_occ background:cron @@ -306,7 +324,7 @@ exec_occ background:cron #================================================= # Set system group in hooks -ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create +ynh_replace_string "__GROUP__" "$app" ../hooks/post_user_create #================================================= # YUNOHOST MULTIMEDIA INTEGRATION @@ -329,11 +347,11 @@ ynh_multimedia_addaccess $app # 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" +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 #================================================= @@ -341,8 +359,8 @@ chmod 755 /home/yunohost.app #================================================= # 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 +ynh_print_warn "Note that if you've installed some third-parties Nextcloud applications, \ +they are probably disabled and you'll have to manually enable them again." #================================================= # SETUP LOGROTATE @@ -373,10 +391,10 @@ systemctl reload nginx if [ $migration_process -eq 1 ] then - echo "ownCloud has been successfully migrated to Nextcloud! \ + ynh_print_info "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 +you don't see Nextcloud as installed." # Execute a post migration script after the end of this upgrade. # Mainly for some cleaning