Просмотр исходного кода

Add mautrix-amp role

pull/871/head
root 5 лет назад
Родитель
Сommit
dd0581fef4
13 измененных файлов: 608 добавлений и 0 удалений
  1. +46
    -0
      group_vars/matrix_servers
  2. +104
    -0
      roles/matrix-bridge-mautrix-amp/defaults/main.yml
  3. +16
    -0
      roles/matrix-bridge-mautrix-amp/tasks/init.yml
  4. +21
    -0
      roles/matrix-bridge-mautrix-amp/tasks/main.yml
  5. +80
    -0
      roles/matrix-bridge-mautrix-amp/tasks/setup_install.yml
  6. +45
    -0
      roles/matrix-bridge-mautrix-amp/tasks/setup_uninstall.yml
  7. +13
    -0
      roles/matrix-bridge-mautrix-amp/tasks/validate_config.yml
  8. +170
    -0
      roles/matrix-bridge-mautrix-amp/templates/config.yaml.j2
  9. +6
    -0
      roles/matrix-bridge-mautrix-amp/templates/puppeteer-config.yaml.j2
  10. +17
    -0
      roles/matrix-bridge-mautrix-amp/templates/registration.yaml.j2
  11. +42
    -0
      roles/matrix-bridge-mautrix-amp/templates/systemd/matrix-mautrix-amp-puppeteer.service.j2
  12. +47
    -0
      roles/matrix-bridge-mautrix-amp/templates/systemd/matrix-mautrix-amp.service.j2
  13. +1
    -0
      setup.yml

+ 46
- 0
group_vars/matrix_servers Просмотреть файл

@@ -182,6 +182,46 @@ matrix_appservice_irc_database_password: "{{ matrix_synapse_macaroon_secret_key
######################################################################


######################################################################
#
# matrix-bridge-mautrix-amp
#
######################################################################

# We don't enable bridges by default.
matrix_mautrix_amp_enabled: false

matrix_mautrix_amp_systemd_required_services_list: |
{{
['docker.service']
+
(['matrix-synapse.service'] if matrix_synapse_enabled else [])
+
(['matrix-postgres.service'] if matrix_postgres_enabled else [])
+
['matrix-mautrix-amp-puppeteer.service']
}}

matrix_mautrix_amp_homeserver_domain: '{{ matrix_domain }}'

matrix_mautrix_amp_homeserver_address: "{{ 'http://matrix-synapse:8008' if matrix_synapse_enabled else '' }}"

matrix_mautrix_amp_homeserver_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'amp.hs.token') | to_uuid }}"

matrix_mautrix_amp_appservice_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'amp.as.token') | to_uuid }}"

matrix_mautrix_amp_login_shared_secret: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret if matrix_synapse_ext_password_provider_shared_secret_auth_enabled else '' }}"

matrix_mautrix_amp_database_engine: 'postgres'
matrix_mautrix_amp_database_password: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'mau.amp.db') | to_uuid }}"

######################################################################
#
# /matrix-bridge-mautrix-amp
#
######################################################################


