1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mautrix_facebook_ynh.git synced 2024-09-03 19:36:33 +02:00

Merge pull request #5 from nathanael-h/testing

Changes to match the signal_ynh package
This commit is contained in:
tituspijean 2022-03-07 18:41:18 +01:00 committed by GitHub
commit d38351fe52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 288 additions and 182 deletions

View file

@ -4,11 +4,11 @@
;; Default test serie ;; Default test serie
; pre-install ; pre-install
sudo yunohost tools update apps sudo yunohost tools update apps
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force sudo yunohost app info synapse --quiet > /dev/null || sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force
; Manifest ; Manifest
port="8449" (PORT) port="8449" (PORT)
synapsenumber="1" synapsenumber="1"
whatsappbot="whatsappbot" botname="facebookbot"
bot_synapse_adm=0 bot_synapse_adm=0
encryption=0 encryption=0
botadmin="@johndoe:synapsedomain.tld" (USER) botadmin="@johndoe:synapsedomain.tld" (USER)

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/tulir/mautrix-facebook/archive/v0.3.0.tar.gz SOURCE_URL=https://github.com/tulir/mautrix-facebook/archive/v0.3.0.tar.gz
SOURCE_SUM=992e491a3e34bd42ddfba0b3aef7869a7a7c03171560783ec23a692d1f0d79a1 SOURCE_SUM=0b31c0a865d71bc76bed541ee8e57dd790a67197f62883032a7ae05b9658642b
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,14 +1,11 @@
# Homeserver details # Homeserver details
homeserver: homeserver:
# The address that this appservice can use to connect to the homeserver. # The address that this appservice can use to connect to the homeserver.
# address: https://example.com address: https://__DOMAIN__
address: __DOMAIN__
# The domain of the homeserver (for MXIDs, etc). # The domain of the homeserver (for MXIDs, etc).
# domain: example.com
domain: __SERVER_NAME__ domain: __SERVER_NAME__
# Whether or not to verify the SSL certificate of the homeserver. # Whether or not to verify the SSL certificate of the homeserver.
# Only applies if address starts with https:// # Only applies if address starts with https://
# verify_ssl: true
verify_ssl: __VERIFY_SERVER_SSL_CERTIFICATES__ verify_ssl: __VERIFY_SERVER_SSL_CERTIFICATES__
# Whether or not the homeserver supports asmux-specific endpoints, # Whether or not the homeserver supports asmux-specific endpoints,
# such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically # such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically
@ -20,21 +17,26 @@ homeserver:
# Changing these values requires regeneration of the registration. # Changing these values requires regeneration of the registration.
appservice: appservice:
# The address that the homeserver can use to connect to this appservice. # The address that the homeserver can use to connect to this appservice.
# address: http://localhost:29319
address: http://localhost:__PORT__ address: http://localhost:__PORT__
# When using https:// the TLS certificate and key files for the address.
tls_cert: false
tls_key: false
# The hostname and port where this appservice should listen. # The hostname and port where this appservice should listen.
# hostname: localhost
hostname: 0.0.0.0 hostname: 0.0.0.0
# port: 29319
port: __PORT__ port: __PORT__
# The maximum body size of appservice API requests (from the homeserver) in mebibytes # The maximum body size of appservice API requests (from the homeserver) in mebibytes
# Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s # Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s
max_body_size: 1 max_body_size: 1
# The full URI to the database. Only Postgres is currently supported. # The full URI to the database. Only Postgres is currently supported.
# database: postgres://username:password@hostname/db database: postgres://__MAUTRIX_BRIDGE_USER__:__MAUTRIX_BRIDGE_DB_PWD__@localhost:5432/__MAUTRIX_BRIDGE_DB_NAME__
database: postgres://__MAUTRIX_FACEBOOK_USER__:__MAUTRIX_FACEBOOK_DB_PWD__@localhost:5432/__MAUTRIX_FACEBOOK_DB_NAME__ # Additional arguments for asyncpg.create_pool()
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool
database_opts:
min_size: 5
max_size: 10
# Public part of web server for out-of-Matrix interaction with the bridge. # Public part of web server for out-of-Matrix interaction with the bridge.
public: public:
@ -51,17 +53,19 @@ appservice:
shared_secret: generate shared_secret: generate
# The unique ID of this appservice. # The unique ID of this appservice.
id: __FACEBOOKBOT__ id: __BOTNAME__
# Username of the appservice bot. # Username of the appservice bot.
bot_username: __FACEBOOKBOT__ bot_username: __BOTNAME__
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
# to leave display name/avatar as-is. # to leave display name/avatar as-is.
bot_displayname: FB bridge bot bot_displayname: FB bridge bot
bot_avatar: mxc://maunium.net/ygtkteZsXnGJLJHRchUwYWak bot_avatar: mxc://maunium.net/ygtkteZsXnGJLJHRchUwYWak
# Community ID for bridged users (changes registration file) and rooms. # Community ID for bridged users (changes registration file) and rooms.
# Must be created manually. Example: "+facebook:example.com" # Must be created manually.
community_id: null #
# Example: "+fb:example.com". Set to false to disable.
community_id: +fb:__SERVER_NAME__
# Whether or not to receive ephemeral events via appservice transactions. # Whether or not to receive ephemeral events via appservice transactions.
# Requires MSC2409 support (i.e. Synapse 1.22+). # Requires MSC2409 support (i.e. Synapse 1.22+).
@ -244,11 +248,11 @@ logging:
formatter: colored formatter: colored
loggers: loggers:
mau: mau:
level: DEBUG level: __LOG_LEVEL__
paho: paho:
level: INFO level: INFO
aiohttp: aiohttp:
level: INFO level: INFO
root: root:
level: DEBUG level: __LOG_LEVEL__
handlers: [file, console] handlers: [file, console]

View file

@ -7,7 +7,6 @@ Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/bin/python3 -m mautrix_facebook >> /var/log/__APP__/__APP__.log 2>&1 ExecStart=__FINALPATH__/bin/python3 -m mautrix_facebook
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide
1. *Read this whole template first.* 1. *Read this whole template first.*
2. *Determine if you are on the right place:* 2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to REPLACEBYYOURAPP itself. Refer to its documentation or repository for help.* - *Otherwise, the issue may be due to mautrix-facebook itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.* - *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.* 3. *Delete the italic comments as you write over them below, and remove this guide.*
--- ---
@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide
- *If you performed a command from the CLI, the command itself is enough. For example:* - *If you performed a command from the CLI, the command itself is enough. For example:*
```sh ```sh
sudo yunohost app install REPLACEBYYOURAPP sudo yunohost app install mautrix_facebook
``` ```
- *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:* - *If the error occurs in your browser, explain what you did:*

View file

@ -8,6 +8,12 @@
}, },
"version": "0.3.0~ynh1", "version": "0.3.0~ynh1",
"url": "https://github.com/tulir/mautrix-facebook", "url": "https://github.com/tulir/mautrix-facebook",
"upstream": {
"license": "AGPL-3.0-or-later",
"admindoc": "https://docs.mau.fi/bridges/python/setup/index.html?bridge=facebook",
"userdoc": "https://docs.mau.fi/bridges/python/facebook/index.html",
"code": "https://github.com/mautrix/facebook"
},
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {
"name": "Gredin67", "name": "Gredin67",
@ -15,7 +21,7 @@
"url": "https://github.com/YunoHost-Apps/mautrix_facebook_ynh" "url": "https://github.com/YunoHost-Apps/mautrix_facebook_ynh"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.0" "yunohost": ">= 4.1"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
@ -38,7 +44,7 @@
"default": "1" "default": "1"
}, },
{ {
"name": "facebookbot", "name": "botname",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose a local synapse user name for the Facebook bot", "en": "Choose a local synapse user name for the Facebook bot",

View file

@ -28,9 +28,34 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# language=$(ynh_app_setting_get --app=$app --key=language)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
port=$(ynh_app_setting_get --app=$app --key=port)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
# bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin)
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
mautrix_config_path="$final_path/config.yaml"
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -54,7 +79,7 @@ ynh_backup --src_path="$final_path"
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/var/log/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
@ -63,22 +88,11 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_backup --src_path="/etc/cron.d/$app" ynh_psql_dump_db --database="$mautrix_bridge_db_name" > ${YNH_CWD}/dump.sql
ynh_backup --src_path="/etc/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -25,7 +25,7 @@ ynh_abort_if_errors
#================================================= #=================================================
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
facebookbot=$YNH_APP_ARG_FACEBOOKBOT botname=$YNH_APP_ARG_BOTNAME
encryption=$YNH_APP_ARG_ENCRYPTION encryption=$YNH_APP_ARG_ENCRYPTION
botadmin=$YNH_APP_ARG_BOTADMIN botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS botusers=$YNH_APP_ARG_BOTUSERS
@ -53,11 +53,14 @@ synapse_db_user="matrix_$synapse_instance"
# SET CONSTANTS # SET CONSTANTS
#================================================= #=================================================
facebookbot_synapse_db_user="@$facebookbot:$server_name" botname_synapse_db_user="@$botname:$server_name"
mautrix_facebook_user=$app synapse_db_name="matrix_$synapse_instance"
mautrix_facebook_db_name=$app mautrix_bridge_user=$app
mautrix_facebook_db_user=$app mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version) upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
@ -71,9 +74,9 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..." --weight=1 ynh_script_progression --message="Configuring bridge port..." --weight=1
# Find a free port for communication between your local synapse instance (home server) and its app service mautrix_facebook. # Find a free port for communication between your local synapse instance (home server) and its app service mautrix_bridge.
port=$(ynh_find_port --port=8449) port=$(ynh_find_port --port=8449)
#================================================= #=================================================
@ -84,11 +87,11 @@ ynh_script_progression --message="Storing installation settings..." --weight=7
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=server_name --value=$server_name
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
ynh_app_setting_set --app=$app --key=facebookbot --value=$facebookbot ynh_app_setting_set --app=$app --key=botname --value=$botname
ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path
ynh_app_setting_set --app=$app --key=encryption --value=$encryption ynh_app_setting_set --app=$app --key=encryption --value=$encryption
ynh_app_setting_set --app=$app --key=mautrix_facebook_db_name --value=$mautrix_facebook_db_name ynh_app_setting_set --app=$app --key=mautrix_bridge_db_name --value=$mautrix_bridge_db_name
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
ynh_app_setting_set --app=$app --key=botusers --value=$botusers ynh_app_setting_set --app=$app --key=botusers --value=$botusers
ynh_app_setting_set --app=$app --key=mautrix_version --value=$upstream_version ynh_app_setting_set --app=$app --key=mautrix_version --value=$upstream_version
@ -114,18 +117,14 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3 ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
ynh_print_OFF mautrix_bridge_db_pwd=$(ynh_string_random --length=30)
mautrix_facebook_db_pwd=$(ynh_string_random --length=30) ynh_app_setting_set --app=$app --key=mautrix_bridge_db_pwd --value=$mautrix_bridge_db_pwd
ynh_app_setting_set --app=$app --key=mautrix_facebook_db_pwd --value=$mautrix_facebook_db_pwd
ynh_print_ON
# Create postgresql database # Create postgresql database
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
ynh_print_OFF ynh_psql_create_user $mautrix_bridge_db_user $mautrix_bridge_db_pwd
ynh_psql_create_user $mautrix_facebook_db_user $mautrix_facebook_db_pwd
ynh_print_ON
ynh_psql_execute_as_root \ ynh_psql_execute_as_root \
--sql="CREATE DATABASE ""$mautrix_facebook_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_facebook_db_user"";" --sql="CREATE DATABASE ""$mautrix_bridge_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_bridge_db_user"";"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -154,63 +153,46 @@ ynh_setup_source --dest_dir="$final_path/src"
ynh_script_progression --message="Configuring system user..." --weight=1 ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$mautrix_facebook_user ynh_system_user_create --username=$mautrix_bridge_user
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=20 ynh_script_progression --message="Configuring a systemd service..." --weight=20
# Create systemd config for mautrix-facebook # Create systemd config for Mautrix-Bridge
#cp ../conf/default_mautrix-facebook /etc/default/$app #cp ../conf/default_mautrix-facebook /etc/default/$app
ynh_add_systemd_config --service=$app ynh_add_systemd_config --service=$app
#================================================= #=================================================
#================================================= #=================================================
# SET MAUTRIX-FACEBOOK CONFIG # SET MAUTRIX-BRIDGE CONFIG
#================================================= #=================================================
ynh_script_progression --message="Configuring Mautrix-FB..." --weight=2 ynh_script_progression --message="Configuring Mautrix-Bridge..." --weight=2
# WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) # WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times)
# For any update do it in all files # For any update do it in all files
mautrix_config_path="$final_path/config.yaml" mautrix_config_path="$final_path/config.yaml"
#Copy example-config.yaml to config.yaml verify_server_ssl_certificates="true"
cp ../conf/config.yaml "$mautrix_config_path" matrix_server_supports_asmux="false"
log_filename="/var/log/$app/$app.log"
# https://docs.python.org/3.6/library/logging.html#logging-levels
log_level="INFO"
ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" --target_file="$mautrix_config_path" ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
ynh_replace_string --match_string=__SERVER_NAME__ --replace_string=$server_name --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__VERIFY_SERVER_SSL_CERTIFICATES__ --replace_string=true --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__MATRIX_SERVER_SUPPORTS_ASMUX__ --replace_string=false --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__MAUTRIX_FACEBOOK_USER__ --replace_string=$mautrix_facebook_user --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__MAUTRIX_FACEBOOK_DB_PWD__ --replace_string=$mautrix_facebook_db_pwd --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__MAUTRIX_FACEBOOK_DB_NAME__ --replace_string=$mautrix_facebook_db_name --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__FACEBOOKBOT__ --replace_string=$facebookbot --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__ENCRYPTION__ --replace_string=$encryption --target_file="$mautrix_config_path"
if [ "$botusers" = "local" ]
then
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$server_name --target_file="$mautrix_config_path"
else
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botusers --target_file="$mautrix_config_path"
fi
ynh_replace_string --match_string=__BOTADMIN__ --replace_string=$botadmin --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__LOG_FILENAME__ --replace_string="/var/log/$app/$app.log" --target_file="$mautrix_config_path"
# Options: debug, info, warn, error, fatal
ynh_replace_string --match_string=__LOG_LEVEL__ --replace_string="error" --target_file="$mautrix_config_path"
#================================================= #=================================================
# INSTALL MAUTRIX-FACEBOOK PYTHON MODULE # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
mkdir -p /var/log/$app mkdir -p /var/log/$app
# Configure Mautrix-Facebook # Configure Mautrix-Bridge
python3 -m venv $final_path python3 -m venv $final_path
$final_path/bin/pip3 install --upgrade setuptools wheel $final_path/bin/pip3 install --upgrade pip setuptools wheel
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
$final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml $final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
@ -240,12 +222,9 @@ ynh_store_file_checksum --file="$mautrix_config_path"
### Then, if write authorization is needed, any access should be given only to directories ### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization. ### that really need such authorization.
# Set permissions to app files
chown -R root: $final_path
# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE
# For any update do it in all files # For any update do it in all files
chown $mautrix_facebook_user:root -R $final_path chown $mautrix_bridge_user:root -R $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -254,14 +233,14 @@ ynh_script_progression --message="Configuring log rotation..." --weight=3
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile "/var/log/$app/$app.log" ynh_use_logrotate --logfile "/var/log/$app/$app.log"
chown $mautrix_facebook_user:root -R /var/log/$app chown $mautrix_bridge_user:root -R /var/log/$app
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
#yunohost service add $app --log "/var/log/$app/log.log" #yunohost service add $app --log "/var/log/$app/log.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added # if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description "$app daemon for bridging FB and Matrix messages" --log "/var/log/$app/$app.log" yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="$log_filename"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -275,7 +254,7 @@ sleep 30
# # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) # # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
# if [ "$bot_is_synapse_admin" = true ] # if [ "$bot_is_synapse_admin" = true ]
# then # then
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$facebookbot"";" 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 # #yunohost app action run $synapse_instance set_admin_user -a username=$facebookbot
# fi # fi
ynh_systemd_action --service_name=$app --action="restart" ynh_systemd_action --service_name=$app --action="restart"

View file

@ -12,26 +12,40 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=5 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# language=$(ynh_app_setting_get --app=$app --key=language)
server_name=$(ynh_app_setting_get --app=$app --key=server_name) server_name=$(ynh_app_setting_get --app=$app --key=server_name)
port=$(ynh_app_setting_get --app=$app --key=port)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
facebookbot=$(ynh_app_setting_get --app=$app --key=facebookbot) # bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin)
port=$(ynh_app_setting_get --app=$app --key=port) encryption=$(ynh_app_setting_get --app=$app --key=encryption)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
mautrix_config_path="$final_path/config.yaml"
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#================================================= #=================================================
# SET CONSTANTS # SET CONSTANTS
#================================================= #=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
facebookbot_synapse_db_user="@$facebookbot:$server_name" mautrix_bridge_user=$app
mautrix_facebook_user=$app mautrix_bridge_db_name=$app
mautrix_facebook_db_name=$app mautrix_bridge_db_user=$app
mautrix_facebook_db_user=$app upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -60,9 +74,11 @@ ynh_remove_systemd_config
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$mautrix_facebook_db_name --db_name=$mautrix_facebook_db_user ynh_psql_remove_db --db_user=$mautrix_bridge_db_name --db_name=$mautrix_bridge_db_user
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$facebookbot"";" ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$mautrix_bridge_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$facebookbot"";" ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$mautrix_bridge_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$botname"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$botname"";"
#yunohost app action run $synapse_instance drop_user -a username=$facebookbot #yunohost app action run $synapse_instance drop_user -a username=$facebookbot
#================================================= #=================================================
@ -79,7 +95,6 @@ ynh_remove_app_dependencies
ynh_script_progression --message="Removing app main directory..." --weight=1 ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
#ynh_secure_remove --file="/etc/$app/"
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
@ -112,10 +127,10 @@ ynh_secure_remove --file="/var/log/$app"
ynh_script_progression --message="Removing the dedicated system user..." --weight=5 ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$mautrix_facebook_user ynh_system_user_delete --username=$mautrix_bridge_user
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --time --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -24,23 +24,38 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) # language=$(ynh_app_setting_get --app=$app --key=language)
db_user=$db_name
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
mautrix_config_path="$final_path/config.yaml"
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -49,82 +64,106 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$mautrix_bridge_user
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
# Restore permissions on app files # Restore permissions on app files
chown -R root: $final_path chown $mautrix_bridge_user:root -R $final_path
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
ynh_psql_test_if_first_run
ynh_psql_create_user $mautrix_bridge_db_user $mautrix_bridge_db_pwd
ynh_psql_execute_as_root \
--sql="CREATE DATABASE ""$mautrix_bridge_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_bridge_db_user"";"
ynh_psql_execute_file_as_root --file="${YNH_CWD}/dump.sql" --database="$mautrix_bridge_db_name"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_restore_file --origin_path="/var/log/$app"
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql python3 -m venv $final_path
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
$final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_use_logrotate --logfile "/var/log/$app/$app.log"
chown $mautrix_bridge_user:root -R /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="$log_filename"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" # 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"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/$app/"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --time --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,16 +12,39 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language) # language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
port=$(ynh_app_setting_get --app=$app --key=port)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
# bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin)
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
mautrix_config_path="$final_path/config.yaml"
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -38,7 +61,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# #
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* # N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
@ -61,7 +84,7 @@ ynh_script_progression --message="Ensuring downward compatibility..." --time --w
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -77,9 +100,9 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 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" ynh_systemd_action --service_name=$app --action="stop" --log_path="$log_filename"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -87,34 +110,26 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --time --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path/src"
fi fi
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$mautrix_bridge_user
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --time --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -125,23 +140,48 @@ ynh_add_fpm_config
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# MODIFY A CONFIG FILE # SET MAUTRIX-BRIDGE CONFIG
#================================================= #=================================================
ynh_script_progression --message="Configuring Mautrix-Bridge..." --weight=2
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" ynh_backup_if_checksum_is_different --file="$app_service_registration_path/$app.yaml"
ynh_backup_if_checksum_is_different --file="$mautrix_config_path"
ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" verify_server_ssl_certificates="true"
matrix_server_supports_asmux="false"
# https://docs.python.org/3.6/library/logging.html#logging-levels
log_level="INFO"
ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/CONFIG_FILE" ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"
ynh_store_file_checksum --file="$mautrix_config_path"
#=================================================
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
#=================================================
ynh_script_progression --message="Upgrading Mautrix-Bridge..." --weight=2
mkdir -p /var/log/$app
# Configure Mautrix-Bridge
python3 -m venv $final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
$final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -150,32 +190,42 @@ ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
#================================================= #=================================================
# Set permissions on app files # Set permissions on app files
chown -R root: $final_path chown $mautrix_bridge_user:root -R $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --logfile "$log_filename"
chown $mautrix_bridge_user:root -R /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="$log_filename"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" # 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 # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --time --last ynh_script_progression --message="Upgrade of $app completed" --last