mirror of
https://github.com/YunoHost-Apps/mautrix_facebook_ynh.git
synced 2024-09-03 19:36:33 +02:00
101 lines
3.9 KiB
Bash
Executable file
101 lines
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_facebook bridge
|
|
if [ $synapsenumber -eq "1" ]
|
|
then
|
|
synapse_instance="synapse"
|
|
else
|
|
synapse_instance="synapse__$synapsenumber"
|
|
fi
|
|
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
|
|
domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
|
synapse_registration_path="/etc/matrix-$synapse_instance/app-service"
|
|
synapse_db_name="matrix_$synapse_instance"
|
|
|
|
ynh_app_setting_set --app="$app" --key="encryption" --value="$encryption"
|
|
ynh_app_setting_set --app="$app" --key="synapse_instance" --value="$synapse_instance"
|
|
ynh_app_setting_set --app="$app" --key="server_name" --value="$server_name"
|
|
ynh_app_setting_set --app="$app" --key="domain" --value="$domain"
|
|
ynh_app_setting_set --app="$app" --key="synapse_registration_path" --value="$synapse_registration_path"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=3
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir/src"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:$app" "$install_dir"
|
|
|
|
mkdir -p /var/log/$app
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
|
|
|
ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
|
|
|
|
chmod 400 "$install_dir/config.yaml"
|
|
chown "$app:$app" "$install_dir/config.yaml"
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
yunohost service add "$app" --description="$app daemon for bridging FB and Matrix messages" --log="/var/log/$app/$app.log"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate --logfile "/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# 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="Installation of $app completed" --last
|