mirror of
https://github.com/YunoHost-Apps/mautrix_telegram_ynh.git
synced 2024-09-03 19:45:55 +02:00
improve restore script
This commit is contained in:
parent
f695024b60
commit
e579544bf9
5 changed files with 25 additions and 20 deletions
|
@ -6,7 +6,7 @@
|
|||
"en": "A Telegram puppeting bridge for Matrix/Synapse.",
|
||||
"fr": "Passerelle Telegram pour Matrix/Synapse."
|
||||
},
|
||||
"version": "0.10.1~ynh1",
|
||||
"version": "0.10.1~ynh2",
|
||||
"url": "https://github.com/mautrix/telegram",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"maintainer": {
|
||||
|
|
|
@ -16,25 +16,15 @@ write_bridge_config () {
|
|||
domain="https://$domain"
|
||||
if [ "$botusers" = "local" ]
|
||||
then
|
||||
# ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$server_name --target_file="$mautrix_config_path"
|
||||
botusers="$server_name"
|
||||
# else
|
||||
# ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botusers --target_file="$mautrix_config_path"
|
||||
fi
|
||||
# ynh_replace_string --match_string=__VERIFY_SERVER_SSL_CERTIFICATES__ --replace_string=true --target_file="$mautrix_config_path"
|
||||
verify_server_ssl_certificates="true"
|
||||
# ynh_replace_string --match_string=__MATRIX_SERVER_SUPPORTS_ASMUX__ --replace_string=false --target_file="$mautrix_config_path"
|
||||
matrix_server_supports_asmux="false"
|
||||
# ynh_replace_string --match_string=__LOG_FILENAME__ --replace_string="/var/log/$app/$app.log" --target_file="$mautrix_config_path"
|
||||
log_filename="/var/log/$app/$app.log"
|
||||
# TODO rename these settings
|
||||
# ynh_replace_string --match_string=__TELEGRAM_API_ID__ --replace_string=$apiid --target_file="$mautrix_config_path"
|
||||
# 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"
|
||||
telegram_api_id="$apiid"
|
||||
telegram_api_hash="$apihash"
|
||||
telegram_bot_token="$bottoken"
|
||||
# ynh_replace_string --match_string=__LOG_LEVEL__ --replace_string="error" --target_file="$mautrix_config_path"
|
||||
log_level="error"
|
||||
ynh_add_config --template="config.yaml" --destination="$mautrix_config_path"
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ ynh_script_progression --message="Configuring log rotation..." --weight=3
|
|||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
# TODO maybe --specific-user??
|
||||
ynh_use_logrotate --logfile "/var/log/$app/$app.log"
|
||||
ynh_use_logrotate --logfile "/var/log/$app/$app.log" --specific-user $mautrix_bridge_user
|
||||
chown $mautrix_bridge_user:root -R /var/log/$app
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -36,6 +36,7 @@ mautrix_bridge_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_
|
|||
mautrix_bridge_db_user=$mautrix_bridge_db_name
|
||||
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
|
||||
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)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -115,21 +116,34 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="$app_service_registration_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="$app_service_registration_path"
|
||||
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
#
|
||||
# also create an initial log file else the service fails
|
||||
mkdir /var/log/$app
|
||||
mkdir /var/log/$app/$app.log
|
||||
chown $mautrix_bridge_user:root -R /var/log/$app
|
||||
|
||||
# after restoring files ensure synapse knows about the bot but don't die on failure
|
||||
# TODO check (in manifest?) if the selected synapse instance is not already connected to a mautrix_bridge bridge
|
||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|
||||
|| echo "Synapse can't restart with the appservice configuration"
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -25,6 +25,7 @@ app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service
|
|||
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
||||
mautrix_bridge_user=$app
|
||||
mautrix_bridge_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_name)
|
||||
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
|
||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
|
||||
|
||||
|
@ -151,8 +152,8 @@ ynh_add_systemd_config
|
|||
mautrix_config_path="$final_path/config.yaml"
|
||||
ynh_backup_if_checksum_is_different --file="$mautrix_config_path"
|
||||
# as_token hs_token are autogenerated, save them before regenerating the config
|
||||
as_token=$(grep as_token "$mautrix_config_path" | sed "s/ *as_token: *//")
|
||||
hs_token=$(grep hs_token "$mautrix_config_path" | sed "s/ *hs_token: *//")
|
||||
as_token=$(grep "as_token:" "$mautrix_config_path" | sed -r "s/ *as_token: *//")
|
||||
hs_token=$(grep "hs_token:" "$mautrix_config_path" | sed -r "s/ *hs_token: *//")
|
||||
# ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$as_token" --target_file="$mautrix_config_path"
|
||||
# ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$hs_token" --target_file="$mautrix_config_path"
|
||||
write_bridge_config
|
||||
|
|
Loading…
Add table
Reference in a new issue