######################################################################
#
# matrix-bridge-mautrix-facebook
@@ -1105,6 +1145,12 @@ matrix_postgres_additional_databases: |
'password': matrix_appservice_irc_database_password,
}] if (matrix_appservice_irc_enabled and matrix_appservice_irc_database_engine == 'postgres' and matrix_appservice_irc_database_hostname == 'matrix-postgres') else [])
+
([{
'name': matrix_mautrix_amp_database_name,
'username': matrix_mautrix_amp_database_username,
'password': matrix_mautrix_amp_database_password,
}] if (matrix_mautrix_amp_enabled and matrix_mautrix_amp_database_engine == 'postgres' and matrix_mautrix_amp_database_hostname == 'matrix-postgres') else [])
+
([{
'name': matrix_mautrix_facebook_database_name,
'username': matrix_mautrix_facebook_database_username,


+ 104
- 0
roles/matrix-bridge-mautrix-amp/defaults/main.yml Просмотреть файл

@@ -0,0 +1,104 @@
# mautrix-amp is a Matrix <-> SMS bridge
# See: https://mau.dev/tulir/mautrix-amp

matrix_mautrix_amp_enabled: true

# This bridge only supports a single user.
matrix_mautrix_amp_bridge_user: ''

# See: https://mau.dev/tulir/mautrix-amp/container_registry
matrix_mautrix_amp_docker_image: "dock.mau.dev/tulir/mautrix-amp:latest"
matrix_mautrix_amp_docker_image_force_pull: "{{ matrix_mautrix_amp_docker_image.endswith(':latest') }}"

matrix_mautrix_amp_puppeteer_docker_image: "dock.mau.dev/tulir/mautrix-amp/puppeteer:latest"
matrix_mautrix_amp_puppeteer_docker_image_force_pull: "{{ matrix_mautrix_amp_puppeteer_docker_image.endswith(':latest') }}"

matrix_mautrix_amp_base_path: "{{ matrix_base_data_path }}/mautrix-amp"
matrix_mautrix_amp_config_path: "{{ matrix_mautrix_amp_base_path }}/config"
matrix_mautrix_amp_puppeteer_path: "{{ matrix_mautrix_amp_base_path }}/puppeteer"

matrix_mautrix_amp_homeserver_address: ''
matrix_mautrix_amp_homeserver_domain: ''
matrix_mautrix_amp_appservice_address: 'http://matrix-mautrix-amp:29394'

# Controls whether the matrix-mautrix-amp container exposes its port (tcp/29394 in the container).
#
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:9006"), or empty string to not expose.
matrix_mautrix_amp_container_http_host_bind_port: ''

# A list of extra arguments to pass to the container
matrix_mautrix_amp_container_extra_arguments: []

# List of systemd services that matrix-mautrix-amp.service depends on.
matrix_mautrix_amp_systemd_required_services_list:
- 'docker.service'
- 'matrix-mautrix-amp-puppeteer.service'

# List of systemd services that matrix-mautrix-amp.service wants
matrix_mautrix_amp_systemd_wanted_services_list: []

# List of systemd services that matrix-mautrix-amp-puppeteer.service depends on.
matrix_mautrix_amp_puppeteer_systemd_required_services_list: ['docker.service']

# List of systemd services that matrix-mautrix-amp-puppeteer.service wants
matrix_mautrix_amp_puppeteer_systemd_wanted_services_list: []

matrix_mautrix_amp_appservice_token: ''
matrix_mautrix_amp_homeserver_token: ''

matrix_mautrix_amp_appservice_bot_username: ampbot

# Database-related configuration fields
#
# This bridge only supports postgres.
#
matrix_mautrix_amp_database_engine: 'postgres'

matrix_mautrix_amp_database_username: 'matrix_mautrix_amp'
matrix_mautrix_amp_database_password: 'some-password'
matrix_mautrix_amp_database_hostname: 'matrix-postgres'
matrix_mautrix_amp_database_port: 5432
matrix_mautrix_amp_database_name: 'matrix_mautrix_amp'

matrix_mautrix_amp_database_connection_string: 'postgres://{{ matrix_mautrix_amp_database_username }}:{{ matrix_mautrix_amp_database_password }}@{{ matrix_mautrix_amp_database_hostname }}:{{ matrix_mautrix_amp_database_port }}/{{ matrix_mautrix_amp_database_name }}'

matrix_mautrix_amp_appservice_database: "{{
{
'postgres': matrix_mautrix_amp_database_connection_string,
}[matrix_mautrix_amp_database_engine]
}}"

# Can be set to enable automatic double-puppeting via Shared Secret Auth (https://github.com/devture/matrix-synapse-shared-secret-auth).
matrix_mautrix_amp_login_shared_secret: ''

# Default configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it.
#
# For a more advanced customization, you can extend the default (see `matrix_mautrix_amp_configuration_extension_yaml`)
# or completely replace this variable with your own template.
matrix_mautrix_amp_configuration_yaml: "{{ lookup('template', 'templates/config.yaml.j2') }}"

matrix_mautrix_amp_configuration_extension_yaml: |
# Your custom YAML configuration goes here.
# This configuration extends the default starting configuration (`matrix_mautrix_amp_configuration_yaml`).
#
# You can override individual variables from the default configuration, or introduce new ones.
#
# If you need something more special, you can take full control by
# completely redefining `matrix_mautrix_amp_configuration_yaml`.

matrix_mautrix_amp_configuration_extension: "{{ matrix_mautrix_amp_configuration_extension_yaml|from_yaml if matrix_mautrix_amp_configuration_extension_yaml|from_yaml is mapping else {} }}"

# Holds the final configuration (a combination of the default and its extension).
# You most likely don't need to touch this variable. Instead, see `matrix_mautrix_amp_configuration_yaml`.
matrix_mautrix_amp_configuration: "{{ matrix_mautrix_amp_configuration_yaml|from_yaml|combine(matrix_mautrix_amp_configuration_extension, recursive=True) }}"

matrix_mautrix_amp_registration_yaml: "{{ lookup('template', 'templates/registration.yaml.j2') }}"

matrix_mautrix_amp_registration: "{{ matrix_mautrix_amp_registration_yaml|from_yaml }}"

matrix_mautrix_amp_puppeteer_config_yaml: "{{ lookup('template', 'templates/puppeteer-config.yaml.j2') }}"

matrix_mautrix_amp_puppeteer_config: "{{ matrix_mautrix_amp_puppeteer_config_yaml|from_yaml }}"

matrix_mautrix_amp_log_level: 'DEBUG'

+ 16
- 0
roles/matrix-bridge-mautrix-amp/tasks/init.yml Просмотреть файл

@@ -0,0 +1,16 @@
- set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-amp.service', 'matrix-mautrix-amp-puppeteer.service'] }}"
when: matrix_mautrix_amp_enabled|bool

# If the matrix-synapse role is not used, these variables may not exist.
- set_fact:
matrix_synapse_container_extra_arguments: >
{{ matrix_synapse_container_extra_arguments|default([]) }}
+
["--mount type=bind,src={{ matrix_mautrix_amp_config_path }}/registration.yaml,dst=/matrix-mautrix-amp-registration.yaml,ro"]

matrix_synapse_app_service_config_files: >
{{ matrix_synapse_app_service_config_files|default([]) }}
+
{{ ["/matrix-mautrix-amp-registration.yaml"] }}
when: matrix_mautrix_amp_enabled|bool

+ 21
- 0
roles/matrix-bridge-mautrix-amp/tasks/main.yml Просмотреть файл

@@ -0,0 +1,21 @@
- import_tasks: "{{ role_path }}/tasks/init.yml"
tags:
- always

- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
when: "run_setup|bool and matrix_mautrix_amp_enabled|bool"
tags:
- setup-all
- setup-mautrix-amp

- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
when: "run_setup|bool and matrix_mautrix_amp_enabled|bool"
tags:
- setup-all
- setup-mautrix-amp

- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
when: "run_setup|bool and not matrix_mautrix_amp_enabled|bool"
tags:
- setup-all
- setup-mautrix-amp

+ 80
- 0
roles/matrix-bridge-mautrix-amp/tasks/setup_install.yml Просмотреть файл

@@ -0,0 +1,80 @@
---

# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed
fail:
msg: >-
The matrix-bridge-mautrix-amp role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)"

