From 024a7b734a7c18aacf59d203d2e972595381c775 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 17 Feb 2017 14:45:54 +0000 Subject: [PATCH] Ability to set the app public or not --- manifest.json | 9 +++++++++ scripts/install | 13 +++++++++++-- scripts/restore | 10 ++++++++++ scripts/upgrade | 11 +++++++++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 9c2d7585..447ddce2 100644 --- a/manifest.json +++ b/manifest.json @@ -67,6 +67,15 @@ "choices": ["64M", "128M", "256M", "512M", "1024M"], "default": "256M", "optional": false + }, + { + "name": "is_public", + "ask": { + "en": "Is it a public website ?", + "fr": "Est-ce un site publique ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" } ] } diff --git a/scripts/install b/scripts/install index 7fdefa4d..70b5e3ed 100755 --- a/scripts/install +++ b/scripts/install @@ -17,6 +17,7 @@ path=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL upload=$YNH_APP_ARG_UPLOAD +is_public=$YNH_APP_ARG_IS_PUBLIC # Source app helpers source /usr/share/yunohost/helpers @@ -40,6 +41,7 @@ ynh_app_setting_set $app path $path ynh_app_setting_set $app admin $admin ynh_app_setting_set $app email $email ynh_app_setting_set $app upload $upload +ynh_app_setting_set $app is_public $is_public # Install dependencies sudo apt-get update @@ -124,8 +126,15 @@ sudo chmod 644 $phpfpmconf sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron sudo cp ../conf/poller-cron /etc/cron.d/$app -# Enable api for client and make app public -ynh_app_setting_set $app skipped_uris "/" +# Make app public if necessary +is_public=$(ynh_app_setting_get $app is_public) +if [ "$is_public" = "Yes" ]; +then + ynh_app_setting_set $app skipped_uris "/" +else + ynh_app_setting_set $app protected_uris "/" +fi + # Reload services sudo service php5-fpm restart || true diff --git a/scripts/restore b/scripts/restore index 5c8084d1..58e35494 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,6 +8,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) admin=$(ynh_app_setting_get $app admin) final_path=$(ynh_app_setting_get $app final_path) db_user=$(ynh_app_setting_get $app db_user) @@ -44,6 +45,15 @@ sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf # Backup cron job sudo cp -a $backup_dir/cron.job /etc/cron.d/$app +# Make app public if necessary +is_public=$(ynh_app_setting_get $app is_public) +if [ "$is_public" = "Yes" ]; +then + ynh_app_setting_set $app skipped_uris "/" +else + ynh_app_setting_set $app protected_uris "/" +fi + # And Reload services sudo service php5-fpm restart sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index 679a8344..392eebaa 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,6 +10,7 @@ source /usr/share/yunohost/helpers domain=$(ynh_app_setting_get $app domain) path=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) admin=$(ynh_app_setting_get $app admin) final_path=$(ynh_app_setting_get $app final_path) db_pwd=$(ynh_app_setting_get $app db_pwd) @@ -74,8 +75,14 @@ sudo chown root: $phpfpmconf sed -i "s@YNH_WWW_PATH@$final_path@g" ../conf/poller-cron sudo cp ../conf/poller-cron /etc/cron.d/$app -# Enable api for client and make app public -ynh_app_setting_set $app skipped_uris "/" +# Make app public if necessary +is_public=$(ynh_app_setting_get $app is_public) +if [ "$is_public" = "Yes" ]; +then + ynh_app_setting_set $app skipped_uris "/" +else + ynh_app_setting_set $app protected_uris "/" +fi # Reload services sudo service php5-fpm restart || true