From aa7721322dd4ab7ae489bccf5e9d989cac0834f6 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 07:19:04 +0000 Subject: [PATCH] scripts: modernize the publix/private switch This allow package_check to properly test it. --- check_process | 2 +- manifest.json | 6 +++--- scripts/install | 8 ++++---- scripts/restore | 7 +++++-- scripts/upgrade | 12 ++++++++++++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/check_process b/check_process index 54af7e4..58cf35f 100644 --- a/check_process +++ b/check_process @@ -10,7 +10,7 @@ ; Checks pkg_linter=1 setup_root=1 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 backup_restore=1 diff --git a/manifest.json b/manifest.json index c58151d..6924340 100644 --- a/manifest.json +++ b/manifest.json @@ -32,13 +32,13 @@ "example": "domain.org" }, { - "name": "public_site", + "name": "is_public", + "type": "boolean", "ask": { "en": "Can guest users access this chat?", "fr": "Les utilisateurs non-enregistrés peuvent-ils accéder à ce chat ?" }, - "choices": ["Yes", "No"], - "default": "Yes" + "default": true }, { "name": "analytics", diff --git a/scripts/install b/scripts/install index 4da5910..75b98b7 100644 --- a/scripts/install +++ b/scripts/install @@ -21,7 +21,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN -is_public=$YNH_APP_ARG_PUBLIC_SITE +is_public=$YNH_APP_ARG_IS_PUBLIC analytics=$YNH_APP_ARG_ANALYTICS path_url="/" @@ -163,11 +163,11 @@ sudo yunohost service add "$app" --log "$logs_path/mattermost.log" #================================================= ynh_app_setting_set "$app" is_public "$is_public" -if [ "$is_public" = "Yes" ]; -then + +if [[ $is_public == "1" ]]; then + # Make the app accessible to the public ynh_app_setting_set "$app" unprotected_uris "/" fi -sudo yunohost app ssowatconf #================================================= # RELOAD NGINX diff --git a/scripts/restore b/scripts/restore index 7218c15..514bc46 100644 --- a/scripts/restore +++ b/scripts/restore @@ -93,9 +93,12 @@ sudo chown -R mattermost:adm "$logs_path" # RESTORE SSOWAT #================================================= -if [ "$is_public" = "Yes" ]; -then +if [[ $is_public == "1" ]]; then + # Make the app accessible to the public ynh_app_setting_set "$app" unprotected_uris "/" +else + # Remove the public access + ynh_app_setting_delete "$app" skipped_uris fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b09a62c..2e166fc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,6 +72,18 @@ backup_config_file="/tmp/config.json" sudo cp -f "$config_file" "$backup_config_file" +#================================================= +# MIGRATE SETTINGS FROM PREVIOUS VERSIONS +#================================================= + +# Convert is_public from "Yes"/"No" to 1 / 0 +if [[ $is_public == "Yes" ]]; then + is_public=1 +elif [[ $is_public == "No" ]]; then + is_public=0 +fi +ynh_app_setting_set "$app" is_public "$is_public" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #=================================================