- name: Ensure Mautrix Amp image is pulled
docker_image:
name: "{{ matrix_mautrix_amp_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_mautrix_amp_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_amp_docker_image_force_pull }}"
when: matrix_mautrix_amp_enabled|bool

- name: Ensure Mautrix Amp Puppeteer image is pulled
docker_image:
name: "{{ matrix_mautrix_amp_puppeteer_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_mautrix_amp_puppeteer_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_amp_puppeteer_docker_image_force_pull }}"
when: matrix_mautrix_amp_enabled|bool

- name: Ensure Mautrix Amp paths exist
file:
path: "{{ item }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- "{{ matrix_mautrix_amp_base_path }}"
- "{{ matrix_mautrix_amp_config_path }}"
- "{{ matrix_mautrix_amp_puppeteer_path }}"

- name: Ensure mautrix-amp-puppeteer config.json installed
copy:
content: "{{ matrix_mautrix_amp_puppeteer_config|to_nice_json }}"
dest: "{{ matrix_mautrix_amp_puppeteer_path }}/config.json"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

- name: Ensure mautrix-amp config.yaml installed
copy:
content: "{{ matrix_mautrix_amp_configuration|to_nice_yaml }}"
dest: "{{ matrix_mautrix_amp_config_path }}/config.yaml"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

- name: Ensure mautrix-amp registration.yaml installed
copy:
content: "{{ matrix_mautrix_amp_registration|to_nice_yaml }}"
dest: "{{ matrix_mautrix_amp_config_path }}/registration.yaml"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

- name: Ensure matrix-mautrix-amp-puppeteer.service installed
template:
src: "{{ role_path }}/templates/systemd/matrix-mautrix-amp-puppeteer.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-mautrix-amp-puppeteer.service"
mode: 0644
register: matrix_mautrix_amp_puppeteer_systemd_service_result

