#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _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? botname=$(ynh_app_setting_get --app=$app --key=botname) #REMOVEME? encryption=$(ynh_app_setting_get --app=$app --key=encryption) #REMOVEME? botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) #REMOVEME? botusers=$(ynh_app_setting_get --app=$app --key=botusers) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #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? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) #REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name) synapse_registration_path="/etc/matrix-$synapse_instance/app-service" synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path) synapse_db_name="matrix_$synapse_instance" #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= # ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/src" --full_replace=1 chmod -R o-rwx "$install_dir" chown -R "$app:$app" "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating 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" #================================================= # UPGRADE MAUTRIX-BRIDGE PYTHON MODULE #================================================= ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2 _mautrix_facebook_build_venv #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= ynh_script_progression --message="Registering Synapse app-service" --weight=1 _mautrix_facebook_register_synapse #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading 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" # 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="Upgrade of $app completed" --last