mirror of
https://github.com/YunoHost-Apps/aeneria_ynh.git
synced 2024-09-03 18:06:15 +02:00
32 lines
952 B
Bash
32 lines
952 B
Bash
#!/bin/bash
|
|
app=$1
|
|
|
|
# Run only if we are altering aeneria's permissions
|
|
[[ "$app" != "__APP__" ]] && exit 0
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
source /etc/yunohost/apps/$app/scripts/_common.sh
|
|
|
|
# Retrieve arguments
|
|
usernames=$2
|
|
permission=$3
|
|
groups=$4
|
|
install_dir=$(ynh_app_setting_get "$app" install_dir)
|
|
phpversion=$(ynh_app_setting_get "$app" phpversion)
|
|
|
|
IFS=',' read -r -a user_list <<< "$usernames"
|
|
IFS=',' read -r -a group_list <<< "$groups"
|
|
|
|
for group in "${group_list[@]}"
|
|
do
|
|
group_array=$(yunohost user group list --output-as json --quiet | jq -r --arg group "$group" ".groups.$group.members | @csv" | tr -d \")
|
|
IFS=',' read -r -a group_array <<< "$group_array"
|
|
user_list+=("${group_array[@]}")
|
|
done
|
|
|
|
for user in "${user_list[@]}"
|
|
do
|
|
mail=$(ynh_user_get_info --username="$user" --key=mail)
|
|
cd "$install_dir" && ynh_exec_as $app php$phpversion bin/console aeneria:user:deactivate "$mail" -n
|
|
done
|