- name: Ensure matrix-mautrix-amp.service installed
template:
src: "{{ role_path }}/templates/systemd/matrix-mautrix-amp.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-mautrix-amp.service"
mode: 0644
register: matrix_mautrix_amp_systemd_service_result

- name: Ensure systemd reloaded after matrix-mautrix-amp.service installation
service:
daemon_reload: yes
when: "matrix_mautrix_amp_systemd_service_result.changed or matrix_mautrix_amp_puppeteer_systemd_service_result.changed"

+ 45
- 0
roles/matrix-bridge-mautrix-amp/tasks/setup_uninstall.yml Просмотреть файл

@@ -0,0 +1,45 @@
---

# Amp puppeteer service
- name: Check existence of matrix-mautrix-amp-puppeteer service
stat:
path: "{{ matrix_systemd_path }}/matrix-mautrix-amp-puppeteer.service"
register: matrix_mautrix_amp_puppeteer_service_stat

- name: Ensure matrix-mautrix-amp-puppeteer is stopped
service:
name: matrix-mautrix-amp-puppeteer
state: stopped
daemon_reload: yes
when: "matrix_mautrix_amp_puppeteer_service_stat.stat.exists"

- name: Ensure matrix-mautrix-amp-puppeteer.service doesn't exist
file:
path: "{{ matrix_systemd_path }}/matrix-mautrix-amp-puppeteer.service"
state: absent
when: "matrix_mautrix_amp_puppeteer_service_stat.stat.exists"

# Bridge service
- name: Check existence of matrix-mautrix-amp service
stat:
path: "{{ matrix_systemd_path }}/matrix-mautrix-amp.service"
register: matrix_mautrix_amp_service_stat

- name: Ensure matrix-mautrix-amp is stopped
service:
name: matrix-mautrix-amp
state: stopped
daemon_reload: yes
when: "matrix_mautrix_amp_service_stat.stat.exists"

- name: Ensure matrix-mautrix-amp.service doesn't exist
file:
path: "{{ matrix_systemd_path }}/matrix-mautrix-amp.service"
state: absent
when: "matrix_mautrix_samp_service_stat.stat.exists"

# All services
- name: Ensure systemd reloaded after matrix-mautrix-amp.service removal
service:
daemon_reload: yes
when: "matrix_mautrix_amp_service_stat.stat.exists or matrix_mautrix_amp_puppeteer_service_stat.stat.exists"

+ 13
- 0
roles/matrix-bridge-mautrix-amp/tasks/validate_config.yml Просмотреть файл

@@ -0,0 +1,13 @@
---

- name: Fail if required settings not defined
fail:
msg: >-
You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''"
with_items:
- "matrix_mautrix_amp_bridge_user"
- "matrix_mautrix_amp_homeserver_domain"
- "matrix_mautrix_amp_homeserver_address"
- "matrix_mautrix_amp_homeserver_token"
- "matrix_mautrix_amp_appservice_token"

+ 170
- 0
roles/matrix-bridge-mautrix-amp/templates/config.yaml.j2 Просмотреть файл

@@ -0,0 +1,170 @@
# Homeserver details
homeserver:
# The address that this appservice can use to connect to the homeserver.
address: {{ matrix_mautrix_amp_homeserver_address }}
# The domain of the homeserver (for MXIDs, etc).
domain: {{ matrix_mautrix_amp_homeserver_domain }}
# Whether or not to verify the SSL certificate of the homeserver.
# Only applies if address starts with https://
verify_ssl: true

# Application service host/registration related details
# Changing these values requires regeneration of the registration.
appservice:
# The address that the homeserver can use to connect to this appservice.
address: {{ matrix_mautrix_amp_appservice_address }}
# 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.
hostname: 0.0.0.0
port: 29394
# 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
max_body_size: 1

# The full URI to the database. Only Postgres is currently supported.
database: {{ matrix_mautrix_amp_database_connection_string }}

# Provisioning API part of the web server for automated portal creation and fetching information.
# Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager).
provisioning:
# Whether or not the provisioning API should be enabled.
enabled: true
# The prefix to use in the provisioning API endpoints.
prefix: /_matrix/provision/v1
# The shared secret to authorize users of the API.
# Set to "generate" to generate and save a new token.
shared_secret: generate

