2021-09-11 16:08:56 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
|
|
|
|
#=================================================
|
2024-03-29 15:26:17 +01:00
|
|
|
# REINSTALL DEPENDENCIES
|
2021-09-11 16:08:56 +02:00
|
|
|
#=================================================
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_script_progression --message="Reinstalling NodeJS..." --weight=4
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
|
|
|
|
ynh_use_nodejs
|
2021-09-11 16:08:56 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2021-09-12 14:49:16 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:$app" "$install_dir"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-09-12 14:49:16 +02:00
|
|
|
# RESTORE THE POSTGRESQL DATABASE
|
2021-09-11 16:08:56 +02:00
|
|
|
#=================================================
|
2022-09-05 21:45:47 +02:00
|
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=20
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
2021-09-11 16:08:56 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE VARIOUS FILES
|
|
|
|
#=================================================
|
2021-09-12 14:49:16 +02:00
|
|
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_restore_file --origin_path="/var/log/$app"
|
|
|
|
chown "$app:$app" "/var/log/$app"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2021-09-12 20:03:12 +02:00
|
|
|
ynh_restore_file --origin_path="$etc_path"
|
2024-03-29 15:26:17 +01:00
|
|
|
|
|
|
|
chown "$app:$app" "$etc_path"
|
2021-09-12 20:43:14 +02:00
|
|
|
chmod 600 "$etc_path/user.config.yaml"
|
2021-09-12 20:03:12 +02:00
|
|
|
|
2021-09-12 14:49:16 +02:00
|
|
|
#=================================================
|
|
|
|
# REGISTER SYNAPSE APP-SERVICE
|
|
|
|
#=================================================
|
2022-09-05 21:45:47 +02:00
|
|
|
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
cp "$install_dir/$app.yaml" "$app_service_registration_path/$app.yaml"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" \
|
|
|
|
|| ynh_die --message="Synapse can't restart with the appservice configuration"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-29 15:26:17 +01:00
|
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
2021-09-11 16:08:56 +02:00
|
|
|
#=================================================
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
|
|
systemctl enable "$app.service" --quiet
|
|
|
|
yunohost service add "$app" --description="$app daemon for bridging Discord and Matrix messages"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
2021-09-11 16:08:56 +02:00
|
|
|
|
2024-03-29 15:26:17 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="start"
|
2021-09-11 16:08:56 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-09-12 14:49:16 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|