mirror of
https://github.com/YunoHost-Apps/mautrix_facebook_ynh.git
synced 2024-09-03 19:36:33 +02:00
93 lines
3.7 KiB
Bash
Executable file
93 lines
3.7 KiB
Bash
Executable file
#!/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
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
#REMOVEME? db_user=$db_name
|
|
#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
|
#REMOVEME? botname=$(ynh_app_setting_get --app=$app --key=botname)
|
|
#REMOVEME? synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
|
synapse_db_name="matrix_$synapse_instance"
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
ynh_restore_file --origin_path="/var/log/$app/"
|
|
|
|
#=================================================
|
|
# RESTORE THE POSTGRESQL DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
|
|
|
|
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
|
|
|
#=================================================
|
|
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE
|
|
#=================================================
|
|
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
|
|
|
|
_mautrix_facebook_build_venv
|
|
|
|
#=================================================
|
|
# REGISTER SYNAPSE APP-SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
|
|
|
_mautrix_facebook_register_synapse
|
|
|
|
#=================================================
|
|
# 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 FB and Matrix messages" --log="/var/log/$app/$app.log"
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
|
|
# Wait until the synapse user is created
|
|
sleep 30
|
|
# # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
|
|
# if [ "$bot_is_synapse_admin" = true ]
|
|
# then
|
|
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = \"$botname\";"
|
|
# #yunohost app action run $synapse_instance set_admin_user -a username=$facebookbot
|
|
# fi
|
|
ynh_systemd_action --service_name="$app" --action="restart"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|