# The unique ID of this appservice.
id: amp
# Username of the appservice bot.
bot_username: {{ matrix_mautrix_amp_appservice_bot_username|to_json }}
# 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: Android Messages bridge bot
bot_avatar: mxc://maunium.net/VuvevQiMRlOxuBVMBNEZZrxi

# Community ID for bridged users (changes registration file) and rooms.
# Must be created manually.
#
# Example: "+amp:example.com". Set to false to disable.
community_id: false

# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
as_token: "{{ matrix_mautrix_amp_appservice_token }}"
hs_token: "{{ matrix_mautrix_amp_homeserver_token }}"

# Prometheus telemetry config. Requires prometheus-client to be installed.
metrics:
enabled: false
listen_port: 8000

# Bridge config
bridge:
# Localpart template of MXIDs for remote users.
# {userid} is replaced with the user ID (phone or name converted into a mxid-friendly format).
username_template: "amp_{userid}"
# Displayname template for remote users.
# {displayname} is replaced with the display name of the user.
# {phone} is replaced with the phone number or name of the user.
displayname_template: "{displayname} (SMS)"

# Maximum length of displayname
displayname_max_length: 100

# Number of conversations to sync (and create portals for) on login.
# Set 0 to disable automatic syncing.
initial_conversation_sync: 10
# Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth
#
# If set, custom puppets will be enabled automatically for local users
# instead of users having to find an access token and run `login-matrix`
# manually.
login_shared_secret: null
# Whether or not created rooms should have federation enabled.
# If false, created portal rooms will never be federated.
federate_rooms: true
# Settings for backfilling messages from the Messages app.
backfill:
# If using double puppeting, should notifications be disabled
# while the initial backfill is in progress?
disable_notifications: false
# End-to-bridge encryption support options. These require matrix-nio to be installed with pip
# and login_shared_secret to be configured in order to get a device for the bridge bot.
#
# Additionally, https://github.com/matrix-org/synapse/pull/5758 is required if using a normal
# application service.
encryption:
# Allow encryption, work in group chat rooms with e2ee enabled
allow: false
# Default to encryption, force-enable encryption in all portals the bridge creates
# This will cause the bridge bot to be in private chats for the encryption to work properly.
default: false
# Options for automatic key sharing.
key_sharing:
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
# You must use a client that supports requesting keys from other users to use this feature.
allow: false
# Require the requesting device to have a valid cross-signing signature?
# This doesn't require that the bridge has verified the device, only that the user has verified it.
# Not yet implemented.
require_cross_signing: false
# Require devices to be verified by the bridge?
# Verification by the bridge is not yet implemented.
require_verification: true
# Whether or not to explicitly set the avatar and room name for private
# chat portal rooms. This will be implicitly enabled if encryption.default is true.
private_chat_portal_meta: false
# Whether or not the bridge should send a read receipt from the bridge bot when a message has
# been sent.
delivery_receipts: false
# Whether or not delivery errors should be reported as messages in the Matrix room.
delivery_error_reports: false
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
# This field will automatically be changed back to false after it,
# except if the config file is not writable.
resend_bridge_info: false

# The prefix for commands. Only required in non-management rooms.
command_prefix: "!am"

# This bridge only supports a single user
user: "{{ matrix_mautrix_amp_bridge_user }}"

puppeteer:
connection:
# Either unix or tcp
type: unix
# Only for type: unix
path: /puppeteer/puppet.sock
# Only for type: tcp
host: localhost
port: 29395

# Python logging configuration.
#
# See section 16.7.2 of the Python documentation for more info:
# https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema
logging:
version: 1
formatters:
colored:
(): mautrix_amp.util.ColorFormatter
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
normal:
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
handlers:
console:
class: logging.StreamHandler
formatter: colored
loggers:
mau:
level: {{ matrix_mautrix_amp_log_level }}
aiohttp:
level: INFO
root:
level: {{ matrix_mautrix_amp_log_level }}
handlers: [console]

+ 6
- 0
roles/matrix-bridge-mautrix-amp/templates/puppeteer-config.yaml.j2 Просмотреть файл

@@ -0,0 +1,6 @@
listen:
type: unix
path: "/puppeteer/puppet.sock"
profile_dir: "./profiles"
disable_debug: true
url: https://messages.google.com/web/

+ 17
- 0
roles/matrix-bridge-mautrix-amp/templates/registration.yaml.j2 Просмотреть файл

