mirror of
https://github.com/YunoHost-Apps/matrix-puppet-discord_ynh.git
synced 2024-09-03 19:36:25 +02:00
Attempt of a version including user config overrides
This commit is contained in:
parent
20bec238c9
commit
42941e7ba5
9 changed files with 104 additions and 49 deletions
|
@ -1,3 +1,7 @@
|
|||
# /!\ WARNING: DO NOT EDIT THIS FILE /!\
|
||||
# this file will be overridden anytime an upgrade or a restoration is performed
|
||||
# Please, edit the __USER_CONFIG_PATH__ file instead
|
||||
|
||||
bridge:
|
||||
# Port to host the bridge on
|
||||
# Used for communication between the homeserver and the bridge
|
||||
|
@ -51,48 +55,6 @@ presence:
|
|||
# How often to send status to the homeserver in milliseconds
|
||||
interval: 500
|
||||
|
||||
provisioning:
|
||||
# Regex of Matrix IDs allowed to use the puppet bridge
|
||||
whitelist:
|
||||
# Allow a specific user
|
||||
#- "@user:server\\.com"
|
||||
|
||||
# Allow users on a specific homeserver
|
||||
- "__ANY_ACCOUNT_OF_DOMAIN__"
|
||||
|
||||
# Allow anyone
|
||||
#- ".*"
|
||||
|
||||
# Regex of Matrix IDs forbidden from using the puppet bridge
|
||||
#blacklist:
|
||||
# Disallow a specific user
|
||||
#- "@user:server\\.com"
|
||||
|
||||
# Disallow users on a specific homeserver
|
||||
#- "@.*:server\\.com"
|
||||
|
||||
relay:
|
||||
# Regex of Matrix IDs who are allowed to use the bridge in relay mode.
|
||||
# Relay mode is when a single Discord bot account relays messages of
|
||||
# multiple Matrix users
|
||||
#
|
||||
# Same format as in provisioning
|
||||
whitelist:
|
||||
- "__ANY_ACCOUNT_OF_DOMAIN__"
|
||||
|
||||
#blacklist:
|
||||
#- "@user:yourserver\\.com"
|
||||
|
||||
selfService:
|
||||
# Regex of Matrix IDs who are allowed to use bridge self-servicing (plumbed rooms)
|
||||
#
|
||||
# Same format as in provisioning
|
||||
whitelist:
|
||||
- "__ANY_ACCOUNT_OF_DOMAIN__"
|
||||
|
||||
#blacklist:
|
||||
#- "@user:server\\.com"
|
||||
|
||||
# Map of homeserver URLs to their C-S API endpoint
|
||||
#
|
||||
# Useful for double-puppeting if .well-known is unavailable for some reason
|
||||
|
|
|
@ -9,7 +9,7 @@ Environment="__YNH_NODE_LOAD_PATH__"
|
|||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__FINALPATH__/
|
||||
ExecStart=__YNH_NPM__ start -- -f __FINALPATH__/__APP__.yaml
|
||||
ExecStart=__FINALPATH__/run.sh
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
|
||||
|
|
47
conf/user.config.yaml
Normal file
47
conf/user.config.yaml
Normal file
|
@ -0,0 +1,47 @@
|
|||
# You can edit this file.
|
||||
# This will override the configuration contained in the __FINALPATH__/base.config.yaml file.
|
||||
# Don't hesitate to take a look at __FINALPATH__/sample.config.yaml to see all the available options.
|
||||
# Then, in order to take into account the changes, run: systemctl restart __APP__
|
||||
|
||||
provisioning:
|
||||
# Regex of Matrix IDs allowed to use the puppet bridge
|
||||
whitelist:
|
||||
# Allow a specific user
|
||||
#- "@user:server\\.com"
|
||||
|
||||
# Allow users on a specific homeserver
|
||||
- "__ANY_ACCOUNT_OF_DOMAIN__"
|
||||
|
||||
# Allow anyone
|
||||
#- ".*"
|
||||
|
||||
# Regex of Matrix IDs forbidden from using the puppet bridge
|
||||
#blacklist:
|
||||
# Disallow a specific user
|
||||
#- "@user:server\\.com"
|
||||
|
||||
# Disallow users on a specific homeserver
|
||||
#- "@.*:server\\.com"
|
||||
|
||||
relay:
|
||||
# Regex of Matrix IDs who are allowed to use the bridge in relay mode.
|
||||
# Relay mode is when a single Discord bot account relays messages of
|
||||
# multiple Matrix users
|
||||
#
|
||||
# Same format as in provisioning
|
||||
whitelist:
|
||||
- "__ANY_ACCOUNT_OF_DOMAIN__"
|
||||
|
||||
#blacklist:
|
||||
#- "@user:yourserver\\.com"
|
||||
|
||||
selfService:
|
||||
# Regex of Matrix IDs who are allowed to use bridge self-servicing (plumbed rooms)
|
||||
#
|
||||
# Same format as in provisioning
|
||||
whitelist:
|
||||
- "__ANY_ACCOUNT_OF_DOMAIN__"
|
||||
|
||||
#blacklist:
|
||||
#- "@user:server\\.com"
|
||||
|
|
@ -31,3 +31,15 @@ setup_final_path_rights() {
|
|||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
}
|
||||
|
||||
setup_run_script_rights() {
|
||||
chmod 750 "$final_path/run.sh"
|
||||
chown "$app:$app" "$final_path/run.sh"
|
||||
}
|
||||
|
||||
create_etc() {
|
||||
local etc_path=$1
|
||||
mkdir -p -m 750 "$etc_path"
|
||||
chown "$app:$app" "$etc_path"
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
log_path=$(ynh_app_setting_get --app=$app --key=log_path)
|
||||
etc_path=$(ynh_app_setting_get --app=$app --key=etc_path)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -55,6 +56,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$log_path"
|
||||
ynh_backup --src="$etc_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
|
|
|
@ -43,6 +43,8 @@ domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
|||
app_service_registration_path="/etc/matrix-$synapse_instance/app-service"
|
||||
log_path="/var/log/$app"
|
||||
config_path="$final_path/config.yaml"
|
||||
base_config_path="$final_path/base.config.yaml"
|
||||
user_config_path="/etc/$app/user.config.yaml"
|
||||
|
||||
ynh_print_OFF
|
||||
db_password=$(ynh_string_random --length=30)
|
||||
|
@ -128,13 +130,27 @@ ynh_script_progression --message="Building Node dependencies..." --weight=30
|
|||
install_node_deps
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
# SETUP PIP (FOR YQ)
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||
|
||||
pip_path=$final_path/.pip
|
||||
python3 -m venv $pip_path
|
||||
$pip_path/bin/pip3 install yq
|
||||
|
||||
#=================================================
|
||||
# ADD CONFIGURATION FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding configuration files..." --weight=1
|
||||
|
||||
etc_path=$(dirname $user_config_path)
|
||||
ynh_app_setting_set --app=$app --key=etc_path --value=$etc_path
|
||||
create_etc "$etc_path"
|
||||
|
||||
any_account_of_domain="@.*:${domain//\./\\\\\.}"
|
||||
|
||||
# TODO Add a way to override the config.yaml file
|
||||
ynh_add_config --template="base.config.yaml" --destination="$config_path"
|
||||
ynh_add_config --template="base.config.yaml" --destination="$base_config_path"
|
||||
ynh_add_config --template="user.config.yaml" --destination="$user_config_path"
|
||||
|
||||
chmod 400 "$config_path"
|
||||
chown $app:$app "$config_path"
|
||||
|
@ -152,6 +168,10 @@ ynh_store_file_checksum --file="$config_path"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||
|
||||
# Create startup script
|
||||
ynh_add_config --template="../sources/extra_files/app/run.sh" --destination="$final_path/run.sh"
|
||||
setup_run_script_rights
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
|
@ -179,7 +199,6 @@ cp "$final_path/$app.yaml" $app_service_registration_path/$app.yaml
|
|||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|
||||
|| ynh_die "Synapse can't restart with the appservice configuration"
|
||||
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
|
|
@ -94,6 +94,9 @@ log_path=$(ynh_app_setting_get --app=$app --key=log_path)
|
|||
ynh_restore_file --origin_path="$log_path"
|
||||
chown $app:$app "$log_path"
|
||||
|
||||
etc_path=$(ynh_app_setting_get --app=$app --key=etc_path)
|
||||
ynh_restore_file --origin_path="$etc_path"
|
||||
|
||||
#=================================================
|
||||
# REGISTER SYNAPSE APP-SERVICE
|
||||
#=================================================
|
||||
|
@ -108,6 +111,8 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
|
|||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
setup_run_script_rights
|
||||
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
|
|
10
sources/extra_files/app/run.sh
Normal file
10
sources/extra_files/app/run.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo <<EOF > __CONFIG_PATH__
|
||||
# /!\ FILE GENERATED AUTOMATICALLY BEFORE EACH SERVICE RESTART
|
||||
# CONSIDER EDITING /etc/__APP__/user.config.yaml
|
||||
EOF
|
||||
|
||||
__PIP_PATH__/bin/yq -y -s '.[0] * .[1]' __FINALPATH__/base.config.yaml /etc/__APP__/user.config.yaml > __CONFIG_PATH__
|
||||
|
||||
__YNH_NPM__ start -- -c __CONFIG_PATH__ -f __APP__.yaml
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
Loading…
Reference in a new issue