#!/bin/bash # Get an application setting # # usage: ynh_app_setting_get --app=app --key=key # | arg: -a, --app - the application id # | arg: -k, --key - the setting to get ynh_app_setting_get() { # Declare an array to define the options of this helper. local legacy_args=ak declare -Ar args_array=( [a]=app= [k]=key= ) local app local key # Manage arguments with getopts ynh_handle_getopts_args "$@" sudo yunohost app setting "$app" "$key" --output-as plain --quiet } # Set an application setting # # usage: ynh_app_setting_set --app=app --key=key --value=value # | arg: -a, --app - the application id # | arg: -k, --key - the setting name to set # | arg: -v, --value - the setting value to set ynh_app_setting_set() { # Declare an array to define the options of this helper. local legacy_args=akv declare -Ar args_array=( [a]=app= [k]=key= [v]=value= ) local app local key local value # Manage arguments with getopts ynh_handle_getopts_args "$@" sudo yunohost app setting "$app" "$key" --value="$value" --quiet } # Delete an application setting # # usage: ynh_app_setting_delete --app=app --key=key # | arg: -a, --app - the application id # | arg: -k, --key - the setting to delete ynh_app_setting_delete() { # Declare an array to define the options of this helper. local legacy_args=ak declare -Ar args_array=( [a]=app= [k]=key= ) local app local key # Manage arguments with getopts ynh_handle_getopts_args "$@" sudo yunohost app setting -d "$app" "$key" --quiet } # Create a new permission for the app # # usage: ynh_permission_create --app "app" --permission "permission" --defaultdisallow [--urls "url" ["url" ...]] # | arg: app - the application id # | arg: permission - the name for the permission (by default a permission named "main" already exist) # | arg: defaultdisallow - define if all user will be allowed by default # | arg: urls - the list of urls for the the permission ynh_permission_create() { declare -Ar args_array=( [a]=app= [p]=permission= [d]=defaultdisallow [u]=urls= ) local app local permission local defaultdisallow local urls ynh_handle_getopts_args "$@" if [[ -n ${defaultdisallow:-} ]]; then defaultdisallow=",default_allow=False" fi if [[ -n ${urls:-} ]]; then urls=",urls=['${urls//';'/"','"}']" fi yunohost tools shell -c "from yunohost.permission import permission_add; permission_add(auth, '$app', '$permission' ${defaultdisallow:-} ${urls:-}, sync_perm=False)" } # Remove a permission for the app (note that when the app is removed all permission is automatically removed) # # usage: ynh_permission_remove --app "app" --permission "permission" # | arg: app - the application id # | arg: permission - the name for the permission (by default a permission named "main" is removed automatically when the app is removed) ynh_permission_remove() { declare -Ar args_array=( [a]=app= [p]=permission= ) local app local permission ynh_handle_getopts_args "$@" yunohost tools shell -c "from yunohost.permission import permission_remove; permission_remove(auth, '$app', '$permission', sync_perm=False)" } # Add a path managed by the SSO # # usage: ynh_permission_add_path --app "app" --permission "permission" --url "url" ["url" ...] # | arg: app - the application id # | arg: permission - the name for the permission # | arg: url - the FULL url for the the permission (ex domain.tld/apps/admin) ynh_permission_add_path() { declare -Ar args_array=( [a]=app= [p]=permission= [u]=url= ) local app local permission local url ynh_handle_getopts_args "$@" yunohost tools shell -c "from yunohost.permission import permission_update; permission_update(auth, '$app', '$permission', add_url=['${url//';'/"','"}'], sync_perm=False)" } # Remove a path managed by the SSO # # usage: ynh_permission_del_path --app "app" --permission "permission" --url "url" ["url" ...] # | arg: app - the application id # | arg: permission - the name for the permission # | arg: url - the FULL url for the the permission (ex domain.tld/apps/admin) ynh_permission_del_path() { declare -Ar args_array=( [a]=app= [p]=permission= [u]=url= ) local app local permission local url ynh_handle_getopts_args "$@" yunohost tools shell -c "from yunohost.permission import permission_update; permission_update(auth, '$app', '$permission', remove_url=['${url//';'/"','"}'], sync_perm=False)" }