remove visitors only for if current value is /

This commit is contained in:
Kay0u 2020-01-29 14:24:59 +07:00
parent c163ae2949
commit fc969ae1d4
No known key found for this signature in database
GPG key ID: 7FF262C033518333

View file

@ -158,7 +158,12 @@ ynh_add_protected_uris() {
#
ynh_app_setting()
{
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python - <<EOF
if [[ "$1" == "delete" ]] && [[ "$3" =~ ^(unprotected|skipped)_ ]]
then
current_value=$(ynh_app_setting_get --app=$app --key=$3)
fi
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python2.7 - <<EOF
import os, yaml, sys
app, action = os.environ['APP'], os.environ['ACTION'].lower()
key, value = os.environ['KEY'], os.environ.get('VALUE', None)
@ -192,7 +197,7 @@ EOF
if [[ "$1" == "set" ]] && [[ "${4:-}" == "/" ]]
then
ynh_permission_update --permission "main" --add "visitors"
elif [[ "$1" == "delete" ]]
elif [[ "$1" == "delete" ]] && [[ "${current_value:-}" == "/" ]]
then
ynh_permission_update --permission "main" --remove "visitors"
fi