Several fixes

This commit is contained in:
Florent 2021-09-12 20:43:14 +02:00 committed by Florent F
parent 42941e7ba5
commit 3531b8484c
8 changed files with 23 additions and 24 deletions

View file

@ -9,7 +9,7 @@ Environment="__YNH_NODE_LOAD_PATH__"
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/run.sh ExecStart=__FINALPATH__/run.sh -f __APP__.yaml
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog

View file

@ -10,7 +10,7 @@ provisioning:
#- "@user:server\\.com" #- "@user:server\\.com"
# Allow users on a specific homeserver # Allow users on a specific homeserver
- "__ANY_ACCOUNT_OF_DOMAIN__" - '__ANY_ACCOUNT_OF_DOMAIN__'
# Allow anyone # Allow anyone
#- ".*" #- ".*"
@ -30,7 +30,7 @@ relay:
# #
# Same format as in provisioning # Same format as in provisioning
whitelist: whitelist:
- "__ANY_ACCOUNT_OF_DOMAIN__" - '__ANY_ACCOUNT_OF_DOMAIN__'
#blacklist: #blacklist:
#- "@user:yourserver\\.com" #- "@user:yourserver\\.com"
@ -40,7 +40,7 @@ selfService:
# #
# Same format as in provisioning # Same format as in provisioning
whitelist: whitelist:
- "__ANY_ACCOUNT_OF_DOMAIN__" - '__ANY_ACCOUNT_OF_DOMAIN__'
#blacklist: #blacklist:
#- "@user:server\\.com" #- "@user:server\\.com"

View file

@ -22,7 +22,7 @@ install_node_deps() {
run_registration() { run_registration() {
pushd "$final_path" pushd "$final_path"
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production npm run start -- -r -c $config_path -f "$app.yaml" ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production $final_path/run.sh -r -f "$app.yaml"
popd popd
} }
@ -42,4 +42,3 @@ create_etc() {
mkdir -p -m 750 "$etc_path" mkdir -p -m 750 "$etc_path"
chown "$app:$app" "$etc_path" chown "$app:$app" "$etc_path"
} }

View file

@ -56,7 +56,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
ynh_backup --src_path="$log_path" ynh_backup --src_path="$log_path"
ynh_backup --src="$etc_path" ynh_backup --src_path="$etc_path"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE

View file

@ -42,7 +42,6 @@ server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
domain=$(ynh_app_setting_get --app $synapse_instance --key domain) domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
app_service_registration_path="/etc/matrix-$synapse_instance/app-service" app_service_registration_path="/etc/matrix-$synapse_instance/app-service"
log_path="/var/log/$app" log_path="/var/log/$app"
config_path="$final_path/config.yaml"
base_config_path="$final_path/base.config.yaml" base_config_path="$final_path/base.config.yaml"
user_config_path="/etc/$app/user.config.yaml" user_config_path="/etc/$app/user.config.yaml"
@ -146,14 +145,16 @@ etc_path=$(dirname $user_config_path)
ynh_app_setting_set --app=$app --key=etc_path --value=$etc_path ynh_app_setting_set --app=$app --key=etc_path --value=$etc_path
create_etc "$etc_path" create_etc "$etc_path"
any_account_of_domain="@.*:${domain//\./\\\\\.}" any_account_of_domain="@.*:${domain//\./\\\.}"
# TODO Add a way to override the config.yaml file # TODO Add a way to override the config.yaml file
ynh_add_config --template="base.config.yaml" --destination="$base_config_path" ynh_add_config --template="base.config.yaml" --destination="$base_config_path"
ynh_add_config --template="user.config.yaml" --destination="$user_config_path" ynh_add_config --template="user.config.yaml" --destination="$user_config_path"
chmod 400 "$config_path" chmod 400 "$base_config_path"
chown $app:$app "$config_path" chown $app:$app "$base_config_path"
chmod 600 "$user_config_path"
chown $app:$app "$user_config_path"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
@ -161,7 +162,10 @@ chown $app:$app "$config_path"
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml" ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"
ynh_store_file_checksum --file="$config_path"
# Probably not worth anymore, because the overrides should
# be now in $user_config_path
# ynh_store_file_checksum --file="$base_config_path"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -199,15 +203,6 @@ cp "$final_path/$app.yaml" $app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration" || ynh_die "Synapse can't restart with the appservice configuration"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"
ynh_store_file_checksum --file="$config_path"
#================================================= #=================================================
# SEND A README FOR THE ADMIN # SEND A README FOR THE ADMIN
#================================================= #=================================================

View file

@ -22,6 +22,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
log_path=$(ynh_app_setting_get --app=$app --key=log_path) log_path=$(ynh_app_setting_get --app=$app --key=log_path)
etc_path=$(ynh_app_setting_get --app=$app --key=etc_path)
ynh_print_OFF ynh_print_OFF
db_password=$(ynh_string_random --length=30) db_password=$(ynh_string_random --length=30)
@ -93,6 +94,7 @@ ynh_script_progression --message="Removing various files..." --weight=1
# Remove the log files # Remove the log files
ynh_secure_remove --file="$log_path" ynh_secure_remove --file="$log_path"
ynh_secure_remove --file="$etc_path"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -96,6 +96,9 @@ chown $app:$app "$log_path"
etc_path=$(ynh_app_setting_get --app=$app --key=etc_path) etc_path=$(ynh_app_setting_get --app=$app --key=etc_path)
ynh_restore_file --origin_path="$etc_path" ynh_restore_file --origin_path="$etc_path"
chown $app:$app "$etc_path"
chmod 600 "$etc_path/user.config.yaml"
chown $app:$app "$etc_path/user.config.yaml"
#================================================= #=================================================
# REGISTER SYNAPSE APP-SERVICE # REGISTER SYNAPSE APP-SERVICE

View file

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
echo <<EOF > __CONFIG_PATH__ echo <<EOF > __FINALPATH__/config.yaml
# /!\ FILE GENERATED AUTOMATICALLY BEFORE EACH SERVICE RESTART # /!\ FILE GENERATED AUTOMATICALLY BEFORE EACH SERVICE RESTART
# CONSIDER EDITING /etc/__APP__/user.config.yaml # CONSIDER EDITING /etc/__APP__/user.config.yaml
EOF EOF
__PIP_PATH__/bin/yq -y -s '.[0] * .[1]' __FINALPATH__/base.config.yaml /etc/__APP__/user.config.yaml > __CONFIG_PATH__ __PIP_PATH__/bin/yq -y -s '.[0] * .[1]' __FINALPATH__/base.config.yaml /etc/__APP__/user.config.yaml > __FINALPATH__/config.yaml
__YNH_NPM__ start -- -c __CONFIG_PATH__ -f __APP__.yaml __YNH_NPM__ start -- -c config.yaml $@