Merge pull request #1370 from YunoHost/curl-auto-visitors-if-needed

ynh_local_curl: temporarily auto-add visitors if needed
This commit is contained in:
Alexandre Aubin 2021-11-03 18:30:32 +01:00 committed by GitHub
commit 20037cf387
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,8 +290,18 @@ ynh_local_curl() {
chown root $cookiefile chown root $cookiefile
chmod 700 $cookiefile chmod 700 $cookiefile
# Temporarily enable visitors if needed...
local visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no)
if [[ $visitors_enabled == "no" ]]; then
ynh_permission_update --permission "main" --add "visitors"
fi
# Curl the URL # Curl the URL
curl --silent --show-error --insecure --location --header "Host: $domain" --resolve $domain:443:127.0.0.1 $POST_data "$full_page_url" --cookie-jar $cookiefile --cookie $cookiefile curl --silent --show-error --insecure --location --header "Host: $domain" --resolve $domain:443:127.0.0.1 $POST_data "$full_page_url" --cookie-jar $cookiefile --cookie $cookiefile
if [[ $visitors_enabled == "no" ]]; then
ynh_permission_update --permission "main" --remove "visitors"
fi
} }
# Create a dedicated config file from a template # Create a dedicated config file from a template