2021-01-04 12:14:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
mautrix_version=$(ynh_app_upstream_version)
|
2024-04-24 20:13:20 +02:00
|
|
|
synapse_db_name="$(get_synapse_db_name $synapse_instance)"
|
2022-01-25 09:49:10 +01:00
|
|
|
bot_synapse_db_user="@$botname:$server_name"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-09-04 22:28:27 +02:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
2022-09-04 22:28:27 +02:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
|
2022-09-04 22:28:27 +02:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
2022-09-04 22:28:27 +02:00
|
|
|
|
2022-09-05 00:02:24 +02:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
# RESTORE VARIOUS FILES
|
2022-09-05 00:02:24 +02:00
|
|
|
#=================================================
|
|
|
|
|
2024-04-09 22:42:50 +02:00
|
|
|
# TODO: check if there are some files to restore
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_restore_file --origin_path="/var/log/$app/"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2021-06-22 18:28:47 +02:00
|
|
|
# REGISTER SYNAPSE APP-SERVICE
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2022-09-04 23:58:20 +02:00
|
|
|
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2024-04-09 22:42:50 +02:00
|
|
|
$install_dir/mautrix-signal -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
|
|
|
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
|
|
|
|
|
2024-06-11 20:24:23 +02:00
|
|
|
chown -R $app:$app "$install_dir/config.yaml"
|
2024-04-09 22:42:50 +02:00
|
|
|
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
|
|
|
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
2024-02-26 13:49:53 +01:00
|
|
|
systemctl enable "$app.service" --quiet
|
|
|
|
yunohost service add "$app" --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log"
|
2021-06-22 18:28:47 +02:00
|
|
|
|
2022-09-04 23:58:20 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
2021-06-22 18:28:47 +02:00
|
|
|
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2022-01-25 09:49:10 +01:00
|
|
|
# START SYSTEMD SERVICE
|
2021-01-04 12:14:25 +01:00
|
|
|
#=================================================
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
2021-01-04 12:14:25 +01:00
|
|
|
|
2022-09-04 23:58:20 +02:00
|
|
|
# Start a systemd service
|
2024-02-26 13:49:53 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
2024-04-27 16:55:48 +02:00
|
|
|
# Update bot admin status
|
|
|
|
set_bot_admin_status
|
2021-01-04 12:14:25 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-01-25 09:49:10 +01:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|