2020-01-29 15:24:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
app=$1
|
|
|
|
removed_users=$2
|
|
|
|
permission=$3
|
|
|
|
removed_groups=$4
|
|
|
|
|
|
|
|
if [ "$app" == __APP__ ]; then
|
2020-02-13 16:14:56 +01:00
|
|
|
if [ "$permission" = "upload images" ]; then # The fake permission "upload images" is modifed.
|
|
|
|
if [ "$removed_groups" = "visitors" ]; then # As is it a fake permission we can only grant/remove the "visitors" group.
|
2020-02-11 09:59:59 +01:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
2020-02-13 16:14:56 +01:00
|
|
|
|
|
|
|
# If the app is private, viewing images stays publicly accessible.
|
|
|
|
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
|
2020-02-11 09:59:59 +01:00
|
|
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
|
|
|
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
|
2020-02-13 16:14:56 +01:00
|
|
|
|
|
|
|
# Sync the is_public variable according to the permission
|
2020-02-12 12:15:20 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
2020-02-11 09:59:59 +01:00
|
|
|
|
|
|
|
yunohost app ssowatconf
|
|
|
|
else
|
|
|
|
ynh_print_warn --message="This app doesn't support this authorisation, you can only add or remove visitors group."
|
|
|
|
fi
|
2020-01-29 15:24:28 +01:00
|
|
|
fi
|
|
|
|
fi
|