#!/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 #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling NodeJS..." --weight=4 ynh_install_nodejs --nodejs_version="$NODEJS_VERSION" ynh_use_nodejs #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:$app" "$install_dir" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=20 ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= # RESTORE VARIOUS FILES #================================================= ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/var/log/$app" chown "$app:$app" "/var/log/$app" ynh_restore_file --origin_path="$etc_path" chown "$app:$app" "$etc_path" chmod 600 "$etc_path/user.config.yaml" #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= ynh_script_progression --message="Registering Synapse app-service" --weight=1 cp "$install_dir/$app.yaml" "$app_service_registration_path/$app.yaml" "/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" \ || ynh_die --message="Synapse can't restart with the appservice configuration" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 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" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="start" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Restoration completed for $app" --last