From 1125a9433df44e40e9a4fff9e8ec831b8238145d Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 8 Mar 2019 22:04:09 +0100 Subject: [PATCH] Fix public/private --- scripts/change_url | 17 +++++++++++++++++ scripts/install | 13 ++++++++----- scripts/upgrade | 13 ++++++++----- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index ef25dbf..23da1c3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -127,6 +127,23 @@ ynh_store_file_checksum "${final_path}/lufi.conf" #================================================= # GENERIC FINALISATION +#================================================= +# UPDATE SSOWAT +#================================================= +ynh_print_info "Reconfigure SSOwat" + +ynh_app_setting_set $app unprotected_uris "/" +if [ $is_public -eq 0 ] +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 protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" +fi + #================================================= # RESTART LUFI #================================================= diff --git a/scripts/install b/scripts/install index 4885b08..33afb7c 100644 --- a/scripts/install +++ b/scripts/install @@ -196,13 +196,16 @@ yunohost service add $app --log "$final_path/log/production.log" #================================================= ynh_print_info "Configuring SSOwat..." -# Make app public or private ynh_app_setting_set $app unprotected_uris "/" -if [ $is_public -eq 0 ]; +if [ $is_public -eq 0 ] then - ynh_app_setting_set $app protected_regex "/stats$","/manifest.webapp$","/$","/d/.*$","/m/.*$" -else - ynh_app_setting_delete $app protected_regex + 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 protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7a821fb..fb6d1e3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,13 +185,16 @@ ln -sf "$final_path/log/production.log" "/var/log/$app/production.log" #================================================= ynh_print_info "Upgrading SSOwat configuration..." -# Make app public or private ynh_app_setting_set $app unprotected_uris "/" -if [ $is_public -eq 0 ]; +if [ $is_public -eq 0 ] then - ynh_app_setting_set $app protected_regex "/stats$","/manifest.webapp$","/$","/d/.*$","/m/.*$" -else - ynh_app_setting_delete $app protected_regex + 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 protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi #=================================================