diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..a2ce821 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,16 @@ +version = "1.0" + +[main] +name = "Mautrix Signal configuration" + + [main.encryption] + name = "Manage encryption" + + [main.encryption.allowed] + ask = "Do you want to allow the use of encrypted room with Mautrix Signal Bridge? " + type = "bololean" + optional = false + default = "0" + help = "Allow encryption, work in group chat rooms with e2ee enabled" + +# TODO: Add toggle for enabling and enforcing encyption \ No newline at end of file diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..9fe7f52 --- /dev/null +++ b/scripts/config @@ -0,0 +1,65 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +encryption_allowed=$(ynh_app_setting_get --app=$app --key=encryption_allowed) + +#================================================= +# SPECIFIC GETTERS FOR TOML SHORT KEY +#================================================= + +get__encryption_allowed() { + # Maintenance mode status + if [ $encryption_allowed -eq "1" ] + then + echo "1" + else + echo "0" + fi +} + +#================================================= +# SPECIFIC VALIDATORS FOR TOML SHORT KEYS +#================================================= + +#================================================= +# SPECIFIC SETTERS FOR TOML SHORT KEYS +#================================================= + +set__encryption_allowed() { + if [ "$encryption_allowed" -eq "1" ]; then + # If encryption_allowed was set to 1, enable maintenance mode + (cd "$final_path" && ynh_exec_as "$app" \ + echo "Site under maintenance." > .maintenance) + ynh_print_info "Maintenance mode disabled" + elif [ "$encryption_allowed" -eq "0" ]; then + # If encryption_allowed was set to 0, disable maintenance mode + ynh_secure_remove --file=$final_path/.maintenance + ynh_print_info "Maintenance mode enabled" + fi + ynh_app_setting_set --app=$app --key=encryption_allowed --value="$encryption_allowed" +} + +#================================================= +# GENERIC FINALIZATION +#================================================= + +ynh_app_config_apply() { + _ynh_app_config_apply + +} + +ynh_app_config_ run $1 \ No newline at end of file