From 6c435910799ffb1337a7f6d9311dd985b506a3df Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sat, 22 Feb 2020 13:53:34 +0100 Subject: [PATCH 01/14] New Permission System --- hooks/post_app_addaccess | 33 +++++++++++++++++++ hooks/post_app_removeaccess | 26 +++++++++++++++ manifest.json | 2 +- scripts/change_url | 5 +-- scripts/install | 30 +++++++++++++---- scripts/remove | 2 +- scripts/upgrade | 64 +++++++++++++++++++++++++------------ 7 files changed, 129 insertions(+), 33 deletions(-) create mode 100644 hooks/post_app_addaccess create mode 100644 hooks/post_app_removeaccess diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess new file mode 100644 index 0000000..f86ee4e --- /dev/null +++ b/hooks/post_app_addaccess @@ -0,0 +1,33 @@ +#!/bin/bash + +# Source app helpers +source /usr/share/yunohost/helpers + +app=$1 +added_users=$2 +permission=$3 +added_groups=$4 + +if [ "$app" == __APP__ ]; then + if [ "$permission" = "create poll" ]; then # The fake permission "create poll" is modifed. + if [ "$added_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group. + domain=$(ynh_app_setting_get --app=$app --key=domain) + path_url=$(ynh_app_setting_get --app=$app --key=path) + + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" + + # Sync the is_public variable according to the permission + ynh_app_setting_set --app=$app --key=is_public --value=1 + + yunohost app ssowatconf + else + ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group." + fi + fi +fi \ No newline at end of file diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess new file mode 100644 index 0000000..1ea9ab3 --- /dev/null +++ b/hooks/post_app_removeaccess @@ -0,0 +1,26 @@ +#!/bin/bash + +# Source app helpers +source /usr/share/yunohost/helpers + +app=$1 +removed_users=$2 +permission=$3 +removed_groups=$4 + +if [ "$app" == __APP__ ]; then + if [ "$permission" = "create poll" ]; then # The fake permission "create poll" is modifed. + if [ "$removed_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group. + + # We remove the regex, no more protection is needed. + ynh_app_setting_delete --app=$app --key=unprotected_regex + + # Sync the is_public variable according to the permission + ynh_app_setting_set --app=$app --key=is_public --value=0 + + yunohost app ssowatconf + else + ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group." + fi + fi +fi \ No newline at end of file diff --git a/manifest.json b/manifest.json index 1935bdb..f36ce39 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "email": "ljf+opensondage_ynh@grimaud.me" }], "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.7.0" }, "multi_instance": true, "services": [ diff --git a/scripts/change_url b/scripts/change_url index bb0a96f..c7422c9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -97,16 +97,13 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_delete --app=$app --key=protected_regex - - # Keep /admin private if [ "$path_url" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. path_url="" fi # Modify the domain to be used in a regex domain_regex=$(echo "$new_domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/admin/" + ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" fi #================================================= diff --git a/scripts/install b/scripts/install index f127726..75f6b13 100644 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..."3 +ynh_script_progression --message="Installing dependencies..." --weight=3 ynh_install_app_dependencies php-fpdf php-cli php-xml @@ -125,6 +125,14 @@ ynh_replace_string --match_string="__PATH__" --replace_string=$path_url - # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config" +#================================================= +# SETUP HOOKS FILE +#================================================= + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess" + + #================================================= # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE) #================================================= @@ -140,7 +148,7 @@ touch "$final_path/admin/stdout.log" #================================================= # RUN DATABASE INITILIZATION #================================================= -ynh_script_progression --message="Initializing database..."2 +ynh_script_progression --message="Initializing database..." --weight=2 # Install composer ynh_install_composer @@ -159,21 +167,29 @@ chown -R $app: "$final_path/"{tpl_c,admin/stdout.log} #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring Permissions..." + +ynh_permission_update --permission="main" --add="visitors" + +ynh_permission_create --permission="admin" --allowed="$admin" --url="/admin" + +# This is a fake permission without any URL. +# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. +# We can't use a real permission for now because the actual permision system doesn't support regex. +ynh_permission_create --permission="create poll" --allowed="visitors" # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_set --app=$app --key=skipped_uris --value="/" - - # Keep /admin private if [ "$path_url" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. path_url="" fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/admin/" + ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" +else + ynh_permission_update --permission="create poll" --remove="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 4f937c8..c088a11 100644 --- a/scripts/remove +++ b/scripts/remove @@ -25,7 +25,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..."3 +ynh_script_progression --message="Removing dependencies..." --weight=3 # Remove metapackage and its dependencies ynh_remove_app_dependencies diff --git a/scripts/upgrade b/scripts/upgrade index b28d82d..8d2b3c2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,43 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi +skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) + +# Unused with the permission system +if [ ! -z "$skipped_uris" ]; then + ynh_app_setting_delete --app=$app --key=skipped_uris +fi + +protected_regex=$(ynh_app_setting_get --app=$app --key=protected_regex) + +# Unused with the permission system +if [ ! -z "$protected_regex" ]; then + ynh_app_setting_delete --app=$app --key=protected_regex +fi + +# Create the permission "upload images" only if it doesn't exist. +if ! ynh_permission_exists --permission="create poll" +then + # This is a fake permission without any URL. + # The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. + # We can't use a real permission for now because the actual permision system doesn't support regex. + ynh_permission_create --permission="create poll" --allowed="visitors" + + # Make app public if necessary + if [ $is_public -eq 1 ] + then + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" + else + ynh_permission_update --permission="create poll" --remove="visitors" + fi +fi + # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -176,6 +213,13 @@ then ynh_store_file_checksum --file="$config" fi +#================================================= +# SETUP HOOKS FILE +#================================================= + +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess" + #================================================= # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE) #================================================= @@ -211,26 +255,6 @@ fi chown -R root: "$final_path" chown -R $app: "$final_path/"{tpl_c,admin/stdout.log} -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - ynh_app_setting_set --app=$app --key=skipped_uris --value="/" - - # Keep /admin private - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/admin/" -fi - #================================================= # RELOAD NGINX #================================================= From a8bafc51dd9bacb79d08ef38ec63c56f68795762 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 12 Nov 2021 01:17:43 +0100 Subject: [PATCH 02/14] c.f. discussion regarding what 'private' means for this app ... let's just skip the test on CI ... --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 98248f7..1408be1 100644 --- a/check_process +++ b/check_process @@ -10,7 +10,7 @@ setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=1 + setup_private=0 setup_public=1 upgrade=1 upgrade=1 from_commit=02f2cd7e656ebae74643e969746b23d8912c7798 From 1b9441401f93aa5e60fae788269f5151640f4f9b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 12 Nov 2021 07:48:48 +0100 Subject: [PATCH 03/14] fix linter warning --- manifest.json | 6 ++---- scripts/restore | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index 42ae370..f9031da 100644 --- a/manifest.json +++ b/manifest.json @@ -39,8 +39,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -50,8 +49,7 @@ }, { "name": "admin", - "type": "user", - "example": "johndoe" + "type": "user" }, { "name": "language", diff --git a/scripts/restore b/scripts/restore index 364a839..44d124e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,8 +35,6 @@ timezone="$(cat /etc/timezone)" #================================================ ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " From 39f0bc2fa3a987b2fd2e7ed6f2d7cc82d663c806 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 12 Nov 2021 07:49:00 +0100 Subject: [PATCH 04/14] Update manifest.json --- manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.json b/manifest.json index f9031da..7d07dd3 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,6 @@ "website": "https://framadate.org/", "demo": "https://framadate.org/", "admindoc": "https://framagit.org/framasoft/framadate/framadate/wikis/home", - "userdoc": "https://yunohost.org/#/app_opensondage", "code": "https://git.framasoft.org/framasoft/framadate" }, "license": "CECILL-B", From 814252d14b2e0ebabff5dc88aaebcc5951cedc54 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 12 Nov 2021 06:49:05 +0000 Subject: [PATCH 05/14] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 058b6d6..fd9756f 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Service for planning an appointment or making a decision quickly and easily ## Documentation and resources * Official app website: https://framadate.org/ -* Official user documentation: https://yunohost.org/#/app_opensondage * Official admin documentation: https://framagit.org/framasoft/framadate/framadate/wikis/home * Upstream app code repository: https://git.framasoft.org/framasoft/framadate * YunoHost documentation for this app: https://yunohost.org/app_opensondage diff --git a/README_fr.md b/README_fr.md index ea78b08..c1cd142 100644 --- a/README_fr.md +++ b/README_fr.md @@ -35,7 +35,6 @@ Service pour planifier un rendez-vous ou prendre une décision rapidement et fac ## Documentations et ressources * Site officiel de l'app : https://framadate.org/ -* Documentation officielle utilisateur : https://yunohost.org/#/app_opensondage * Documentation officielle de l'admin : https://framagit.org/framasoft/framadate/framadate/wikis/home * Dépôt de code officiel de l'app : https://git.framasoft.org/framasoft/framadate * Documentation YunoHost pour cette app : https://yunohost.org/app_opensondage From 5fbc91f3328f11791881acb3e7c16ebabfb0c53f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 12 Nov 2021 07:50:43 +0100 Subject: [PATCH 06/14] Update check_process --- check_process | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 1408be1..ce959c4 100644 --- a/check_process +++ b/check_process @@ -13,11 +13,11 @@ setup_private=0 setup_public=1 upgrade=1 - upgrade=1 from_commit=02f2cd7e656ebae74643e969746b23d8912c7798 + upgrade=1 from_commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b backup_restore=1 multi_instance=1 change_url=1 ;;; Upgrade options - ; commit=02f2cd7e656ebae74643e969746b23d8912c7798 - name=Merge pull request #70 from YunoHost-Apps/testing + ; commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b + name=Merge pull request #77 from YunoHost-Apps/testing manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=1& From f65ef22fc7793a747d2bf06fb5b37558e2fbb384 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 12 Nov 2021 11:06:00 +0100 Subject: [PATCH 07/14] 1.1.17 --- check_process | 2 +- conf/app.src | 6 +++--- manifest.json | 2 +- scripts/install | 1 - scripts/upgrade | 28 ++++++++++++++-------------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/check_process b/check_process index ce959c4..0d613e1 100644 --- a/check_process +++ b/check_process @@ -20,4 +20,4 @@ ;;; Upgrade options ; commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b name=Merge pull request #77 from YunoHost-Apps/testing - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=1& + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1& diff --git a/conf/app.src b/conf/app.src index 6a39146..5a26197 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://framagit.org/framasoft/framadate/framadate/-/archive/1.1.16/framadate-1.1.16.tar.gz -SOURCE_SUM=89da42a915c912a91ae1ba44fd32a61ec8fa5f59c517ee3f5d74335ddee77c7d +SOURCE_URL=https://framagit.org/framasoft/framadate/framadate/-/archive/1.1.17/framadate-1.1.17.tar.gz +SOURCE_SUM=a9b086a7274886d0d13c1c3ed8d6caa848d798315bd6006c6883a37387c390b0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=opensondage-1-1-16.tar.gz +SOURCE_FILENAME=opensondage-1-1-17.tar.gz diff --git a/manifest.json b/manifest.json index 7d07dd3..c346179 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement", "de": "Service zur schnellen und einfachen Planung eines Termins oder zur Entscheidungsfindung" }, - "version": "1.1.16~ynh1", + "version": "1.1.17~ynh1", "url": "https://git.framasoft.org/framasoft/framadate", "upstream": { "license": "CECILL-B", diff --git a/scripts/install b/scripts/install index 8796c17..071a593 100644 --- a/scripts/install +++ b/scripts/install @@ -115,7 +115,6 @@ ynh_add_config --template="../conf/config.php" --destination="$final_path/app/in ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_addaccess" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../hooks/post_app_removeaccess" - #================================================= # REPLACE LOGO IMAGE (DEFAULT IS FRAMADATE) #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 4f2020e..568fe74 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,6 +35,20 @@ timezone="$(cat /etc/timezone)" 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=3 + +# 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 + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -121,20 +135,6 @@ if [ -z "$path_url" ]; then ynh_app_setting_delete --app=$app --key=path_url fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 - -# 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 #================================================= From 59a56f1cde774b71f05d2853056167658db00548 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 12 Nov 2021 10:06:06 +0000 Subject: [PATCH 08/14] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd9756f..ada2d3a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Service for planning an appointment or making a decision quickly and easily -**Shipped version:** 1.1.16~ynh1 +**Shipped version:** 1.1.17~ynh1 **Demo:** https://framadate.org/ diff --git a/README_fr.md b/README_fr.md index c1cd142..cf2bd4f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement -**Version incluse :** 1.1.16~ynh1 +**Version incluse :** 1.1.17~ynh1 **Démo :** https://framadate.org/ From 311768b916030b8b03261892180e52eab89f568b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 26 Nov 2021 18:46:27 +0100 Subject: [PATCH 09/14] 4.3 --- conf/app.src | 2 +- conf/nginx.conf | 5 ----- manifest.json | 2 +- scripts/_common.sh | 4 ++-- scripts/install | 15 +++++++++++++-- scripts/remove | 8 ++++++++ scripts/restore | 11 ++++++++--- scripts/upgrade | 9 ++++++++- 8 files changed, 41 insertions(+), 15 deletions(-) diff --git a/conf/app.src b/conf/app.src index 5a26197..b307330 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,4 @@ SOURCE_SUM=a9b086a7274886d0d13c1c3ed8d6caa848d798315bd6006c6883a37387c390b0 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=opensondage-1-1-17.tar.gz +SOURCE_FILENAME=opensondage.tar.gz diff --git a/conf/nginx.conf b/conf/nginx.conf index 56d6c10..b102748 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - rewrite "^__PATH__/([a-zA-Z0-9-]+)$" "__PATH__/studs.php?poll=$1"; rewrite "^__PATH__/([a-zA-Z0-9-]+)/action/([a-zA-Z_-]+)/(.+)$" "__PATH__/studs.php?poll=$1&$2=$3"; rewrite "^__PATH__/([a-zA-Z0-9-]+)/vote/([a-zA-Z0-9]{16})$" "__PATH__/studs.php?poll=$1&vote=$2"; diff --git a/manifest.json b/manifest.json index c346179..90fdf69 100644 --- a/manifest.json +++ b/manifest.json @@ -26,7 +26,7 @@ "email": "ljf+opensondage_ynh@grimaud.me" }], "requirements": { - "yunohost": ">= 4.2.0" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 406bdfb..6b3d3fe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,8 +6,8 @@ # dependencies used by the app YNH_PHP_VERSION="7.3" -YNH_COMPOSER_VERSION=2.1.1 -extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli" +YNH_COMPOSER_VERSION="2.1.1" +pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-cli" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 071a593..3a27115 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ language=$YNH_APP_ARG_LANGUAGE is_public=$YNH_APP_ARG_IS_PUBLIC email=$(ynh_user_get_info --username=$admin --key=mail) timezone="$(cat /etc/timezone)" +phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -50,6 +51,14 @@ 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=language --value=$language ynh_app_setting_set --app=$app --key=email --value=$email +ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -96,8 +105,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config #================================================= # SPECIFIC SETUP @@ -108,6 +116,9 @@ ynh_script_progression --message="Configuring $app..." --weight=2 ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php" +chmod 400 "$final_path/app/inc/config.php" +chown $app:$app "$final_path/app/inc/config.php" + #================================================= # SETUP HOOKS FILE #================================================= diff --git a/scripts/remove b/scripts/remove index 705c54d..c68f608 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,6 +28,14 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=5 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 44d124e..262ba90 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,8 +35,7 @@ timezone="$(cat /etc/timezone)" #================================================ ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -80,7 +79,13 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --package="$extra_php_dependencies" +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 568fe74..31c3794 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -169,13 +169,20 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE From 2210ca525b44fe6c9c2905119c2c535c37597b78 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 26 Nov 2021 19:10:55 +0100 Subject: [PATCH 10/14] Set permissions --- scripts/install | 24 +++++------------------ scripts/upgrade | 51 ++++++++----------------------------------------- 2 files changed, 13 insertions(+), 62 deletions(-) diff --git a/scripts/install b/scripts/install index 3a27115..f14ca07 100644 --- a/scripts/install +++ b/scripts/install @@ -159,31 +159,17 @@ chown -R $app: "$final_path/"{tpl_c,admin/stdout.log} #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring Permissions..." - -ynh_permission_update --permission="main" --add="visitors" - -ynh_permission_create --permission="admin" --allowed="$admin" --url="/admin" - -# This is a fake permission without any URL. -# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. -# We can't use a real permission for now because the actual permision system doesn't support regex. -ynh_permission_create --permission="create poll" --allowed="visitors" +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" -else - ynh_permission_update --permission="create poll" --remove="visitors" + 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 31c3794..f59b094 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,7 +19,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) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -60,50 +59,16 @@ if [ -z "$is_public" ]; then ynh_app_setting_delete --app=$app --key=public_site fi -# 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 +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public fi -skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) - -# Unused with the permission system -if [ ! -z "$skipped_uris" ]; then - ynh_app_setting_delete --app=$app --key=skipped_uris -fi - -protected_regex=$(ynh_app_setting_get --app=$app --key=protected_regex) - -# Unused with the permission system -if [ ! -z "$protected_regex" ]; then - ynh_app_setting_delete --app=$app --key=protected_regex -fi - -# Create the permission "upload images" only if it doesn't exist. -if ! ynh_permission_exists --permission="create poll" -then - # This is a fake permission without any URL. - # The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. - # We can't use a real permission for now because the actual permision system doesn't support regex. - ynh_permission_create --permission="create poll" --allowed="visitors" - - # Make app public if necessary - if [ $is_public -eq 1 ] - then - if [ "$path_url" == "/" ]; then - # If the path is /, clear it to prevent any error with the regex. - path_url="" - fi - # Modify the domain to be used in a regex - domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set --app=$app --key=unprotected_regex --value="$domain_regex$path_url/create_poll.php?.*$","$domain_regex$path_url/adminstuds.php?.*" - else - ynh_permission_update --permission="create poll" --remove="visitors" - fi +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin fi # If db_name doesn't exist, create it From c436a8a7675e47b1ab321145f2885c4d579be193 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 26 Nov 2021 19:13:10 +0100 Subject: [PATCH 11/14] Add description --- doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + 2 files changed, 2 insertions(+) create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..17fbe0a --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Opensondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..6f84764 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Opensondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. \ No newline at end of file From a2c0e81232059b666091e92f35b0c09530f5ac77 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 26 Nov 2021 18:13:16 +0000 Subject: [PATCH 12/14] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ada2d3a..2d27dd8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Service for planning an appointment or making a decision quickly and easily +Opensondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. **Shipped version:** 1.1.17~ynh1 diff --git a/README_fr.md b/README_fr.md index cf2bd4f..4ce8086 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Service pour planifier un rendez-vous ou prendre une décision rapidement et facilement +Opensondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. **Version incluse :** 1.1.17~ynh1 From d52221e971e6dda873a78225d650c93787c6740a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 26 Nov 2021 19:20:15 +0100 Subject: [PATCH 13/14] Fix --- check_process | 2 +- doc/DESCRIPTION.md | 2 +- doc/DESCRIPTION_fr.md | 2 +- scripts/upgrade | 34 ++++++++++++++-------------------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/check_process b/check_process index 0d613e1..cca0046 100644 --- a/check_process +++ b/check_process @@ -10,7 +10,7 @@ setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 upgrade=1 from_commit=61398d8e49d4de8e7425c4ccd8098d5a4c55994b diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 17fbe0a..797f1f1 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1 @@ -Opensondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. \ No newline at end of file +OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 6f84764..862aceb 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1 +1 @@ -Opensondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. \ No newline at end of file +OpenSondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index f59b094..dbfa210 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,24 +53,6 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -if [ -z "$is_public" ]; then - is_public=$(ynh_app_setting_get --app=$app --key=public_site) - ynh_app_setting_set --app=$app --key=is_public --value=$is_public - ynh_app_setting_delete --app=$app --key=public_site -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 - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -100,6 +82,18 @@ if [ -z "$path_url" ]; then ynh_app_setting_delete --app=$app --key=path_url 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 + #================================================= # CREATE DEDICATED USER #================================================= @@ -160,8 +154,8 @@ then ynh_script_progression --message="Reconfiguring $app..." --weight=2 ynh_add_config --template="../conf/config.php" --destination="$final_path/app/inc/config.php" - chmod 400 "$final_path/app/inc/config.php" - chown $app:$app "$final_path/app/inc/config.php" + chmod 400 "$final_path/app/inc/config.php" + chown $app:$app "$final_path/app/inc/config.php" fi #================================================= From f40843d4f4ed8b56d09e1666b5ea333903f4c902 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Mon, 29 Nov 2021 18:28:27 +0000 Subject: [PATCH 14/14] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d27dd8..22798c1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Opensondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. +OpenSondage is an online service for planning an appointment or making a decision quickly and easily. No registration is required. **Shipped version:** 1.1.17~ynh1 diff --git a/README_fr.md b/README_fr.md index 4ce8086..b7c02d9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Opensondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. +OpenSondage est un service en ligne permettant de planifier un rendez-vous ou prendre des décisions rapidement et simplement. Aucune inscription préalable n’est nécessaire. **Version incluse :** 1.1.17~ynh1