From cef7221323c9510e7b71196d558ecc2de1ff8d0d Mon Sep 17 00:00:00 2001 From: Kayou Date: Mon, 24 Jun 2019 09:52:08 +0200 Subject: [PATCH] Make /admin private after a change url --- scripts/change_url | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index dba7377..bb0a96f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,6 +29,8 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -87,6 +89,26 @@ ynh_replace_string --match_string="const APP_URL = '$old_domain';" --replace_str #================================================= # GENERIC FINALISATION +#================================================= +# SETUP SSOWAT +#================================================= +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/" +fi + #================================================= # RELOAD NGINX #=================================================