diff --git a/conf/config.json b/conf/config.json index 9e72abfd..9d8ba73a 100644 --- a/conf/config.json +++ b/conf/config.json @@ -17,7 +17,7 @@ "hashing_default_password": true, "localstorage.allowsymlinks": true, "simpleSignUpLink.shown": false, - "default_phone_region": "", + "default_phone_region": "fr", "maintenance_window_start": 1, "mail_smtpmode": "smtp", "mail_smtpport": "25", diff --git a/doc/ADMIN.md b/doc/ADMIN.md index de240f96..a718d008 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -4,7 +4,9 @@ You can run Nextcloud commands from the command line by opening a Nextcloud "she ```bash sudo yunohost app shell __APP__ -# You should then see you're in a shell with "__APP__@yourmachine" +``` +You should then see you're in a shell with "__APP__@yourmachine" +``` php occ ... ``` Alternatively, you can run `sudo -u __APP__ php__PHP_VERSION__ --define apc.enable_cli=1 __INSTALL_DIR__/occ ...` @@ -17,6 +19,8 @@ This user can be added to the Nextcloud admin group with : ```bash sudo yunohost app shell __APP__ -# And then +``` +And then +``` php occ group:adduser admin ``` diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 5fb52009..c70e6ec2 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -4,7 +4,9 @@ Vous pouvez lancer des commandes Nextcloud en ouvrant un "shell" Nextcloud et ut ```bash sudo yunohost app shell __APP__ -# Vous devriez voir que vous êtes dans un shell "__APP__@yourmachine" +``` +Vous devriez voir que vous êtes dans un shell `__APP__@yourmachine` +``` php occ ... ``` @@ -18,6 +20,8 @@ Vous pouvez ajouter le comptes aux admins de Nextcloud avec: ```bash sudo yunohost app shell __APP__ -# Puis +``` +Puis +``` php occ group:adduser admin ``` diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 4c681db5..3eb9f7e3 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -4,4 +4,4 @@ In the context of YunoHost, Nextcloud integrates with the SSO/User Portal (YunoH The `/.well-known` address will be automatically configured for CalDAV and CardDAV synchronization if no other service such as Baïkal is already using it. -The YunoHost catalog has two collaborative office suites, [OnlyOffice](https://github.com/YunoHost-Apps/onlyoffice_ynh) and [Collabora](https://github.com/YunoHost-Apps/collabora_ynh), which can be integrated with Nextcloud. \ No newline at end of file +The YunoHost catalog has two collaborative office suites, [OnlyOffice](https://apps.yunohost.org/app/onlyoffice) and [Collabora](https://apps.yunohost.org/app/collabora), which can be integrated with Nextcloud. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index a19201ad..7bc00ca5 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -4,4 +4,4 @@ Dans le cadre de YunoHost, Nextcloud s'intègre avec le SSO/portail utilisateur L'adresse `/.well-known` sera automatiquement configuré pour la synchronisation CalDAV et CardDAV si aucun autre service tel que Baïkal ne l'utilise déjà. -Le catalogue YunoHost dispose de deux suites bureautiques collaboratives, [OnlyOffice](https://github.com/YunoHost-Apps/onlyoffice_ynh) et [Collabora](https://github.com/YunoHost-Apps/collabora_ynh), qui peuvent être intégrées à Nextcloud. +Le catalogue YunoHost dispose de deux suites bureautiques collaboratives, [OnlyOffice](https://apps.yunohost.org/app/onlyoffice) et [Collabora](https://apps.yunohost.org/app/collabora), qui peuvent être intégrées à Nextcloud. diff --git a/doc/PRE_UPGRADE.md b/doc/PRE_UPGRADE.md new file mode 100644 index 00000000..e8a5189b --- /dev/null +++ b/doc/PRE_UPGRADE.md @@ -0,0 +1 @@ +Before updating NextCloud, make sure that your applications are compatible with the Nextcloud version you are about to install. Also update all your applications installed in NextCloud before updating. diff --git a/doc/PRE_UPGRADE_fr.md b/doc/PRE_UPGRADE_fr.md new file mode 100644 index 00000000..22eb6827 --- /dev/null +++ b/doc/PRE_UPGRADE_fr.md @@ -0,0 +1 @@ +Avant de mettre à jour NextCloud, assurez-vous que vos applications sont compatibles avec la version de Nextcloud que vous êtes sur le point d'installer. Mettez également à jour l'ensemble de vos applications installées dans NextCloud avant d'effectuer la mise à jour. diff --git a/manifest.toml b/manifest.toml index e72f8d46..d3679d83 100644 --- a/manifest.toml +++ b/manifest.toml @@ -149,6 +149,7 @@ ram.runtime = "512M" "tar", "smbclient", "at", + "postgresql", "mariadb-server", "redis-server", "php8.5-apcu", @@ -180,4 +181,4 @@ ram.runtime = "512M" """ [resources.database] - type = "mysql" + type = "postgresql" diff --git a/patches/30/00-add-logout_url-conf.patch b/patches/30/00-add-logout_url-conf.patch index 8628b783..fd177f44 100644 --- a/patches/30/00-add-logout_url-conf.patch +++ b/patches/30/00-add-logout_url-conf.patch @@ -8,8 +8,8 @@ index d4d6a17db79..f587f805683 100644 $loginToken = $this->request->getCookie('nc_token'); + $uuidUser = $this->userSession->getUser()->getUID(); + $isLdapUser = $this->config->getUserValue($uuidUser, 'user_ldap', 'uid'); - if (!is_null($loginToken)) { -- $this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken); + if ($loginToken !== null && $uid !== null) { +- $this->config->deleteUserValue($uid, 'login_token', $loginToken); + $this->config->deleteUserValue($uuidUser, 'login_token', $loginToken); } $this->userSession->logout(); diff --git a/patches/main/00-add-logout_url-conf.patch b/patches/main/00-add-logout_url-conf.patch index 4ca916f5..9b768423 100644 --- a/patches/main/00-add-logout_url-conf.patch +++ b/patches/main/00-add-logout_url-conf.patch @@ -24,7 +24,6 @@ index 1a105130..9a51f8d9 100644 + } + + $response = new RedirectResponse($redirectUrl); - + $this->session->set('clearingExecutionContexts', '1'); $this->session->close(); - diff --git a/scripts/backup b/scripts/backup index feb41380..3134150f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -40,11 +40,11 @@ ynh_backup "/etc/cron.d/$app" ynh_backup "/var/log/$app" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Backing up the MySQL database..." +ynh_print_info "Backing up the PostgreSQL database..." -ynh_mysql_dump_db > db.sql +ynh_psql_dump_db > db.sql #================================================= # BACKUP THE NOTIFY_PUSH APP diff --git a/scripts/change_url b/scripts/change_url index 03a03070..7b6de95d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -39,6 +39,7 @@ then # Reload PHP-FPM, necessary for force Nextcloud to re-read config.php, cf opcache.revalidate_freq ynh_systemctl --service=php${php_version}-fpm --action=reload + mkdir -p /etc/nginx/conf.d/$new_domain.d/$app.d mv /etc/nginx/conf.d/$old_domain.d/$app.d /etc/nginx/conf.d/$new_domain.d/$app.d fi diff --git a/scripts/config b/scripts/config index cbdbe78d..8258a296 100644 --- a/scripts/config +++ b/scripts/config @@ -19,7 +19,7 @@ get__maintenance_mode() { if echo $maintenance_mode_status | grep -q "disabled" then echo "0" - elif echo $maintenance_mode_status | grep -q "enabled" + elif echo "$maintenance_mode_status" | grep -q "enabled" then echo "1" else diff --git a/scripts/install b/scripts/install index a0e404dc..d16e88d2 100755 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,8 @@ source /usr/share/yunohost/helpers ynh_app_setting_set_default --key=php_upload_max_filesize --value=10G ynh_app_setting_set_default --key=php_memory_limit --value=512M - +ynh_app_setting_set_default --key=fpm_footprint --value=high +ynh_app_setting_set_default --key=fpm_usage --value=medium ynh_app_setting_set_default --key=enable_notify_push --value=0 phpflags="--define apc.enable_cli=1" @@ -17,12 +18,9 @@ ynh_app_setting_set --key=phpflags --value="$phpflags" ldap_email_attr="mail" -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression "Migrate MySQL database to utf8..." - -ynh_mysql_db_shell <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" +enable_forward_email="0" +ynh_app_setting_set --key=enable_forward_email --value=0 +ldap_email_attr="mail" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -79,7 +77,7 @@ admin_password="$(ynh_string_random --length=6)" # Install Nextcloud using a temporary admin user exec_occ maintenance:install \ - --database "mysql" --database-name $db_name \ + --database "pgsql" --database-port "5432" --database-name $db_name \ --database-user $db_user --database-pass "$db_pwd" \ --admin-user "admin" --admin-pass "$admin_password" \ --data-dir "$data_dir/data" \ @@ -90,9 +88,6 @@ exec_occ maintenance:install \ #================================================= ynh_script_progression "Configuring $app..." -# Set the mysql.utf8mb4 config to true in config.php -exec_occ config:system:set mysql.utf8mb4 --type=boolean --value="true" - # move the logs from the data_dir to the standard /var/log exec_occ config:system:set logfile --value="/var/log/$app/nextcloud.log" @@ -182,7 +177,7 @@ exec_occ config:system:set overwrite.cli.url --value="https://${domain}${path}" #================================================= # Set the user as admin -ynh_mysql_db_shell <<< "INSERT INTO oc_group_user VALUES ('admin','$admin');" +ynh_psql_db_shell <<< "INSERT INTO oc_group_user VALUES ('admin','$admin');" # And delete admin user exec_occ user:delete admin diff --git a/scripts/remove b/scripts/remove index df1fe905..720d7bb8 100755 --- a/scripts/remove +++ b/scripts/remove @@ -26,7 +26,6 @@ if [ $enable_notify_push -eq 1 ]; then fi # Remove a cron file -# TODO: Ensure that cron job is not running (How !?) ynh_safe_rm "/etc/cron.d/$app" # Cleaning ACL in home directories diff --git a/scripts/restore b/scripts/restore index bb21b487..d9bcdb85 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,11 +18,11 @@ ynh_script_progression "Restoring data directory..." ynh_restore "$data_dir" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression "Restoring the MySQL database..." +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_mysql_db_shell < ./db.sql +ynh_psql_db_shell < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS @@ -87,6 +87,7 @@ ynh_script_progression "Adding multimedia directories..." # Build YunoHost multimedia directories ynh_multimedia_build_main_dir + # Allow nextcloud to write into these directories ynh_multimedia_addaccess $app @@ -101,8 +102,8 @@ ynh_restore "/etc/fail2ban/filter.d/$app.conf" # Make sure a log file exists (mostly for CI tests) logfile="/var/log/$app/nextcloud.log" if [ ! -f "$logfile" ]; then - touch "$logfile" - chown "$app:" "$logfile" + touch "$logfile" + chown "$app:" "$logfile" fi ynh_systemctl --action=restart --service=fail2ban diff --git a/scripts/upgrade b/scripts/upgrade index d7b316f8..790ad463 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ ynh_app_setting_set_default --key=php_upload_max_filesize --value=10G ynh_app_setting_set_default --key=php_memory_limit --value=512M ynh_app_setting_set_default --key=enable_notify_push --value=0 +ynh_app_setting_set_default --key=enable_forward_email --value=0 # Remove the option backup_core_only if it's in the settings.yml file ynh_app_setting_delete --key=backup_core_only @@ -37,6 +38,12 @@ filter_boring_occ_warnings() { sed -E 's@\s*([0-9]+\/[0-9]+\s+\[(-|>|=)+\]\s+[0-9]+%|\s*Starting ...|Nextcloud or one of the apps require upgrade - only a limited number of commands are available|You may use your browser or the occ upgrade command to do the upgrade)@@g' } +current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2) +current_major_version=${current_version%%.*} + +last_version=$(ynh_read_manifest "resources.sources.main.url" | grep -Eo '[0-9][0-9]\.[0-9]\.[0-9]+') +last_major_version=${last_version%%.*} + # Define a function to execute commands with `occ` exec_occ() { # Backward compatibility to upgrade from older versions @@ -76,6 +83,44 @@ exec_occ() { php$NEXTCLOUD_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") 2> >(filter_boring_occ_warnings >&2) } +#================================================= +# HANDLE DATABASE MIGRATION FROM MYSL TO PSQL +#================================================= + +# If the MySQL database is here, we should migrate +if mysql -e "USE $db_name" 2>/dev/null +then + # Migrate mysql db onto postgresql if the db is empty + if [[ "$(ynh_psql_db_shell "$db_name" <<< "\dt" 2>/dev/null | wc -l)" == "0" ]] + then + mysql_size=$(du -bs /var/lib/mysql/$app | awk '{print $1}') + mysql_size_human=$(du -hs /var/lib/mysql/$app | awk '{print $1}') + free_space=$(df --output=avail /var/lib/postgresql/*/main | tail -n1) + free_space=$((free_space * 1024)) + [ $mysql_size -ge $free_space ] && ynh_die "Unable to migrate the database $app ($mysql_size_human) due to lack of free space." + ynh_print_info "Migrating to PostgreSQL database..." + ynh_hide_warnings exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n + fi + + # Remove mysql db if the postgresql db is not empty + if [[ "$(ynh_psql_db_shell "$db_name" <<< "\dt" 2>/dev/null | wc -l)" != "0" ]] + then + ynh_mysql_drop_db $db_name + nc_conf="${install_dir}/config/config.php" + # Verify the checksum and backup the file if it's different + ynh_backup_if_checksum_is_different "$install_dir/config/config.php" + + ynh_write_var_in_file --file="$nc_conf" --key="dbtype" --value="pgsql" + ynh_write_var_in_file --file="$nc_conf" --key="dbuser" --value="$db_user" + ynh_write_var_in_file --file="$nc_conf" --key="dbpassword" --value="$db_pwd" + ynh_store_file_checksum "$nc_conf" + fi +fi + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + # Define a function to add an external storage # Create the external storage for the given folders and enable sharing create_external_storage() { @@ -122,7 +167,7 @@ then installed_apps_not_compatible_with_future_version="$(list_installed_apps_not_compatible_with_future_version $last_major_version)" if [[ -n "$installed_apps_not_compatible_with_future_version" ]] then - ynh_die "The following apps are not (yet?) compatible with Nextcloud $last_major_version. You should make sure to upgrade the app, or disable it, or wait for it to become compatible before running this upgrade : $installed_apps_not_compatible_with_future_version" + ynh_die "The following apps are not (yet?) compatible with Nextcloud $last_major_version. You should make sure to upgrade the app, or disable it, or wait for it to become compatible before running this upgrade: $installed_apps_not_compatible_with_future_version" fi fi @@ -153,15 +198,6 @@ chown -R $app:www-data "$install_dir" # Print the current version number of Nextcloud exec_occ -V -if [ "$(exec_occ config:system:get mysql.utf8mb4)" != "true" ]; then - db_pwd=$(ynh_app_setting_get --key=db_pwd) - # Change your databases character set and collation - ynh_mysql_db_shell <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" - # Set the mysql.utf8mb4 config to true in config.php - exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true" - exec_occ maintenance:repair -fi - # Upgrade may fail if this app is enabled # Take all apps enabled, and check if mail is one of them # Then temporary disable the mail app @@ -231,6 +267,7 @@ if [[ "$current_major_version" -le "$last_major_version" ]]; then exec_occ -V done fi + exec_occ db:add-missing-indices -n exec_occ db:add-missing-columns -n exec_occ db:add-missing-primary-keys -n @@ -282,6 +319,9 @@ ynh_safe_rm "$nc_conf" # Migrating the mimetypes take a long time on larger instances # so this is not done automatically during upgrades. exec_occ maintenance:repair --include-expensive +# New indexes are sometimes added (by Nextcloud or installed applications) +# to improve database performance. +exec_occ db:add-missing-indices #================================================= # ALLOW USERS TO DISCONNECT FROM NEXTCLOUD @@ -390,7 +430,6 @@ then ynh_config_add --template="notify_push.conf" --destination="$nginx_extra_conf_dir/notify_push.conf" fi -# Create a dedicated NGINX config ynh_config_add_nginx #=================================================