From 00146b35820c1c0f6afd2618edc765682aec0582 Mon Sep 17 00:00:00 2001 From: ewilly Date: Mon, 18 Nov 2019 16:26:21 +0100 Subject: [PATCH] Update --- scripts/_common.sh | 44 ++++++++++++++------------------------------ scripts/install | 2 ++ 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index e20e803..1744eeb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -46,34 +46,18 @@ myynh_set_permissions () { chown root: "$data_path" } -#Change --data to --data-urlencode -myynh_local_curl () { - # Define url of page to curl - local local_page=$(ynh_normalize_url_path $1) - local full_path=$path_url$local_page - - if [ "${path_url}" == "/" ]; then - full_path=$local_page - fi - - local full_page_url=https://localhost$full_path - - # Concatenate all other arguments with '&' to prepare POST data - local POST_data="" - local arg="" - for arg in "${@:2}" - do - POST_data="${POST_data}${arg}&" - done - if [ -n "$POST_data" ] - then - # Add --data-urlencode arg and remove the last character, which is an unecessary '&' - POST_data="--data-urlencode ${POST_data::-1}" - fi - - # Wait untils nginx has fully reloaded (avoid curl fail with http2) - sleep 2 - - # Curl the URL - curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 $POST_data "$full_page_url" +#Convert --data to --data-urlencode before ynh_local_curl +urlencode() { + local data + if [[ $# != 1 ]]; then + echo "Usage: $0 string-to-urlencode" + return 1 + fi + data="$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")" + if [[ $? != 3 ]]; then + echo "Unexpected error" 1>&2 + return 2 + fi + echo "${data##/?}" + return 0 } diff --git a/scripts/install b/scripts/install index 1de0f50..4809509 100644 --- a/scripts/install +++ b/scripts/install @@ -75,6 +75,8 @@ yunohost app ssowatconf # fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?) admin_url="/index.php?p=login" +admin=$(urlencode $admin) +password=$(urlencode $password) ynh_local_curl $admin_url "creation=1" "login=$admin" "pass=$password" "confirm=$password" # if app is private, remove url to SSOWat conf from skipped_uris