From 386ef01d05604cb0e73553f103eedd4619998089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 2 Jun 2023 13:48:11 +0200 Subject: [PATCH] v2 --- actions.toml | 17 --- check_process | 27 ----- conf/nextcloud.cron | 2 +- conf/nginx.conf | 6 +- doc/{DISCLAIMER.md => ADMIN.md} | 0 doc/{DISCLAIMER_fr.md => ADMIN_fr.md} | 0 manifest.json | 70 ----------- manifest.toml | 30 +++-- scripts/actions/add_multimedia_directories | 66 ----------- scripts/actions/disable_maintenance | 52 -------- scripts/backup | 39 ++---- scripts/change_url | 91 +------------- scripts/install | 102 +--------------- scripts/remove | 60 ---------- scripts/restore | 57 +-------- scripts/upgrade | 132 +++------------------ tests.toml | 16 +++ 17 files changed, 69 insertions(+), 698 deletions(-) delete mode 100644 actions.toml delete mode 100644 check_process rename doc/{DISCLAIMER.md => ADMIN.md} (100%) rename doc/{DISCLAIMER_fr.md => ADMIN_fr.md} (100%) delete mode 100644 manifest.json delete mode 100755 scripts/actions/add_multimedia_directories delete mode 100755 scripts/actions/disable_maintenance create mode 100644 tests.toml diff --git a/actions.toml b/actions.toml deleted file mode 100644 index fc6cb0f..0000000 --- a/actions.toml +++ /dev/null @@ -1,17 +0,0 @@ -[disable_maintenance] -name = "Disable the maintenance mode of Nextcloud" -command = "/bin/bash scripts/actions/disable_maintenance" -# user = "root" # optional -# cwd = "/" # optional -# accepted_return_codes = [0, 1, 2, 3] # optional -accepted_return_codes = [0] -description = "Disable the maintenance mode of Nextcloud if you're stuck after an upgrade" - -[add_multimedia_directories] -name = "Add multimedia directories" -command = "/bin/bash scripts/actions/add_multimedia_directories" -# user = "root" # optional -# cwd = "/" # optional -# accepted_return_codes = [0, 1, 2, 3] # optional -accepted_return_codes = [0] -description = "Add the multimedia and shared multimedia directories again" diff --git a/check_process b/check_process deleted file mode 100644 index 6922dcc..0000000 --- a/check_process +++ /dev/null @@ -1,27 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - admin="homer" - is_public=1 - user_home="1" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - #25.0.2 - upgrade=1 from_commit=c5cf91ad30149e1924c23b19e93f483c3ed3edd8 - backup_restore=1 - multi_instance=1 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=c5cf91ad30149e1924c23b19e93f483c3ed3edd8 - name=Merge pull request #495 from YunoHost-Apps/25.0.2 - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&user_home=1& diff --git a/conf/nextcloud.cron b/conf/nextcloud.cron index a2be7ed..31bfe2f 100644 --- a/conf/nextcloud.cron +++ b/conf/nextcloud.cron @@ -1 +1 @@ -*/5 * * * * __APP__ /usr/bin/php__PHPVERSION__ --define apc.enable_cli=1 -f __FINAL_PATH__/cron.php +*/5 * * * * __APP__ /usr/bin/php__PHPVERSION__ --define apc.enable_cli=1 -f __INSTALL_DIR__/cron.php diff --git a/conf/nginx.conf b/conf/nginx.conf index 7a5f24f..37c2389 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,8 +6,8 @@ location ^~ /.well-known { #rewrite ^/\.well-known/host-meta\.json __PATH__/public.php?service=host-meta-json last; #rewrite ^/\.well-known/host-meta __PATH__/public.php?service=host-meta last; - location = /.well-known/carddav { return 301 __PATH__/remote.php/dav/; } - location = /.well-known/caldav { return 301 __PATH__/remote.php/dav/; } + location = /.well-known/carddav { return 301 __PATH__/remote.php/dav/; } + location = /.well-known/caldav { return 301 __PATH__/remote.php/dav/; } location = /.well-known/webfinger { return 301 __PATH__/index.php$uri; } location = /.well-known/nodeinfo { return 301 __PATH__/index.php$uri; } @@ -114,7 +114,7 @@ location ^~ __PATH__/ { location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ { try_files $uri / __PATH__/index.php$request_uri; - expires 6M; # Cache-Control policy borrowed from `.htaccess` + expires 6M; # Cache-Control policy borrowed from `.htaccess` access_log off; # Optional: Don't log access to assets location ~ \.wasm$ { diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 8774f46..0000000 --- a/manifest.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "id": "nextcloud", - "name": "Nextcloud", - "packaging_format": 1, - "description": { - "en": "Online storage, file sharing platform and various other applications", - "fr": "Stockage en ligne, plateforme de partage de fichiers et diverses autres applications" - }, - "version": "26.0.2~ynh1", - "url": "https://nextcloud.com", - "upstream": { - "license": "AGPL-3.0", - "website": "https://nextcloud.com", - "demo": "https://demo.nextcloud.com/", - "admindoc": "https://docs.nextcloud.com/server/stable/admin_manual/", - "userdoc": "https://docs.nextcloud.com/server/latest/user_manual/en/", - "code": "https://github.com/nextcloud/server", - "cpe": "cpe:2.3:a:nextcloud:nextcloud" - }, - "license": "AGPL-3.0", - "maintainer": { - "name": "kay0u", - "email": "pierre@kayou.io" - }, - "requirements": { - "yunohost": ">= 11.1.15" - }, - "multi_instance": true, - "services": [ - "nginx", - "php8.1-fpm", - "mysql" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/nextcloud", - "default": "/nextcloud" - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "You need to enable public if you want to connect Nextcloud Desktop client to Nextcloud server. This can be changed later via the webadmin.", - "fr": "Vous devez cocher cette case si vous souhaitez connecter le client Nextcloud Desktop au serveur Nextcloud. Cela peut être modifié ultérieurement via l'administrateur Web." - }, - "default": true - }, - { - "name": "user_home", - "type": "boolean", - "ask": { - "en": "Access the users home folder from Nextcloud?", - "fr": "Accéder au dossier personnel des utilisateurs depuis Nextcloud ?" - }, - "default": false - } - ] - } -} \ No newline at end of file diff --git a/manifest.toml b/manifest.toml index 895e868..1e3b9d5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,31 +16,28 @@ demo = "https://demo.nextcloud.com/" admindoc = "https://docs.nextcloud.com/server/stable/admin_manual/" userdoc = "https://docs.nextcloud.com/server/latest/user_manual/en/" code = "https://github.com/nextcloud/server" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. +code = "https://github.com/nextcloud/server" +cpe = "cpe:2.3:a:nextcloud:nextcloud" [integration] -yunohost = ">= 11.1.15" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.1.19" +architectures = ["amd64", "arm64"] multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = true +sso = true +disk = "50M" +ram.build = "500M" +ram.runtime = "512M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" [install.path] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "path" default = "/nextcloud" [install.admin] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "user" [install.init_main_permission] @@ -61,9 +58,18 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.install_dir] [resources.data_dir] + subdirs = ["data"] [resources.permissions] main.url = "/" + api.url = "re:__DOMAIN__\\/.well-known\\/.*" + api.auth_header = false + api.show_tile = false + api.protected= true + api.allowed = ["visitors", "all_users"] + + [resources.apt] + packages = "mariadb-server, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, php8.1-fpm, php8.1-bz2, php8.1-imap, php8.1-gmp, php8.1-gd, php8.1-intl, php8.1-curl, php8.1-apcu, php8.1-redis, php8.1-ldap, php8.1-imagick, php8.1-zip, php8.1-mbstring, php8.1-xml, php8.1-mysql, php8.1-igbinary, php8.1-bcmath" [resources.database] type = "mysql" diff --git a/scripts/actions/add_multimedia_directories b/scripts/actions/add_multimedia_directories deleted file mode 100755 index 8b5a9af..0000000 --- a/scripts/actions/add_multimedia_directories +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source scripts/_common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF ARGUMENTS ARE CORRECT -#================================================= - -#================================================= -# DEFINE FUNCTION -#================================================= - -# Define a function to execute commands with `occ` -exec_occ() { - (cd "$final_path" && exec_as "$app" \ - php$YNH_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") -} - -# 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]+$ ]] \ - && ynh_print_warn --message="Unable to create external storage" \ - || exec_occ files_external:option "$mount_id" enable_sharing true -} - -#================================================= -# SPECIFIC ACTION -#================================================= -# YUNOHOST MULTIMEDIA INTEGRATION -#================================================= -ynh_script_progression --message="Updating multimedia directories..." --weight=6 - -# 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 - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/disable_maintenance b/scripts/actions/disable_maintenance deleted file mode 100755 index 60e8738..0000000 --- a/scripts/actions/disable_maintenance +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source scripts/_common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# CHECK IF ARGUMENTS ARE CORRECT -#================================================= - -#================================================= -# CHECK IF AN ACTION HAS TO BE DONE -#================================================= - -# Check the current status of the maintenance mode - -if [ "$(grep "maintenance" "$final_path/config/config.php" | awk '{print $3}' | cut -d',' -f1)" != "true" ] -then - ynh_die --message="Nextcloud isn't currently under maintenance." --ret_code=0 -fi - -#================================================= -# SPECIFIC ACTION -#================================================= -# DISABLE THE MAINTENANCE MODE -#================================================= - -ynh_script_progression --message="Disabling maintenance mode..." --weight=3 - -( -cd "$final_path" && exec_as "$app" \ - php$YNH_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi maintenance:mode --off -) - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Execution completed" --last diff --git a/scripts/backup b/scripts/backup index c33dfd2..924f0bd 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,26 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers source ../settings/scripts/_ynh_mysql_dump_db.sh -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -41,6 +21,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" +#================================================= +# BACKUP THE DATA DIRECTORY +#================================================= + +ynh_backup --src_path="$data_dir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -53,13 +39,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# BACKUP THE MYSQL DATABASE -#================================================= -ynh_print_info --message="Backing up the MySQL database..." - -ynh_mysql_dump_db --database="$db_name" --default_character_set="utf8mb4" > db.sql - #================================================= # SPECIFIC BACKUP #================================================= @@ -82,11 +61,11 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/cron.d/$app" #================================================= -# BACKUP THE DATA DIRECTORY +# BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up data directory..." +ynh_print_info --message="Backing up the MySQL database..." -ynh_backup --src_path="$data_dir" --is_big +ynh_mysql_dump_db --database="$db_name" --default_character_set="utf8mb4" > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index beb9e1d..59ac9d8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,60 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -72,30 +18,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # SPECIFIC MODIFICATIONS #================================================= @@ -124,20 +46,11 @@ then ynh_print_warn --message="Another app already uses the domain $new_domain to serve a caldav/carddav feature. You may encounter issues when dealing with your calendar or address book." # Remove lines about .well-known/carddav and caldav with sed. -#REMOVEME? sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$new_domain.d/$app.conf" -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi fi -#================================================= -# GENERIC FINALISATION -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index a884bfd..08b62c3 100755 --- a/scripts/install +++ b/scripts/install @@ -10,74 +10,17 @@ source _common.sh source /usr/share/yunohost/helpers source _ynh_mysql_connect_as.sh -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? admin=$YNH_APP_ARG_ADMIN -#REMOVEME? user_home=$YNH_APP_ARG_USER_HOME -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? phpversion=$YNH_PHP_VERSION - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - -# Check machine architecture (Nextcloud will soon deprecate 32-bit support) -if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armhf" ] -then - ynh_print_warn --message="Nextcloud will soon deprecate 32-bit support. It is recommended to upgrade to a 64-bit architecture." -fi - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=user_home --value=$user_home maintenance_mode=0 ynh_app_setting_set --app=$app --key=maintenance_mode --value=$maintenance_mode -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=10 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE A MYSQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2 - -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +ynh_script_progression --message="Creating a MySQL database..." --weight=2 ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" @@ -99,20 +42,11 @@ SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true EOF -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Enable YunoHost patches on Nextcloud sources cp -a ../sources/patches_last_version/* ../sources/patches # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -126,10 +60,8 @@ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION -# Used by ynh_add_nginx_config -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -155,12 +87,8 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -# Define app's data directory -#REMOVEME? data_dir="/home/yunohost.app/$app/data" -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - -# Create app folders -mkdir -p "$data_dir" +data_dir="$data_dir/data" +ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir #================================================= # INSTALL NEXTCLOUD @@ -350,7 +278,7 @@ chmod 750 $install_dir ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$data_dir/nextcloud.log" +ynh_use_logrotate --logfile="/home/yunohost.app/$app/data/nextcloud.log" #================================================= # SETUP FAIL2BAN @@ -360,26 +288,6 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=8 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/home/yunohost.app/$app/data/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: ''.*$" --max_retry=5 -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." - -# Make app public if necessary -#REMOVEME? if [ $is_public -eq 1 ] -then -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi - -#REMOVEME? ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 5c09222..0d0ff5b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,56 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=20 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# REMOVE THE MYSQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=5 - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=3 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 -#REMOVEME? ynh_secure_remove --file="$data_dir" -fi - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -111,16 +61,6 @@ for i in $(ls /home); do && setfacl --remove g:$app:rwx 2>&1 done -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 402f4ad..1e4b0c3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,39 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers source ../settings/scripts/_ynh_mysql_connect_as.sh -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - -#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=4 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -55,33 +22,13 @@ ynh_restore_file --origin_path="$install_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." --weight=9 +ynh_script_progression --message="Restoring the MySQL database..." --weight=9 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -#REMOVEME? ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_name --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name --default_character_set="utf8mb4" < ./db.sql -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=10 - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -130,8 +77,6 @@ ynh_script_progression --message="Restoring data directory..." --weight=2 # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p "$data_dir" - #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index bcf7a44..f894dbb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,159 +9,55 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=3 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? user_home=$(ynh_app_setting_get --app=$app --key=user_home) - -#REMOVEME? maintenance_mode=$(ynh_app_setting_get --app=$app --key=maintenance_mode) -#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) -# Check machine architecture (Nextcloud will soon deprecate 32-bit support) -if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armhf" ] -then - ynh_print_warn --message="Nextcloud will soon deprecate 32-bit support. It is recommended to upgrade to a 64-bit architecture." -fi - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If install_dir doesn't exist, create it -if [ -z "$install_dir" ]; then -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -fi - # If data_dir doesn't exist, create it -if [ -z "$data_dir" ]; then +if [ -z "${data_dir:-}" ]; then data_dir=/home/yunohost.app/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir + ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir fi # Remove the option backup_core_only if it's in the settings.yml file ynh_app_setting_delete --app=$app --key=backup_core_only # If maintenance_mode doesn't exist, create it -if [ -z "$maintenance_mode" ]; then +if [ -z "${maintenance_mode:-}" ]; then maintenance_mode=0 ynh_app_setting_set --app=$app --key=maintenance_mode --value=$maintenance_mode fi # If fpm_footprint doesn't exist, create it -if [ -z "$fpm_footprint" ]; then +if [ -z "${fpm_footprint:-}" ]; then fpm_footprint=high ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint fi # If fpm_free_footprint doesn't exist, create it -if [ -z "$fpm_free_footprint" ]; then +if [ -z "${fpm_free_footprint:-}" ]; then fpm_free_footprint=0 ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint fi # If fpm_usage doesn't exist, create it -if [ -z "$fpm_usage" ]; then +if [ -z "${fpm_usage:-}" ]; then fpm_usage=medium ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -# Create a permission if needed -#REMOVEME? if ! ynh_permission_exists --permission="api"; then -#REMOVEME? ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true" -fi - # Delete existing ini configuration file (backward compatibility) if [ -f /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini ]; then ynh_secure_remove --file=/etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 - -# 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 "$install_dir/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 - # Use only for the previous backup script that doesn't set 'is_big' - ynh_app_setting_set --app=$app --key=backup_core_only --value=1 - - # Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade - - # Remove the option backup_core_only after the backup. - ynh_app_setting_delete $app backup_core_only - -#REMOVEME? ynh_clean_setup () { - # restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup - } -fi - -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - -#REMOVEME? ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true" -fi - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=7 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -170,8 +66,6 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Recreate a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # NGINX CONFIGURATION #================================================= @@ -184,7 +78,7 @@ ynh_remove_nginx_config ynh_app_setting_delete --app=$app --key="checksum__etc_nginx_conf.d_$domain.d_$app.conf" # Wait untils NGINX has fully reloaded -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload --line_match="Reloaded" --log_path="systemd" +ynh_systemd_action --service_name=nginx --action=reload --line_match="Reloaded" --log_path="systemd" # Check if .well-known is available for this domain if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" @@ -205,6 +99,9 @@ ynh_add_nginx_config # VERSION TO THE NEXT ONE #================================================= +current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2) +current_major_version=${current_version%%.*} + # Define a function to execute commands with `occ` exec_occ() { # Backward compatibility to upgrade from older versions @@ -233,7 +130,7 @@ local mount_id=$(exec_occ files_external:create --output=json \ || exec_occ files_external:option "$mount_id" enable_sharing true } # Define app's data directory -#REMOVEME? data_dir="/home/yunohost.app/$app/data" +data_dir="/home/yunohost.app/$app/data" if [ "$upgrade_type" == "UPGRADE_APP" ] then @@ -252,7 +149,7 @@ then exec_occ -V if [ "$(exec_occ config:system:get mysql.utf8mb4)" != "true" ]; then -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) # Change your databases character set and collation ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" @@ -335,7 +232,7 @@ EOF ) # Replace the old nextcloud by the new one -#REMOVEME? ynh_secure_remove --file="$install_dir" + ynh_secure_remove --file="$install_dir" mv "$tmpdir" "$install_dir" ynh_secure_remove --file="$tmpdir" @@ -492,9 +389,8 @@ ynh_add_fail2ban_config --logpath="/home/yunohost.app/$app/data/nextcloud.log" - #================================================= # RELOAD NGINX #================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression --message="Reloading PHP-FPM..." -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..28376bc --- /dev/null +++ b/tests.toml @@ -0,0 +1,16 @@ +test_format = 1.0 + +[default] + + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.user_home="1" + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.c5cf91ad.name = "Upgrade from 25.0.2" \ No newline at end of file