diff --git a/conf/config.json b/conf/config.json index bb800325..0063ee9a 100644 --- a/conf/config.json +++ b/conf/config.json @@ -14,6 +14,7 @@ "hashing_default_password": true, "localstorage.allowsymlinks": true, "simpleSignUpLink.shown": false, + "default_phone_region": "", "maintenance_window_start": 1, "mail_smtpmode": "smtp", "mail_smtpport": "25", diff --git a/manifest.toml b/manifest.toml index c11eb993..eb0b9f2b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -27,7 +27,7 @@ multi_instance = true ldap = true sso = true -disk = "650M" +disk = "850M" ram.build = "250M" ram.runtime = "512M" @@ -116,7 +116,8 @@ ram.runtime = "512M" api.allowed = ["visitors", "all_users"] [resources.apt] - packages = "mariadb-server, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, redis-server, php8.3-fpm, php8.3-bz2, php8.3-imap, php8.3-gmp, php8.3-gd, php8.3-intl, php8.3-curl, php8.3-apcu, php8.3-redis, php8.3-ldap, php8.3-imagick, php8.3-zip, php8.3-mbstring, php8.3-xml, php8.3-mysql, php8.3-igbinary, php8.3-bcmath" + packages = "postgresql, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, redis-server, php8.3-pgsql, php8.3-mysql, php8.3-fpm, php8.3-bz2, php8.3-imap, php8.3-gmp, php8.3-gd, php8.3-intl, php8.3-curl, php8.3-apcu, php8.3-redis, php8.3-ldap, php8.3-imagick, php8.3-zip, php8.3-mbstring, php8.3-xml, php8.3-igbinary, php8.3-bcmath" [resources.database] - type = "mysql" + type = "postgresql" + \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 33c1736a..19c0decc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,12 @@ # COMMON VARIABLES AND CUSTOM HELPERS #================================================= +# Define a function to execute commands with `occ` +exec_occ() { + (cd "$install_dir" && ynh_exec_as_app \ + php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") +} + wait_nginx_reload() { # NGINX may take some time to support the new configuration, # wait for the Nextcloud configuration file to disappear from NGINX before checking the CalDAV/CardDAV URL. diff --git a/scripts/backup b/scripts/backup index 33c0c7f1..7c48d677 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 509b92dc..2277ed4f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,10 +29,10 @@ ynh_config_change_url_nginx ynh_script_progression "Applying $app specific modifications..." # Define a function to execute commands with `occ` -exec_occ() { - (cd "$install_dir" && ynh_exec_as_app \ - php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") -} +#exec_occ() { +# (cd "$install_dir" && ynh_exec_as_app \ +# php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") +#} if [ $change_domain -eq 1 ] then diff --git a/scripts/config b/scripts/config index fc45c353..447e3c34 100644 --- a/scripts/config +++ b/scripts/config @@ -10,10 +10,10 @@ source /usr/share/yunohost/helpers php_version=$(ynh_app_setting_get --key=php_version) current_fpm_footprint=$(ynh_app_setting_get --key=fpm_footprint) -exec_occ() { - (cd "$install_dir" && ynh_exec_as_app \ - php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") -} +#exec_occ() { +# (cd "$install_dir" && ynh_exec_as_app \ +# php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") +#} #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY diff --git a/scripts/install b/scripts/install index cd270cc0..eb866c50 100755 --- a/scripts/install +++ b/scripts/install @@ -22,13 +22,6 @@ ynh_app_setting_set --key=enable_notify_push --value=0 system_addressbook_exposed="0" ynh_app_setting_set --key=system_addressbook_exposed --value=0 -#================================================= -# 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;" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -73,10 +66,10 @@ ynh_config_add_nginx ynh_script_progression "Installing $app..." # Define a function to execute commands with `occ` -exec_occ() { - (cd "$install_dir" && ynh_exec_as_app \ - php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") -} +#exec_occ() { +# (cd "$install_dir" && ynh_exec_as_app \ +# php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") +#} # Set write access for the following commands chown -R $app:www-data "$install_dir" @@ -89,7 +82,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-name $db_name \ --database-user $db_user --database-pass "$db_pwd" \ --admin-user "admin" --admin-pass "$admin_password" \ --data-dir "$data_dir/data" \ @@ -100,9 +93,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" @@ -189,7 +179,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 @@ -253,10 +243,12 @@ ynh_script_progression "Adding multimedia directories..." # Build YunoHost multimedia directories ynh_multimedia_build_main_dir + # Mount the user directory in Nextcloud exec_occ app:enable files_external create_external_storage "/home/yunohost.multimedia/\$user" "Multimedia" create_external_storage "/home/yunohost.multimedia/share" "Shared multimedia" + # Allow nextcloud to write into these directories ynh_multimedia_addaccess $app diff --git a/scripts/remove b/scripts/remove index c506c10c..5a5ed392 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,6 +9,7 @@ source /usr/share/yunohost/helpers ynh_script_progression "Removing system configurations related to $app..." ynh_config_remove_nginx + ynh_safe_rm "/etc/nginx/conf.d/$domain.d/$app.d" ynh_config_remove_phpfpm diff --git a/scripts/restore b/scripts/restore index 9be6e2b8..649374e3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,11 +11,11 @@ ynh_script_progression "Restoring the app main directory..." ynh_restore "$install_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 THE PHP-FPM CONFIGURATION @@ -146,10 +146,10 @@ ynh_systemctl --service=nginx --action=reload # CHECK IF NOTIFY_PUSH WORKS #================================================= -exec_occ() { - (cd "$install_dir" && ynh_exec_as_app \ - php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") -} +#exec_occ() { +# (cd "$install_dir" && ynh_exec_as_app \ +# php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") +#} if [ $enable_notify_push -eq 1 ] then diff --git a/scripts/upgrade b/scripts/upgrade index 12fe5a7b..f99bfefb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,6 +54,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 @@ -87,6 +93,35 @@ 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 we're moving through version 29.0.10~ynh1 (in which the switch to PostgreSQL is made) +if ynh_app_upgrading_from_version_before 29.0.10~ynh1 +then + # Double-check the MySQL database is here + if ! mysql -e "USE $db_name" 2>/dev/null + then + ynh_print_warn "Uhoh? The Nextcloud MySQL database doesn't exist? We are supposed to move it to PostgreSQL... Maybe it was already migrated?" + # Double check the psql is not empty, otherwise big whoops? + if [[ "$(ynh_psql_db_shell --database=$db_name --sql="\dt" 2>/dev/null | wc -l)" == 0 ]] + then + ynh_die "Apparently the PostgreSQL database is also empty, this is kind of worrying, what happened?!" + else + ynh_print_warn "Apparently the PostgreSQL database is not empty, so this is probably OK?" + fi + else + ynh_print_info "Migrating to PostgreSQL database..." + exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n + ynh_mysql_drop_db $db_name + 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,11 +157,7 @@ function list_installed_apps_not_compatible_with_future_version() comm -23 <(comm -23 $installed_apps $core_apps_in_current_version) $nextcloud_destination_appcatalog } -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%%.*} if [[ "$last_major_version" != "$current_major_version" ]] then @@ -147,15 +178,6 @@ then # 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 @@ -269,6 +291,11 @@ then # Then remove the config file ynh_safe_rm "$nc_conf" + # Occasionally new mimetypes are added to better handle certain file types. + # Migrating the mimetypes take a long time on larger instances + # so this is not done automatically during upgrades. + exec_occ maintenance:repair --include-expensive + #================================================= # ALLOW USERS TO DISCONNECT FROM NEXTCLOUD #================================================= @@ -374,7 +401,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 #================================================= @@ -424,7 +450,6 @@ ynh_config_add_logrotate # FAIL2BAN #================================================= -# Create a dedicated Fail2Ban config ynh_config_add_fail2ban --logpath="/var/log/$app/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: ''.*$" #=================================================