From b5d4e6dfc71af23044a92533af1098dc4dc405d1 Mon Sep 17 00:00:00 2001 From: ljf Date: Mon, 4 Sep 2023 16:06:35 +0200 Subject: [PATCH] [enh] Restore and access update --- hooks/post_app_addaccess | 29 +++++++++++++++++++++++++++++ hooks/post_app_removeaccess | 22 ++++++++++++++++++++++ hooks/post_app_restore | 8 ++++++++ 3 files changed, 59 insertions(+) create mode 100644 hooks/post_app_addaccess create mode 100644 hooks/post_app_removeaccess create mode 100644 hooks/post_app_restore diff --git a/hooks/post_app_addaccess b/hooks/post_app_addaccess new file mode 100644 index 0000000..9b5a189 --- /dev/null +++ b/hooks/post_app_addaccess @@ -0,0 +1,29 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers +app=$1 +install_dir=/var/www/chatonsinfos/ +service_path=${install_dir}public/${app}.properties +local groups_added=$4 +local app_info="$(yunohost app info $app --full --json)" +get_info() { + echo $app_info | jq -r ".$1" +} +if [[ "$groups_added" == *"visitors"* ]] +then + registration=$(ynh_read_var_in_file --file="$service_path" --key="service.registration") + local ldap="$(get_info 'manifest.integration.ldap')" + local sso="$(get_info 'manifest.integration.sso')" + if [[ "$registration" != "None" && "$registration" != "Free" ]] + then + if [[ "$ldap" == "not_relevant" && "$sso" == "not_relevant" ]] + then + registration="None" + elif [[ "$ldap" == "false" ]] + then + registration="Free" + fi + ynh_write_var_in_file --file="$service_path" --key="service.registration" --value="$registration" + fi +fi diff --git a/hooks/post_app_removeaccess b/hooks/post_app_removeaccess new file mode 100644 index 0000000..ec62a29 --- /dev/null +++ b/hooks/post_app_removeaccess @@ -0,0 +1,22 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers +app=$1 +install_dir=/var/www/chatonsinfos/ +service_path=${install_dir}public/${app}.properties +local groups_removed=$4 +local app_info="$(yunohost app info $app --full --json)" +get_info() { + echo $app_info | jq -r ".$1" +} +if [[ "$groups_removed" == *"visitors"* ]] +then + registration=$(ynh_read_var_in_file --file="$service_path" --key="service.registration") + local ldap="$(get_info 'manifest.integration.ldap')" + local sso="$(get_info 'manifest.integration.sso')" + if [[ "$registration" != "Member" && "$registration" != "Client" ]] + then + ynh_write_var_in_file --file="$service_path" --key="service.registration" --value="Member" + fi +fi diff --git a/hooks/post_app_restore b/hooks/post_app_restore new file mode 100644 index 0000000..085c37c --- /dev/null +++ b/hooks/post_app_restore @@ -0,0 +1,8 @@ +#!/bin/bash + +source /etc/yunohost/apps/chatonsinfos/scripts/_common.sh +source /usr/share/yunohost/helpers + +install_dir=/var/www/chatonsinfos/ +generate_config_panel +update_subs