From 75f9ad9a4cf586f547c1bbae539cad8f6ba05055 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Feb 2021 21:57:21 +0100 Subject: [PATCH 01/19] New permissions --- manifest.json | 4 ++-- pull_request_template.md | 4 +--- scripts/install | 12 +++++++----- scripts/upgrade | 24 ++++++++++++------------ scripts/ynh_composer__2 | 14 +++++++++++--- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/manifest.json b/manifest.json index 9ebfe3d..8dd9264 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "url": "https://framagit.org/framasoft/framaforms", "license": "GPL-2.0-only", "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.0.0" }, "maintainer": { "name": "ljf", @@ -20,7 +20,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { diff --git a/pull_request_template.md b/pull_request_template.md index 3679ea2..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/framaforms_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/framaforms_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/install b/scripts/install index ad6db06..193a858 100644 --- a/scripts/install +++ b/scripts/install @@ -271,17 +271,19 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 - -ynh_permission_create --permission "admin" --url /admin/ +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi +# Only the admin can access the admin panel of the app (if the app has an admin panel) +ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f48a280..9fb7aff 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,6 +58,18 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -180,18 +192,6 @@ mkdir -p "/home/yunohost.app/$app/data" chown -R $app: "/home/yunohost.app/$app/data" chmod 775 "/home/yunohost.app/$app/data" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/ynh_composer__2 b/scripts/ynh_composer__2 index 762b7f7..ca68a65 100644 --- a/scripts/ynh_composer__2 +++ b/scripts/ynh_composer__2 @@ -1,5 +1,10 @@ #!/bin/bash +readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 +# Declare the actual composer version to use. +# A packager willing to use another version of composer can override the variable into its _common.sh. +YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} + # Execute a command with Composer # # usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" @@ -25,26 +30,29 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] # | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include +# | arg: -c, --composerversion - Composer version to install ynh_install_composer () { # Declare an array to define the options of this helper. local legacy_args=vwa - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) local phpversion local workdir local install_args + local composerversion # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" phpversion="${phpversion:-$YNH_PHP_VERSION}" install_args="${install_args:-}" + composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" \ + php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ || ynh_die "Unable to install Composer." # update dependencies to create composer.lock From 8441bf2ef5cef27db1b38b200c3ea5eeb6300f0d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Feb 2021 22:06:57 +0100 Subject: [PATCH 02/19] add admin --- scripts/install | 2 +- scripts/upgrade | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 193a858..1e9851c 100644 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC password=$YNH_APP_ARG_PASSWORD -admin=admin +admin=$YNH_APP_ARG_ADMIN language=$YNH_APP_ARG_LANGUAGE expiration=$YNH_APP_ARG_EXPIRATION deletion=$YNH_APP_ARG_DELETION diff --git a/scripts/upgrade b/scripts/upgrade index 9fb7aff..4755b64 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +admin=$(ynh_app_setting_get --app=$app --key=admin) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) From cb2c3c8e93c16ab19d765357124534b292818136 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Feb 2021 22:35:25 +0100 Subject: [PATCH 03/19] Small typos --- README.md | 4 ++-- issue_template.md | 2 +- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d3b355c..0abd787 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ You can modify some configurations using the Framaforms administration panel. Yo #### Multi-user support -Are LDAP and HTTP auth supported? **Only LDAP** -Can the app be used by multiple users? **Yes** + * Are LDAP and HTTP auth supported? **Only LDAP** + * Can the app be used by multiple users? **Yes** #### Supported architectures diff --git a/issue_template.md b/issue_template.md index 2a9be2a..68c7586 100644 --- a/issue_template.md +++ b/issue_template.md @@ -8,7 +8,7 @@ about: Create a report to help us debug, it would be nice to fill the template a 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - - *Otherwise, the issue may be due to framaforms itself. Refer to its documentation or repository for help.* + - *Otherwise, the issue may be due to Framaforms itself. Refer to its documentation or repository for help.* - *If you have a doubt, post here, we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- diff --git a/manifest.json b/manifest.json index 8dd9264..1106c03 100644 --- a/manifest.json +++ b/manifest.json @@ -69,7 +69,7 @@ "en": "Choose the application language", "fr": "Choisissez la langue de l'application" }, - "choices": ["fr", "en"], + "choices": ["de", "en", "es", "fr", "it", "pt"], "default": "en" }, { From 84a2f569479c82f4e979138d8521968d908c6164 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Feb 2021 22:42:43 +0100 Subject: [PATCH 04/19] Remove ynh_exec_as --- scripts/install | 10 +++++----- scripts/upgrade | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/install b/scripts/install index 1e9851c..e671d81 100644 --- a/scripts/install +++ b/scripts/install @@ -188,11 +188,11 @@ ynh_script_progression --message="Installing database..." --weight=19 chown -R $app: $final_path update-alternatives --set php /usr/bin/php$phpversion -ynh_exec_as $app env PATH=$PATH drush @$app site-install framaforms_org install_configure_form.site_contact_url="https://forum.yunohost.org/t/framaforms-create-polls-using-drag-and-drop/8208" install_configure_form.site_default_country=FR -y --locale="$language" --account-name="admin" --account-pass="$password" --site-name="Framaforms" --site-mail="$admin_mail" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app variable-set update_notify_emails "$admin_mail" -ynh_exec_as $app env PATH=$PATH drush @$app variable-set file_private_path "/home/yunohost.app/$app/data" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app pm-enable framaforms_feature -y --resolve-dependencies 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app php-eval "module_load_include('inc', 'framaforms', 'includes/framaforms.pages');create_all_pages();" 2>&1 || true +sudo -u $app env PATH=$PATH drush @$app site-install framaforms_org install_configure_form.site_contact_url="https://forum.yunohost.org/t/framaforms-create-polls-using-drag-and-drop/8208" install_configure_form.site_default_country=FR -y --locale="$language" --account-name="admin" --account-pass="$password" --site-name="Framaforms" --site-mail="$admin_mail" 2>&1 +sudo -u $app env PATH=$PATH drush @$app variable-set update_notify_emails "$admin_mail" +sudo -u $app env PATH=$PATH drush @$app variable-set file_private_path "/home/yunohost.app/$app/data" 2>&1 +sudo -u $app env PATH=$PATH drush @$app pm-enable framaforms_feature -y --resolve-dependencies 2>&1 +sudo -u $app env PATH=$PATH drush @$app php-eval "module_load_include('inc', 'framaforms', 'includes/framaforms.pages');create_all_pages();" 2>&1 || true #================================================= # IMPORTING LANGUAGE PACK diff --git a/scripts/upgrade b/scripts/upgrade index 4755b64..619b6b9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,12 +156,12 @@ then update-alternatives --set php /usr/bin/php$phpversion pushd "$final_path" - ynh_exec_as $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1 - ynh_exec_as $app env PATH=$PATH drush @$app cache-clear all - # ynh_exec_as $app env PATH=$PATH drush @$app pm-update -y drupal - # ynh_exec_as $app env PATH=$PATH drush @$app updatedb -y - ynh_exec_as $app env PATH=$PATH drush @$app cache-clear all - ynh_exec_as $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 + sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1 + sudo -u $app $app env PATH=$PATH drush @$app cache-clear all + # sudo -u $app env PATH=$PATH drush @$app pm-update -y drupal + # sudo -u $app env PATH=$PATH drush @$app updatedb -y + sudo -u $app $app env PATH=$PATH drush @$app cache-clear all + sudo -u $app $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 popd update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} From 3d649994d63eda88888b573fdf5bfad3b16d1034 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Feb 2021 22:45:53 +0100 Subject: [PATCH 05/19] Cleaning up --- manifest.json | 2 +- scripts/_common.sh | 63 +++++++++++++++++++++++++++++++++++++++++ scripts/install | 2 -- scripts/restore | 2 -- scripts/upgrade | 2 -- scripts/ynh_composer__2 | 61 --------------------------------------- scripts/ynh_exec_as | 14 --------- 7 files changed, 64 insertions(+), 82 deletions(-) delete mode 100644 scripts/ynh_composer__2 delete mode 100644 scripts/ynh_exec_as diff --git a/manifest.json b/manifest.json index 1106c03..7f7e32d 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Create online webforms and surveys", "fr": "Créez des formulaires et questionnaires en ligne" }, - "version": "1.0.3~ynh1", + "version": "1.0.3~ynh2", "url": "https://framagit.org/framasoft/framaforms", "license": "GPL-2.0-only", "requirements": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 94ca18f..deb9fc1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,3 +22,66 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-cli php$ #================================================= # FUTURE OFFICIAL HELPERS #================================================= + + +#!/bin/bash + +readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 +# Declare the actual composer version to use. +# A packager willing to use another version of composer can override the variable into its _common.sh. +YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} + +# Execute a command with Composer +# +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | arg: -v, --phpversion - PHP version to use with composer +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -c, --commands - Commands to execute. +ynh_composer_exec () { + # Declare an array to define the options of this helper. + local legacy_args=vwc + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) + local phpversion + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + + COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} "$workdir/composer.phar" $commands \ + -d "$workdir" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] +# | arg: -v, --phpversion - PHP version to use with composer +# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include +# | arg: -c, --composerversion - Composer version to install +ynh_install_composer () { + # Declare an array to define the options of this helper. + local legacy_args=vwa + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) + local phpversion + local workdir + local install_args + local composerversion + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + install_args="${install_args:-}" + composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" + + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ + || ynh_die "Unable to install Composer." + + # update dependencies to create composer.lock + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ + || ynh_die "Unable to update core dependencies with Composer." +} diff --git a/scripts/install b/scripts/install index e671d81..76605ab 100644 --- a/scripts/install +++ b/scripts/install @@ -7,8 +7,6 @@ #================================================= source _common.sh -source ynh_composer__2 -source ynh_exec_as source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/restore b/scripts/restore index 172770e..a07bd39 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,8 +8,6 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_composer__2 -source ../settings/scripts/ynh_exec_as source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 619b6b9..38d1860 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,8 +7,6 @@ #================================================= source _common.sh -source ynh_composer__2 -source ynh_exec_as source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/ynh_composer__2 b/scripts/ynh_composer__2 deleted file mode 100644 index ca68a65..0000000 --- a/scripts/ynh_composer__2 +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 -# Declare the actual composer version to use. -# A packager willing to use another version of composer can override the variable into its _common.sh. -YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} - -# Execute a command with Composer -# -# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -c, --commands - Commands to execute. -ynh_composer_exec () { - # Declare an array to define the options of this helper. - local legacy_args=vwc - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) - local phpversion - local workdir - local commands - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - - COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} "$workdir/composer.phar" $commands \ - -d "$workdir" --quiet --no-interaction -} - -# Install and initialize Composer in the given directory -# -# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include -# | arg: -c, --composerversion - Composer version to install -ynh_install_composer () { - # Declare an array to define the options of this helper. - local legacy_args=vwa - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) - local phpversion - local workdir - local install_args - local composerversion - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - install_args="${install_args:-}" - composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" - - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ - || ynh_die "Unable to install Composer." - - # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ - || ynh_die "Unable to update core dependencies with Composer." -} diff --git a/scripts/ynh_exec_as b/scripts/ynh_exec_as deleted file mode 100644 index 2e849dc..0000000 --- a/scripts/ynh_exec_as +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -ynh_exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} From 0eb040cba03eb41d4054f5bdc8c90d36f2297669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 3 Feb 2021 23:25:18 +0100 Subject: [PATCH 06/19] Update scripts/upgrade Co-authored-by: Alexandre Aubin --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 38d1860..4af4b9b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -155,11 +155,11 @@ then pushd "$final_path" sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1 - sudo -u $app $app env PATH=$PATH drush @$app cache-clear all + sudo -u $app env PATH=$PATH drush @$app cache-clear all # sudo -u $app env PATH=$PATH drush @$app pm-update -y drupal # sudo -u $app env PATH=$PATH drush @$app updatedb -y - sudo -u $app $app env PATH=$PATH drush @$app cache-clear all - sudo -u $app $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 + sudo -u $app env PATH=$PATH drush @$app cache-clear all + sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 popd update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} From 1d91e9370a893fc46d4d799b004694a845cfa40a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 23 Mar 2021 20:51:39 +0100 Subject: [PATCH 07/19] protect config file --- README.md | 2 +- check_process | 1 - manifest.json | 22 +--------------------- scripts/install | 20 +++++++++----------- scripts/restore | 1 + scripts/upgrade | 27 +++++++++------------------ 6 files changed, 21 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 0abd787..fea324a 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can modify some configurations using the Framaforms administration panel. Yo ## Documentation * Official documentation: https://docs.framasoft.org/fr/framaforms/ - * YunoHost documentation: https://yunohost.org/#/app_framaforms + * YunoHost documentation: https://yunohost.org/en/app_framaforms ## YunoHost specific features diff --git a/check_process b/check_process index 91243cc..9df3169 100644 --- a/check_process +++ b/check_process @@ -22,7 +22,6 @@ upgrade=1 from_commit=25e97123f0e82ec1b9375774f3e86b7d8f5d73cf backup_restore=1 multi_instance=1 - port_already_use=0 change_url=1 ;;; Options Email=ljf+framaforms_ynh@reflexlibre.net diff --git a/manifest.json b/manifest.json index 7f7e32d..ffe8d39 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "url": "https://framagit.org/framasoft/framaforms", "license": "GPL-2.0-only", "requirements": { - "yunohost": ">= 4.0.0" + "yunohost": ">= 4.1.7" }, "maintainer": { "name": "ljf", @@ -28,38 +28,22 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for Framaforms", - "fr": "Choisissez un nom de domaine pour Framaforms" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Framaforms", - "fr": "Choisissez un chemin pour Framaforms" - }, "example": "/poll", "default": "/poll" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l’administrateur" - }, "example": "johndoe" }, { "name": "password", "type": "password", - "ask": { - "en": "Set the administrator password", - "fr": "Définissez le mot de passe administrateur" - }, "example": "Choose a password" }, { @@ -101,10 +85,6 @@ { "name": "is_public", "type": "boolean", - "ask": { - "en": "Are visitors who do not have a YunoHost account on this server allowed to register and create forms?", - "fr": "Les visiteurs qui n'ont pas de compte YunoHost sur ce serveur sont-ils autorisés à s'inscrire et à créer des formulaires ?" - }, "help": { "en": "If no, only person with an account on your server will be able to create forms. In all cases, visitors will be able to reply to form.", "fr": "Si non, seule la personne disposant d'un compte sur votre serveur pourra créer des formulaires. Dans tous les cas, les visiteurs pourront répondre au formulaire." diff --git a/scripts/install b/scripts/install index 76605ab..a989a98 100644 --- a/scripts/install +++ b/scripts/install @@ -52,7 +52,6 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=password --value=$password -ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=expiration --value=$expiration ynh_app_setting_set --app=$app --key=deletion --value=$deletion @@ -78,6 +77,14 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -95,14 +102,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -265,6 +264,7 @@ ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files chown -R $app: $final_path +chmod 600 $config_file #================================================= # SETUP SSOWAT @@ -274,8 +274,6 @@ ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/restore b/scripts/restore index a07bd39..023609f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -78,6 +78,7 @@ chmod 2775 "$final_path/app/sites/default/files" mkdir -p "/home/yunohost.app/$app/data" chown -R $app: "/home/yunohost.app/$app/data" chmod 775 "/home/yunohost.app/$app/data" +chmod 600 "$final_path/app/sites/default/settings.php" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 4af4b9b..dac08ac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) admin=$(ynh_app_setting_get --app=$app --key=admin) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -36,15 +35,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -83,6 +73,14 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -112,14 +110,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -190,6 +180,7 @@ chown -R $app: $final_path mkdir -p "/home/yunohost.app/$app/data" chown -R $app: "/home/yunohost.app/$app/data" chmod 775 "/home/yunohost.app/$app/data" +chmod 600 $config_file #================================================= # RELOAD NGINX From 9e443b8f56e2dafa179fce8a7b017a59109a973a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 24 Mar 2021 12:47:13 +0100 Subject: [PATCH 08/19] Fix --- conf/yoursite.aliases.drushrc.php | 2 +- scripts/install | 46 ++++++++++++++++--------------- scripts/restore | 1 + scripts/upgrade | 4 +-- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/conf/yoursite.aliases.drushrc.php b/conf/yoursite.aliases.drushrc.php index 4035f0f..2c91f35 100644 --- a/conf/yoursite.aliases.drushrc.php +++ b/conf/yoursite.aliases.drushrc.php @@ -29,7 +29,7 @@ */ $aliases['__APP__'] = array( 'root' => '__FINALPATH__/app/', - 'uri' => 'https://__DOMAIN____PATH_URL__', + 'uri' => 'https://__DOMAIN____PATH__', 'path-aliases' => array( '%dump-dir' => '/tmp', ), diff --git a/scripts/install b/scripts/install index a989a98..a425bd5 100644 --- a/scripts/install +++ b/scripts/install @@ -120,12 +120,14 @@ ynh_script_progression --message="Creating Drush alias..." --weight=2 mkdir -p "$final_path/.drush" drush_aliasconfig="$final_path/.drush/$app.aliases.drushrc.php" -cp -f "../conf/yoursite.aliases.drushrc.php" "$drush_aliasconfig" +# cp -f "../conf/yoursite.aliases.drushrc.php" "$drush_aliasconfig" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$drush_aliasconfig" +# ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig" +# ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig" +# ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$drush_aliasconfig" +# ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$drush_aliasconfig" + +ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$drush_aliasconfig" #================================================= # INSTALL COMPOSER @@ -171,11 +173,13 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 config_file=$final_path/app/sites/default/settings.php -cp ../conf/default.settings.php "$config_file" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config_file" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$config_file" +# cp ../conf/default.settings.php "$config_file" +# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" +# ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config_file" +# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file" +# ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$config_file" + +ynh_add_config --template="../conf/default.settings.php" --destination="$config_file" #================================================= # INSTALLING FRAMAFORMS WITH DRUSH @@ -196,14 +200,14 @@ sudo -u $app env PATH=$PATH drush @$app php-eval "module_load_include('inc', 'fr #================================================= ynh_script_progression --message="Importing language pack..." --weight=5 -sudo -u $app env PATH=$PATH drush @$app pm-download -y drush_language -sudo -u $app env PATH=$PATH drush @$app pm-download -y l10n_update -sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update -sudo -u $app env PATH=$PATH drush @$app language-add $language -y -sudo -u $app env PATH=$PATH drush @$app language-default $language -y -sudo -u $app env PATH=$PATH drush @$app cache-clear drush -y -sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -y -sudo -u $app env PATH=$PATH drush @$app l10n-update -y +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download -y drush_language +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download -y l10n_update +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-add $language -y +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-default $language -y +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear drush -y +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -y +ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update -y # We don't upgrade module to avoid to erase framaforms change # in drupal core and modules code @@ -250,10 +254,7 @@ ynh_store_file_checksum --file="$config_file" #================================================= ynh_script_progression --message="Setuping the cron file..." -cp ../conf/cron /etc/cron.d/$app - -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION @@ -264,6 +265,7 @@ ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files chown -R $app: $final_path +chmod o-rwx $final_path chmod 600 $config_file #================================================= diff --git a/scripts/restore b/scripts/restore index 023609f..811eba9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -73,6 +73,7 @@ ynh_script_progression --message="Restoring user rights..." --weight=1 # Restore permissions on app files chown -R root: $final_path +chmod o-rwx $final_path chmod 2775 "$final_path/app/sites/default/files" mkdir -p "/home/yunohost.app/$app/data" diff --git a/scripts/upgrade b/scripts/upgrade index dac08ac..5abce2f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,7 +98,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -176,7 +176,7 @@ ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions on app files chown -R $app: $final_path - +chmod o-rwx $final_path mkdir -p "/home/yunohost.app/$app/data" chown -R $app: "/home/yunohost.app/$app/data" chmod 775 "/home/yunohost.app/$app/data" From c4d18061fef420d2e7e935f16d7c9092f515ed41 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 24 Mar 2021 12:49:03 +0100 Subject: [PATCH 09/19] Update install --- scripts/install | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index a425bd5..95ca677 100644 --- a/scripts/install +++ b/scripts/install @@ -200,14 +200,14 @@ sudo -u $app env PATH=$PATH drush @$app php-eval "module_load_include('inc', 'fr #================================================= ynh_script_progression --message="Importing language pack..." --weight=5 -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download -y drush_language -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download -y l10n_update -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-add $language -y -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-default $language -y -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear drush -y -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -y -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update -y +sudo -u $app env PATH=$PATH drush @$app pm-download -y drush_language 2>&1 +sudo -u $app env PATH=$PATH drush @$app pm-download -y l10n_update 2>&1 +sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update 2>&1 +sudo -u $app env PATH=$PATH drush @$app language-add $language -y 2>&1 +sudo -u $app env PATH=$PATH drush @$app language-default $language -y 2>&1 +sudo -u $app env PATH=$PATH drush @$app cache-clear drush -y 2>&1 +sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -y 2>&1 +sudo -u $app env PATH=$PATH drush @$app l10n-update -y 2>&1 # We don't upgrade module to avoid to erase framaforms change # in drupal core and modules code From 29909e0a10543a74de230873ce874e0e288a53ce Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 17 Apr 2021 16:36:16 +0200 Subject: [PATCH 10/19] Update install --- scripts/install | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/install b/scripts/install index 95ca677..a3fe49e 100644 --- a/scripts/install +++ b/scripts/install @@ -120,12 +120,6 @@ ynh_script_progression --message="Creating Drush alias..." --weight=2 mkdir -p "$final_path/.drush" drush_aliasconfig="$final_path/.drush/$app.aliases.drushrc.php" -# cp -f "../conf/yoursite.aliases.drushrc.php" "$drush_aliasconfig" - -# ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig" -# ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig" -# ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$drush_aliasconfig" -# ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$drush_aliasconfig" ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$drush_aliasconfig" @@ -173,12 +167,6 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 config_file=$final_path/app/sites/default/settings.php -# cp ../conf/default.settings.php "$config_file" -# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" -# ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config_file" -# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file" -# ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$config_file" - ynh_add_config --template="../conf/default.settings.php" --destination="$config_file" #================================================= From 3f3e4af6e93a8577b7c77e0979027535d0ae0956 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Thu, 13 May 2021 17:46:50 +0200 Subject: [PATCH 11/19] [autopatch] Update issue and PR templates --- .../ISSUE_TEMPLATE.md | 31 ++++++++++++------- .github/PULL_REQUEST_TEMPLATE.md | 16 ++++++++++ pull_request_template.md | 16 ---------- 3 files changed, 36 insertions(+), 27 deletions(-) rename issue_template.md => .github/ISSUE_TEMPLATE.md (57%) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 pull_request_template.md diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 57% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index 68c7586..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ --- name: Bug report -about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. --- @@ -8,15 +8,17 @@ about: Create a report to help us debug, it would be nice to fill the template a 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - - *Otherwise, the issue may be due to Framaforms itself. Refer to its documentation or repository for help.* - - *If you have a doubt, post here, we will figure it out together.* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- -**Describe the bug** +### Describe the bug + *A clear and concise description of what the bug is.* -**Versions** +### Context + - Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* - YunoHost version: x.x.x - I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* @@ -25,11 +27,11 @@ about: Create a report to help us debug, it would be nice to fill the template a - Using, or trying to install package version/branch: - If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* -**To Reproduce** -*Steps to reproduce the behavior.* +### Steps to reproduce + - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install framaforms + sudo yunohost app install the_app ``` - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* @@ -38,9 +40,16 @@ about: Create a report to help us debug, it would be nice to fill the template a 3. *Scroll down to '...'* 4. *See error* -**Expected behavior** +### Expected behavior + *A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* -**Logs** -*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + *If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 6c28fc5..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how do you fix that problem* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* From 8a85fbfc924b67badbec1973ccb1a1ff81227948 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 4 Jun 2021 16:16:35 +0200 Subject: [PATCH 12/19] Fix --- check_process | 10 +++---- conf/app.src | 2 +- manifest.json | 2 +- scripts/_common.sh | 65 ++-------------------------------------------- 4 files changed, 8 insertions(+), 71 deletions(-) diff --git a/check_process b/check_process index 9df3169..71fd1e2 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,10 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" language="fr" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 password="password" expiration="0" deletion="0" diff --git a/conf/app.src b/conf/app.src index a48f4e4..8da0a3b 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ SOURCE_URL=https://framagit.org/framasoft/framaforms/-/archive/1.0.3/framaforms-1.0.3.tar.gz -SOURCE_SUM=325f6735960864500d8c636cd67547666bc3aa07608b8a3c87e2e2a03ddb18cd +SOURCE_SUM=a7b004dac19d761212d49a0e407f5d31c97e49ccefca6443067a9d5da68bf64d SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index ffe8d39..2466051 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "url": "https://framagit.org/framasoft/framaforms", "license": "GPL-2.0-only", "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "maintainer": { "name": "ljf", diff --git a/scripts/_common.sh b/scripts/_common.sh index deb9fc1..267d18c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,8 @@ YNH_PHP_VERSION="7.3" extra_php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pgsql" +YNH_COMPOSER_VERSION="1.10.17" + #================================================= # PERSONAL HELPERS #================================================= @@ -22,66 +24,3 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-cli php$ #================================================= # FUTURE OFFICIAL HELPERS #================================================= - - -#!/bin/bash - -readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 -# Declare the actual composer version to use. -# A packager willing to use another version of composer can override the variable into its _common.sh. -YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} - -# Execute a command with Composer -# -# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -c, --commands - Commands to execute. -ynh_composer_exec () { - # Declare an array to define the options of this helper. - local legacy_args=vwc - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) - local phpversion - local workdir - local commands - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - - COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} "$workdir/composer.phar" $commands \ - -d "$workdir" --quiet --no-interaction -} - -# Install and initialize Composer in the given directory -# -# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] -# | arg: -v, --phpversion - PHP version to use with composer -# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. -# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include -# | arg: -c, --composerversion - Composer version to install -ynh_install_composer () { - # Declare an array to define the options of this helper. - local legacy_args=vwa - declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) - local phpversion - local workdir - local install_args - local composerversion - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - workdir="${workdir:-$final_path}" - phpversion="${phpversion:-$YNH_PHP_VERSION}" - install_args="${install_args:-}" - composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" - - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ - || ynh_die "Unable to install Composer." - - # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ - || ynh_die "Unable to update core dependencies with Composer." -} From 3c54df74b25661399aa6fc5ea7fb102173154872 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 15 May 2021 19:19:38 +0200 Subject: [PATCH 13/19] Apply example_ynh --- manifest.json | 188 ++++++++++++++++++++++----------------------- scripts/backup | 9 ++- scripts/change_url | 25 +++--- scripts/install | 79 ++++++++++--------- scripts/remove | 20 ++--- scripts/restore | 54 +++++++------ scripts/upgrade | 84 ++++++++++---------- 7 files changed, 234 insertions(+), 225 deletions(-) diff --git a/manifest.json b/manifest.json index 2466051..fdfaeed 100644 --- a/manifest.json +++ b/manifest.json @@ -1,96 +1,96 @@ { - "name": "Framaforms", - "id": "framaforms", - "packaging_format": 1, - "description": { - "en": "Create online webforms and surveys", - "fr": "Créez des formulaires et questionnaires en ligne" - }, - "version": "1.0.3~ynh2", - "url": "https://framagit.org/framasoft/framaforms", - "license": "GPL-2.0-only", - "requirements": { - "yunohost": ">= 4.2.4" - }, - "maintainer": { - "name": "ljf", - "email": "ljf+framaforms_ynh@reflexlibre.net", - "url": "https://reflexlibre.net" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.3-fpm", - "mysql" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain", - "example": "domain.org" - }, - { - "name": "path", - "type": "path", - "example": "/poll", - "default": "/poll" - }, - { - "name": "admin", - "type": "user", - "example": "johndoe" - }, - { - "name": "password", - "type": "password", - "example": "Choose a password" - }, - { - "name": "language", - "type": "string", - "ask": { - "en": "Choose the application language", - "fr": "Choisissez la langue de l'application" - }, - "choices": ["de", "en", "es", "fr", "it", "pt"], - "default": "en" - }, - { - "name": "expiration", - "type": "string", - "ask": { - "en": "After how many weeks do the forms expire?", - "fr": "Après combien de semaines les formulaires expirent-ils ?" - }, - "help": { - "en": "Set 0 to disable expiration", - "fr": "Mettre 0 pour désactiver l'expiration" - }, - "default": "0" - }, - { - "name": "deletion", - "type": "string", - "ask": { - "en": "After how many weeks is the forms deleted?", - "fr": "Après combien de semaines les formulaires sont-ils supprimés ?" - }, - "help": { - "en": "Set 0 to disable deletion", - "fr": "Mettre 0 pour désactiver la suppression" - }, - "default": "0" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If no, only person with an account on your server will be able to create forms. In all cases, visitors will be able to reply to form.", - "fr": "Si non, seule la personne disposant d'un compte sur votre serveur pourra créer des formulaires. Dans tous les cas, les visiteurs pourront répondre au formulaire." - }, - "default": true - } - ] - } + "name": "Framaforms", + "id": "framaforms", + "packaging_format": 1, + "description": { + "en": "Create online webforms and surveys", + "fr": "Créez des formulaires et questionnaires en ligne" + }, + "version": "1.0.3~ynh2", + "url": "https://framagit.org/framasoft/framaforms", + "license": "GPL-2.0-only", + "requirements": { + "yunohost": ">= 4.1.7" + }, + "maintainer": { + "name": "ljf", + "email": "ljf+framaforms_ynh@reflexlibre.net", + "url": "https://reflexlibre.net" + }, + "multi_instance": true, + "services": [ + "nginx", + "php7.3-fpm", + "mysql" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "example": "/poll", + "default": "/poll" + }, + { + "name": "admin", + "type": "user", + "example": "johndoe" + }, + { + "name": "password", + "type": "password", + "example": "Choose a password" + }, + { + "name": "language", + "type": "string", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["de", "en", "es", "fr", "it", "pt"], + "default": "en" + }, + { + "name": "expiration", + "type": "string", + "ask": { + "en": "After how many weeks do the forms expire?", + "fr": "Après combien de semaines les formulaires expirent-ils ?" + }, + "help": { + "en": "Set 0 to disable expiration", + "fr": "Mettre 0 pour désactiver l'expiration" + }, + "default": "0" + }, + { + "name": "deletion", + "type": "string", + "ask": { + "en": "After how many weeks is the forms deleted?", + "fr": "Après combien de semaines les formulaires sont-ils supprimés ?" + }, + "help": { + "en": "Set 0 to disable deletion", + "fr": "Mettre 0 pour désactiver la suppression" + }, + "default": "0" + }, + { + "name": "is_public", + "type": "boolean", + "help": { + "en": "If no, only person with an account on your server will be able to create forms. In all cases, visitors will be able to reply to form.", + "fr": "Si non, seule la personne disposant d'un compte sur votre serveur pourra créer des formulaires. Dans tous les cas, les visiteurs pourront répondre au formulaire." + }, + "default": true + } + ] + } } diff --git a/scripts/backup b/scripts/backup index 96a1261..7c8e69b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -28,6 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,7 +41,11 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" -ynh_backup --src_path="/home/yunohost.app/$app/data" --is_big=1 +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index d1d91c8..9ddd691 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,9 +32,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before changing its URL (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -42,7 +42,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -73,19 +73,19 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# 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 + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -102,13 +102,10 @@ fi #================================================= ynh_script_progression --message="Updating Drush alias..." --weight=1 -drush_aliasconfig="$final_path/.drush/$app.aliases.drushrc.php" -cp -f "../conf/yoursite.aliases.drushrc.php" "$drush_aliasconfig" +domain="$new_domain" +path_url="$new_path" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$new_domain" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$new_path" --target_file="$drush_aliasconfig" +ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$final_path/.drush/$app.aliases.drushrc.php" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index a3fe49e..81837ff 100644 --- a/scripts/install +++ b/scripts/install @@ -22,13 +22,13 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC -password=$YNH_APP_ARG_PASSWORD admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE +password=$YNH_APP_ARG_PASSWORD expiration=$YNH_APP_ARG_EXPIRATION deletion=$YNH_APP_ARG_DELETION -admin_mail="root@$domain" +admin_mail=$(ynh_user_get_info --username=$admin --key=mail) app=$YNH_APP_INSTANCE_NAME @@ -65,6 +65,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=7 ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -77,14 +85,6 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_psql_setup_db --db_user=$db_user --db_name=$db_name -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -94,6 +94,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/app" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -130,7 +134,7 @@ ynh_script_progression --message="Installing Composer..." --weight=31 mkdir -p "$final_path/.composer" -cp -f "../conf/composer.json" "$final_path/.composer/composer.json" +ynh_add_config --template="../conf/composer.json" --destination="$final_path/.composer/composer.json" ynh_install_composer --phpversion="$phpversion" --workdir="$final_path/.composer" @@ -141,13 +145,26 @@ export PATH="$final_path/.composer/vendor/bin:$PATH" #================================================= ynh_script_progression --message="Initializing tmp and private directory..." --weight=1 +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + mkdir -p "$final_path/app/sites/default/files" chmod 2775 "$final_path/app/sites/default/files" mkdir -p "$final_path/app/sites/default/files/tmp" -mkdir -p "/home/yunohost.app/$app/data" -chown -R $app: "/home/yunohost.app/$app/data" -chmod 775 "/home/yunohost.app/$app/data" +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." --time --weight=1 + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # ADD MISSING IMAGES @@ -161,21 +178,20 @@ chmod 775 "/home/yunohost.app/$app/data" #cp ../sources/partager.png "$final_path/sites/default/files/imgforms/" #================================================= -# MODIFY CONFIG FILES +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 -config_file=$final_path/app/sites/default/settings.php +ynh_add_config --template="../conf/default.settings.php" --destination="$final_path/app/sites/default/settings.php" -ynh_add_config --template="../conf/default.settings.php" --destination="$config_file" +chmod 600 "$final_path/app/sites/default/settings.php" +chown $app:$app "$final_path/app/sites/default/settings.php" #================================================= # INSTALLING FRAMAFORMS WITH DRUSH #================================================= ynh_script_progression --message="Installing database..." --weight=19 -chown -R $app: $final_path - update-alternatives --set php /usr/bin/php$phpversion sudo -u $app env PATH=$PATH drush @$app site-install framaforms_org install_configure_form.site_contact_url="https://forum.yunohost.org/t/framaforms-create-polls-using-drag-and-drop/8208" install_configure_form.site_default_country=FR -y --locale="$language" --account-name="admin" --account-pass="$password" --site-name="Framaforms" --site-mail="$admin_mail" 2>&1 sudo -u $app env PATH=$PATH drush @$app variable-set update_notify_emails "$admin_mail" @@ -213,7 +229,6 @@ sudo -u $app env PATH=$PATH drush @$app vset framaforms_deletion_period_value $d # Remove framaforms footer sudo -u $app env PATH=$PATH drush @$app sql-query "UPDATE block SET region='-1', status=0 WHERE delta='framaforms_footer' AND region='footer'" - #================================================= # CONFIGURING LDAP #================================================= @@ -229,14 +244,6 @@ cat ../conf/ldap.conf | sudo -u $app env PATH=$PATH drush @$app variable-set --f update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." --weight=1 - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config_file" - #================================================= # SETUP THE CRON FILE #================================================= @@ -246,16 +253,6 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 - -# Set permissions to app files -chown -R $app: $final_path -chmod o-rwx $final_path -chmod 600 $config_file - #================================================= # SETUP SSOWAT #================================================= @@ -264,6 +261,8 @@ ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/remove b/scripts/remove index 1c72a9e..8295c34 100644 --- a/scripts/remove +++ b/scripts/remove @@ -47,20 +47,12 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" -#================================================= -# REMOVE APP DATA DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="/home/yunohost.app/$app" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= @@ -68,11 +60,19 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= # SPECIFIC REMOVE +#================================================= +# REMOVE APP DATA DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="/home/yunohost.app/$app" + #================================================= # REMOVE THE CRON FILE #================================================= diff --git a/scripts/restore b/scripts/restore index 811eba9..ea4d445 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -20,7 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -31,6 +31,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -51,6 +52,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." --weight ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -58,28 +67,24 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." --weight=1 - -# Restore permissions on app files -chown -R root: $final_path -chmod o-rwx $final_path chmod 2775 "$final_path/app/sites/default/files" -mkdir -p "/home/yunohost.app/$app/data" -chown -R $app: "/home/yunohost.app/$app/data" -chmod 775 "/home/yunohost.app/$app/data" -chmod 600 "$final_path/app/sites/default/settings.php" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --time --weight=1 + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -90,8 +95,11 @@ ynh_script_progression --message="Restoring PHP-FPM configuration..." --weight=1 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" +ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# SPECIFIC RESTORATION #================================================= # RESTORE THE CRON FILE #================================================= @@ -100,8 +108,6 @@ ynh_script_progression --message="Restoring cron file..." --weight=1 # Restore the file first, so it can have a backup if different ynh_restore_file --origin_path="/etc/cron.d/$app" -#================================================= -# SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5abce2f..45e8c6f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) admin=$(ynh_app_setting_get --app=$app --key=admin) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION @@ -30,6 +31,22 @@ ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=21 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -47,6 +64,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If datadir doesn't exist, create it +if [ -z "$datadir" ]; then + final_path=/home/yunohost.app/$app + ynh_app_setting_set --app=$app --key=final_path --value=$datadir +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -59,30 +82,14 @@ if ! ynh_permission_exists --permission="admin"; then ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=21 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path -#================================================= -# STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -95,12 +102,16 @@ then ynh_setup_source --dest_dir="$final_path/app" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -120,6 +131,16 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie #================================================= # SPECIFIC UPGRADE +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." --time --weight=1 + +mkdir -p $datadir +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # UPGRADE COMPOSER #================================================= @@ -139,8 +160,6 @@ then ynh_backup_if_checksum_is_different --file="$final_path/app/sites/default/settings.php" - chown -R $app: $final_path - update-alternatives --set php /usr/bin/php$phpversion pushd "$final_path" @@ -156,32 +175,15 @@ then fi #================================================= -# STORE THE CONFIG FILE CHECKSUM +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Storing the config file checksum..." --weight=1 +ynh_script_progression --message="Updating a configuration file..." -config_file=$final_path/app/sites/default/settings.php - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config_file" - -#================================================= +chmod 600 "$final_path/app/sites/default/settings.php" +chown $app:$app "$final_path/app/sites/default/settings.php" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 - -# Set permissions on app files -chown -R $app: $final_path -chmod o-rwx $final_path -mkdir -p "/home/yunohost.app/$app/data" -chown -R $app: "/home/yunohost.app/$app/data" -chmod 775 "/home/yunohost.app/$app/data" -chmod 600 $config_file - #================================================= # RELOAD NGINX #================================================= From 673aa5eaa878b3b4a2fa206eef3ad3e7c8a4a30d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 May 2021 02:21:01 +0200 Subject: [PATCH 14/19] remove time --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 81837ff..95a091d 100644 --- a/scripts/install +++ b/scripts/install @@ -156,7 +156,7 @@ mkdir -p "$final_path/app/sites/default/files/tmp" #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --time --weight=1 +ynh_script_progression --message="Creating a data directory..." datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir diff --git a/scripts/restore b/scripts/restore index ea4d445..6178f45 100644 --- a/scripts/restore +++ b/scripts/restore @@ -76,7 +76,7 @@ chmod 2775 "$final_path/app/sites/default/files" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --time --weight=1 +ynh_script_progression --message="Restoring the data directory..." ynh_restore_file --origin_path="$datadir" --not_mandatory diff --git a/scripts/upgrade b/scripts/upgrade index 45e8c6f..ba496e9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -134,7 +134,7 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --time --weight=1 +ynh_script_progression --message="Creating a data directory..." mkdir -p $datadir chmod 750 "$datadir" From 4d015494364f859a4319aa5cd12d22218d5d128e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 May 2021 04:19:47 +0200 Subject: [PATCH 15/19] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index fdfaeed..8a0ac17 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "url": "https://framagit.org/framasoft/framaforms", "license": "GPL-2.0-only", "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.0" }, "maintainer": { "name": "ljf", From c85cb9843664478c1b486f8ed920b68e0a0c5517 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 May 2021 04:25:18 +0200 Subject: [PATCH 16/19] Fix install --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index 95a091d..d29bea8 100644 --- a/scripts/install +++ b/scripts/install @@ -127,6 +127,9 @@ drush_aliasconfig="$final_path/.drush/$app.aliases.drushrc.php" ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$drush_aliasconfig" +chmod 400 "$drush_aliasconfig" +chown $app:$app "$drush_aliasconfig" + #================================================= # INSTALL COMPOSER #================================================= From 0db0fabd27473a319883c95aa6454f909a6dfb23 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Fri, 21 May 2021 15:37:39 +0200 Subject: [PATCH 17/19] Create `files` folder BEFORE setting permissions --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index d29bea8..230c2e9 100644 --- a/scripts/install +++ b/scripts/install @@ -148,13 +148,13 @@ export PATH="$final_path/.composer/vendor/bin:$PATH" #================================================= ynh_script_progression --message="Initializing tmp and private directory..." --weight=1 +mkdir -p "$final_path/app/sites/default/files" +mkdir -p "$final_path/app/sites/default/files/tmp" + chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" - -mkdir -p "$final_path/app/sites/default/files" chmod 2775 "$final_path/app/sites/default/files" -mkdir -p "$final_path/app/sites/default/files/tmp" #================================================= # CREATE DATA DIRECTORY From 1bf6bf3ed7423fd56d1b5bc3dab47701d108266f Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Wed, 9 Jun 2021 14:27:11 +0200 Subject: [PATCH 18/19] Remove upgrade from 25e971 --- check_process | 2 -- 1 file changed, 2 deletions(-) diff --git a/check_process b/check_process index 71fd1e2..0418448 100644 --- a/check_process +++ b/check_process @@ -16,8 +16,6 @@ setup_private=1 setup_public=1 upgrade=1 - # 1.0.1+200715~ynh4 - upgrade=1 from_commit=25e97123f0e82ec1b9375774f3e86b7d8f5d73cf backup_restore=1 multi_instance=1 change_url=1 From 1a9b2d0f5a3efd4eaefe72261a7990947a489151 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 13 Jun 2021 14:54:39 +0200 Subject: [PATCH 19/19] Improvement script progression comment --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 8295c34..1b12a17 100644 --- a/scripts/remove +++ b/scripts/remove @@ -68,7 +68,7 @@ ynh_remove_fpm_config #================================================= # REMOVE APP DATA DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +ynh_script_progression --message="Removing app data directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="/home/yunohost.app/$app"