@@ -0,0 +1,17 @@
#jinja2: lstrip_blocks: "True"
id: amp
as_token: "{{ matrix_mautrix_amp_appservice_token }}"
hs_token: "{{ matrix_mautrix_amp_homeserver_token }}"
namespaces:
users:
- exclusive: true
regex: '^@amp_.+:{{ matrix_mautrix_amp_homeserver_domain|regex_escape }}$'
- exclusive: true
regex: '^@{{ matrix_mautrix_amp_appservice_bot_username|regex_escape }}:{{ matrix_mautrix_amp_homeserver_domain|regex_escape }}$'
aliases:
- exclusive: true
regex: '^#amp_.+:{{ matrix_mautrix_amp_homeserver_domain|regex_escape }}$'
url: {{ matrix_mautrix_amp_appservice_address }}
# See https://github.com/tulir/mautrix-signal/issues/43
sender_localpart: _bot_{{ matrix_mautrix_amp_appservice_bot_username }}
rate_limited: false

+ 42
- 0
roles/matrix-bridge-mautrix-amp/templates/systemd/matrix-mautrix-amp-puppeteer.service.j2 Просмотреть файл

@@ -0,0 +1,42 @@
#jinja2: lstrip_blocks: "True"
[Unit]
Description=Matrix Mautrix Amp puppeteer

{% for service in matrix_mautrix_amp_puppeteer_systemd_required_services_list %}
Requires={{ service }}
After={{ service }}
{% endfor %}

{% for service in matrix_mautrix_amp_puppeteer_systemd_wanted_services_list %}
Wants={{ service }}
{% endfor %}

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"

ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-mautrix-amp-puppeteer 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-mautrix-amp-puppeteer 2>/dev/null'

# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre={{ matrix_host_command_sleep }} 5

# We can't use `--read-only` for this bridge.
ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-mautrix-amp-puppeteer \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
--network={{ matrix_docker_network }} \
-v {{ matrix_mautrix_amp_puppeteer_path }}:/puppeteer:z \
{{ matrix_mautrix_amp_puppeteer_docker_image }} \
yarn start --config /puppeteer/config.json --browser /usr/lib/chromium/chrome --no-sandbox

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-mautrix-amp-puppeteer 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-mautrix-amp-puppeteer 2>/dev/null'

Restart=always
RestartSec=30
SyslogIdentifier=matrix-mautrix-amp-puppeteer

[Install]
WantedBy=multi-user.target

+ 47
- 0
roles/matrix-bridge-mautrix-amp/templates/systemd/matrix-mautrix-amp.service.j2 Просмотреть файл

@@ -0,0 +1,47 @@
#jinja2: lstrip_blocks: "True"
[Unit]
Description=Matrix Mautrix Amp server

{% for service in matrix_mautrix_amp_systemd_required_services_list %}
Requires={{ service }}
After={{ service }}
{% endfor %}

{% for service in matrix_mautrix_amp_systemd_wanted_services_list %}
Wants={{ service }}
{% endfor %}

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-mautrix-amp 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-mautrix-amp 2>/dev/null'

# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre={{ matrix_host_command_sleep }} 5

ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-mautrix-amp \
--log-driver=none \
--network={{ matrix_docker_network }} \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
{% if matrix_mautrix_amp_container_http_host_bind_port %}
-p {{ matrix_mautrix_amp_container_http_host_bind_port }}:29394 \
{% endif %}
-v {{ matrix_mautrix_amp_config_path }}:/config:z \
-v {{ matrix_mautrix_amp_puppeteer_path }}:/puppeteer:z \
{% for arg in matrix_mautrix_amp_container_extra_arguments %}
{{ arg }} \
{% endfor %}
{{ matrix_mautrix_amp_docker_image }} \
python3 -m mautrix_amp -c /config/config.yaml --no-update

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-mautrix-amp 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-mautrix-amp 2>/dev/null'

Restart=always
RestartSec=30
SyslogIdentifier=matrix-mautrix-amp

[Install]
WantedBy=multi-user.target

+ 1
- 0
setup.yml Просмотреть файл

@@ -13,6 +13,7 @@
- matrix-bridge-appservice-slack
- matrix-bridge-appservice-webhooks
- matrix-bridge-appservice-irc
- matrix-bridge-mautrix-amp
- matrix-bridge-mautrix-facebook
- matrix-bridge-mautrix-hangouts
- matrix-bridge-mautrix-signal


Загрузка…
Отмена
Сохранить