From 03b279dd91672b9422d3a9aa7e3cbacc1e9c44cf Mon Sep 17 00:00:00 2001 From: Gredin 67 Date: Sat, 23 Jan 2021 01:00:48 +0100 Subject: [PATCH] adapt install and config files --- conf/app.src | 8 ++++---- scripts/config.yaml | 18 +++++++++--------- scripts/install | 33 +++++++++------------------------ 3 files changed, 22 insertions(+), 37 deletions(-) diff --git a/conf/app.src b/conf/app.src index 17489bf..3006c28 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ -SOURCE_URL=url of app's source -SOURCE_SUM=sha256 checksum +SOURCE_URL=https://github.com/tulir/mautrix-facebook/tarball/7b2246099d3d6ac52061f82315460415eb22219b +SOURCE_SUM=fd9d4f2b2feec390fb35b56f3a5e4a26234f9ed5029eb3950bea4b7dc55bef49 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true +SOURCE_FILENAME=mautrix-facebook +SOURCE_EXTRACT=false diff --git a/scripts/config.yaml b/scripts/config.yaml index c5e7d25..ce9d9ab 100644 --- a/scripts/config.yaml +++ b/scripts/config.yaml @@ -34,7 +34,7 @@ appservice: # The full URI to the database. Only Postgres is currently supported. # database: postgres://username:password@hostname/db - database: postgres://__MAUTRIX_FACEBOOK_DB_USER__:__MAUTRIX_FACEBOOK_DB_PWD__@localhost:5432/__MAUTRIX_FACEBOOK_DB_NAME__ + database: postgres://__MAUTRIX_FACEBOOK_USER__:__MAUTRIX_FACEBOOK_DB_PWD__@localhost:5432/__MAUTRIX_FACEBOOK_DB_NAME__ # Public part of web server for out-of-Matrix interaction with the bridge. public: @@ -51,12 +51,12 @@ appservice: shared_secret: generate # The unique ID of this appservice. - id: facebook + id: __FACEBOOKBOT__ # Username of the appservice bot. - bot_username: facebookbot + bot_username: __FACEBOOKBOT__ # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty # to leave display name/avatar as-is. - bot_displayname: Facebook bridge bot + bot_displayname: FB bridge bot bot_avatar: mxc://maunium.net/ygtkteZsXnGJLJHRchUwYWak # Community ID for bridged users (changes registration file) and rooms. @@ -81,7 +81,7 @@ metrics: bridge: # Localpart template of MXIDs for Facebook users. # {userid} is replaced with the user ID of the Facebook user. - username_template: "facebook_{userid}" + username_template: "fb_{userid}" # Localpart template for per-user room grouping community IDs. # The bridge will create these communities and add all of the specific user's portals to the community. # {localpart} is the MXID localpart and {server} is the MXID server part of the user. @@ -122,7 +122,7 @@ bridge: sync_direct_chat_list: false # Servers to always allow double puppeting from double_puppet_server_map: - example.com: https://example.com + example.com: https://__BOTUSERS__ # Allow using double puppeting from any server with a valid client .well-known file. double_puppet_allow_discovery: false # Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth @@ -217,8 +217,8 @@ bridge: # domain - All users on that homeserver # mxid - Specific user permissions: - "example.com": "user" - "@admin:example.com": "admin" + "__BOTUSERS__": "user" + "__BOTADMIN__": "admin" # Python logging configuration. # @@ -236,7 +236,7 @@ logging: file: class: logging.handlers.RotatingFileHandler formatter: normal - filename: ./mautrix-facebook.log + filename: __LOG_FILENAME__ maxBytes: 10485760 backupCount: 10 console: diff --git a/scripts/install b/scripts/install index 88c19e3..cbb56ac 100755 --- a/scripts/install +++ b/scripts/install @@ -172,13 +172,7 @@ ynh_add_systemd_config --service=$app #================================================= # SET MAUTRIX-FACEBOOK CONFIG #================================================= -ynh_script_progression --message="Configuring Mautrix-Facebook..." --weight=2 - -# Configure Mautrix-Facebook -python3 -m venv $final_path - -pip install --upgrade mautrix-facebook - +ynh_script_progression --message="Configuring Mautrix-FB..." --weight=2 # WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) # For any update do it in all files @@ -190,6 +184,8 @@ cp ../conf/config.yaml "$mautrix_config_path" ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" --target_file="$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" @@ -205,27 +201,16 @@ 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=__ENABLE_RELAYBOT__ --replace_string="true" --target_file="$mautrix_config_path" -ynh_replace_string --match_string=__RELAYBOT_MANAGEMENT_ROOM__ --replace_string="highwaytohell" --target_file="$mautrix_config_path" -ynh_replace_string --match_string=__RELAYBOT_INVITE__ --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_FORMAT__ --replace_string="log.log" --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" -#cd $final_path -#Generate the appservice registration file by running ./mautrix-facebook -g. - #You can use the -c and -r flags to change the location of the config and registration files. They default to config.yaml and registration.yaml respectively. -#mkdir -p $app_service_registration_path +# Configure Mautrix-Facebook +python3 -m venv $final_path +pip install --upgrade ./mautrix-facebook.tar.gz python -m $final_path/mautrix-facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml -#Add the path to the registration file (registration.yaml by default) to your synapse homeserver.yaml under app_service_config_files. -#cd $base_directory -#cp ../conf/$app.yaml $app_service_registration_path -#$as_token=; -#$hs_token=; -#ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$as_token" --target_file=$app_service_registration_path/$app.yaml -#ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$hs_token" --target_file=$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 @@ -265,7 +250,7 @@ chown $mautrix_facebook_user:root -R $final_path ynh_script_progression --message="Configuring log rotation..." --weight=3 # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile "/var/log/$app/log.log" +ynh_use_logrotate --logfile "/var/log/$app/$app.log" chown $mautrix_facebook_user:root -R /var/log/$app #================================================= @@ -273,7 +258,7 @@ chown $mautrix_facebook_user:root -R /var/log/$app #================================================= #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 -yunohost service add $app --description "$app daemon for bridging Facebook and Matrix messages" --log "/var/log/$app/log.log" +yunohost service add $app --description "$app daemon for bridging FB and Matrix messages" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE