From 3526c4a3ddb63bb5232ad2d622051df6d451026f Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Mon, 5 Apr 2021 13:28:00 +0200 Subject: [PATCH] improve backup and install scripts --- conf/config.yaml | 4 ++-- scripts/backup | 13 +++++++++++-- scripts/install | 9 +++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index 37556f1..ed6ac92 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -78,8 +78,8 @@ appservice: ephemeral_events: false # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. - as_token: "This value is generated when generating the registration" - hs_token: "This value is generated when generating the registration" + as_token: __AS_TOKEN__ + hs_token: __HS_TOKEN__ # Prometheus telemetry config. Requires prometheus-client to be installed. metrics: diff --git a/scripts/backup b/scripts/backup index f35b565..27c175a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -30,9 +30,16 @@ app=$YNH_APP_INSTANCE_NAME 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) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) + +# synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) +# mautrix_bridge_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_name) +# mautrix_bridge_db_user=$app +# mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd) +# mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd) + #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -47,6 +54,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= +# includes config file ynh_backup --src_path="$final_path" #================================================= @@ -67,7 +75,8 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP VARIOUS FILES #================================================= -# ynh_backup --src_path="/etc/$app/" +# backup synapse registration file +ynh_backup --src_path="$app_service_registration_path" #================================================= # BACKUP THE PostrgeSQL DATABASE diff --git a/scripts/install b/scripts/install index 1c90ed8..2f855e7 100755 --- a/scripts/install +++ b/scripts/install @@ -85,7 +85,6 @@ port=$(ynh_find_port --port=29317) # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." --weight=7 - ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=port --value=$port @@ -93,7 +92,8 @@ ynh_app_setting_set --app=$app --key=botname --value=$botname ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path ynh_app_setting_set --app=$app --key=encryption --value=$encryption -ynh_app_setting_set --app=$app --key=mautrix_bridge_db_name --value=$mautrix_bridge_db_name ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin +ynh_app_setting_set --app=$app --key=mautrix_bridge_db_name --value=$mautrix_bridge_db_name +ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin ynh_app_setting_set --app=$app --key=botusers --value=$botusers ynh_app_setting_set --app=$app --key=apiid --value=$apiid @@ -189,6 +189,7 @@ mautrix_config_path="$final_path/config.yaml" #Copy example-config.yaml to config.yaml cp ../conf/config.yaml "$mautrix_config_path" + ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" --target_file="$mautrix_config_path" ynh_replace_string --match_string=__SERVER_NAME__ --replace_string=$server_name --target_file="$mautrix_config_path" ynh_replace_string --match_string=__VERIFY_SERVER_SSL_CERTIFICATES__ --replace_string=true --target_file="$mautrix_config_path" @@ -215,6 +216,10 @@ ynh_replace_string --match_string=__TELEGRAM_API_ID__ --replace_string=$apiid -- ynh_replace_string --match_string=__TELEGRAM_API_HASH__ --replace_string=$apihash --target_file="$mautrix_config_path" ynh_replace_string --match_string=__TELEGRAM_BOT_TOKEN__ --replace_string=$bottoken --target_file="$mautrix_config_path" +generated="\"This value is generated when generating the registration\"" +ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$generated" --target_file="$mautrix_config_path" +ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$generated" --target_file="$mautrix_config_path" + #================================================= # INSTALL MAUTRIX-BRIDGE PYTHON MODULE