bundles/mautrix-whatsapp: introduce
This commit is contained in:
parent
4a3cee1623
commit
fede30c2cc
7 changed files with 277 additions and 4 deletions
|
@ -35,6 +35,7 @@ Rule of thumb: keep ports below 10000 free for stuff that reserves ports.
|
||||||
| 11332-11334 | rspamd | rspamd |
|
| 11332-11334 | rspamd | rspamd |
|
||||||
| 20000 | mx-puppet-discord | Bridge |
|
| 20000 | mx-puppet-discord | Bridge |
|
||||||
| 20010 | mautrix-telegram | Bridge |
|
| 20010 | mautrix-telegram | Bridge |
|
||||||
|
| 20020 | mautrix-whatsapp | Bridge |
|
||||||
| 20080 | matrix-synapse | client, federation |
|
| 20080 | matrix-synapse | client, federation |
|
||||||
| 20081 | matrix-synapse | prometheus metrics |
|
| 20081 | matrix-synapse | prometheus metrics |
|
||||||
| 22000 | gitea | gitea |
|
| 22000 | gitea | gitea |
|
||||||
|
|
108
bundles/mautrix-whatsapp/files/config.yaml
Normal file
108
bundles/mautrix-whatsapp/files/config.yaml
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
homeserver:
|
||||||
|
address: ${node.metadata['mautrix-whatsapp']['homeserver']['url']}
|
||||||
|
domain: ${node.metadata['mautrix-whatsapp']['homeserver']['domain']}
|
||||||
|
|
||||||
|
appservice:
|
||||||
|
address: http://${node.metadata['mautrix-whatsapp'].get('listen-addr', '127.0.0.1')}:${node.metadata['mautrix-whatsapp'].get('port', 20020)}
|
||||||
|
hostname: ${node.metadata['mautrix-whatsapp'].get('listen-addr', '127.0.0.1')}
|
||||||
|
port: ${node.metadata['mautrix-whatsapp'].get('port', 20020)}
|
||||||
|
database:
|
||||||
|
type: postgres
|
||||||
|
uri: postgres://${node.metadata['mautrix-whatsapp']['database']['user']}:${node.metadata['mautrix-whatsapp']['database']['password']}@${node.metadata['mautrix-whatsapp']['database'].get('host', 'localhost')}/${node.metadata['mautrix-whatsapp']['database']['database']}
|
||||||
|
max_open_conns: 20
|
||||||
|
max_idle_conns: 2
|
||||||
|
provisioning:
|
||||||
|
prefix: /_matrix/provision/v1
|
||||||
|
% if node.metadata['mautrix-whatsapp']['provisioning']['enabled']:
|
||||||
|
shared_secret: ${node.metadata['mautrix-whatsapp']['provisioning']['shared_secret']}
|
||||||
|
% else:
|
||||||
|
shared_secret: disable
|
||||||
|
% endif
|
||||||
|
id: whatsapp
|
||||||
|
bot:
|
||||||
|
username: whatsappbot
|
||||||
|
displayname: WhatsApp bridge bot
|
||||||
|
avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
|
||||||
|
as_token: ${node.metadata['mautrix-whatsapp']['as_token']}
|
||||||
|
hs_token: ${node.metadata['mautrix-whatsapp']['hs_token']}
|
||||||
|
|
||||||
|
metrics:
|
||||||
|
enabled: false
|
||||||
|
listen: 127.0.0.1:8001
|
||||||
|
|
||||||
|
whatsapp:
|
||||||
|
os_name: Mautrix-WhatsApp bridge
|
||||||
|
browser_name: mx-wa
|
||||||
|
|
||||||
|
bridge:
|
||||||
|
username_template: whatsapp_{{.}}
|
||||||
|
displayname_template: "{{if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WhatsApp)"
|
||||||
|
community_template: whatsapp_{{.Localpart}}={{.Server}}
|
||||||
|
connection_timeout: 20
|
||||||
|
fetch_message_on_timeout: false
|
||||||
|
delivery_receipts: true
|
||||||
|
login_qr_regen_count: 2
|
||||||
|
max_connection_attempts: 3
|
||||||
|
connection_retry_delay: -1
|
||||||
|
report_connection_retry: true
|
||||||
|
chat_list_wait: 30
|
||||||
|
portal_sync_wait: 600
|
||||||
|
user_message_buffer: 1024
|
||||||
|
portal_message_buffer: 128
|
||||||
|
call_notices:
|
||||||
|
start: true
|
||||||
|
end: true
|
||||||
|
initial_chat_sync_count: 20
|
||||||
|
initial_history_fill_count: 50
|
||||||
|
initial_history_disable_notifications: false
|
||||||
|
recovery_chat_sync_limit: -1
|
||||||
|
recovery_history_backfill: true
|
||||||
|
sync_max_chat_age: ${node.metadata['mautrix-whatsapp'].get('sync_max_days', 7)*24*60*60}
|
||||||
|
sync_with_custom_puppets: true
|
||||||
|
sync_direct_chat_list: false
|
||||||
|
default_bridge_receipts: true
|
||||||
|
default_bridge_presence: true
|
||||||
|
login_shared_secret: null
|
||||||
|
invite_own_puppet_for_backfilling: true
|
||||||
|
private_chat_portal_meta: false
|
||||||
|
resend_bridge_info: false
|
||||||
|
whatsapp_thumbnail: false
|
||||||
|
allow_user_invite: false
|
||||||
|
command_prefix: "!wa"
|
||||||
|
encryption:
|
||||||
|
allow: false # requires login_shared_secret to be set
|
||||||
|
default: false
|
||||||
|
key_sharing:
|
||||||
|
allow: false
|
||||||
|
require_cross_signing: false
|
||||||
|
require_verification: true
|
||||||
|
permissions:
|
||||||
|
% for user, permission in node.metadata['mautrix-whatsapp']['permissions'].items():
|
||||||
|
${user}: ${permission}
|
||||||
|
% endfor
|
||||||
|
relaybot:
|
||||||
|
enabled: false
|
||||||
|
management: "!whatsapp-relaybot:${node.metadata['mautrix-whatsapp']['homeserver']['domain']}"
|
||||||
|
invites:
|
||||||
|
% for user, permission in node.metadata['mautrix-whatsapp']['permissions'].items():
|
||||||
|
% if permission > 50:
|
||||||
|
- ${user}
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
message_formats:
|
||||||
|
m.text: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
|
||||||
|
m.notice: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
|
||||||
|
m.emote: "* <b>{{ .Sender.Displayname }}</b> {{ .Message }}"
|
||||||
|
m.file: "<b>{{ .Sender.Displayname }}</b> sent a file"
|
||||||
|
m.image: "<b>{{ .Sender.Displayname }}</b> sent an image"
|
||||||
|
m.audio: "<b>{{ .Sender.Displayname }}</b> sent an audio file"
|
||||||
|
m.video: "<b>{{ .Sender.Displayname }}</b> sent a video"
|
||||||
|
m.location: "<b>{{ .Sender.Displayname }}</b> sent a location"
|
||||||
|
|
||||||
|
logging:
|
||||||
|
directory: /opt/mautrix-whatsapp/logs
|
||||||
|
file_name_format: "{{.Date}}-{{.Index}}.log"
|
||||||
|
file_date_format: 2006-01-02
|
||||||
|
file_mode: 0600
|
||||||
|
timestamp_format: Jan _2, 2006 15:04:05
|
||||||
|
print_level: info
|
13
bundles/mautrix-whatsapp/files/mautrix-whatsapp.service
Normal file
13
bundles/mautrix-whatsapp/files/mautrix-whatsapp.service
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Matrix WhatsApp Bridge
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=mautrix-whatsapp
|
||||||
|
Group=mautrix-whatsapp
|
||||||
|
ExecStart=/opt/mautrix-whatsapp/src/mautrix-whatsapp --config /opt/mautrix-whatsapp/config.yaml --registration /opt/mautrix-whatsapp/registration.yaml
|
||||||
|
WorkingDirectory=/opt/mautrix-whatsapp/src
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
10
bundles/mautrix-whatsapp/files/registration.yaml
Normal file
10
bundles/mautrix-whatsapp/files/registration.yaml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
id: whatsapp
|
||||||
|
url: http://${node.metadata['mautrix-whatsapp'].get('listen-addr', '127.0.0.1')}:${node.metadata['mautrix-whatsapp'].get('port', 20020)}
|
||||||
|
as_token: ${node.metadata['mautrix-whatsapp']['as_token']}
|
||||||
|
hs_token: ${node.metadata['mautrix-whatsapp']['hs_token']}
|
||||||
|
sender_localpart: whatsappbot
|
||||||
|
rate_limited: false
|
||||||
|
namespaces:
|
||||||
|
users:
|
||||||
|
- regex: ^@whatsapp_[0-9]+:${node.metadata['mautrix-whatsapp']['homeserver']['domain']}$
|
||||||
|
exclusive: true
|
70
bundles/mautrix-whatsapp/items.py
Normal file
70
bundles/mautrix-whatsapp/items.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
users = {
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'home': '/opt/mautrix-whatsapp',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
directories = {
|
||||||
|
'/opt/mautrix-whatsapp/src': {},
|
||||||
|
'/opt/mautrix-whatsapp/logs': {
|
||||||
|
'owner': 'mautrix-whatsapp',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
git_deploy = {
|
||||||
|
'/opt/mautrix-whatsapp/src': {
|
||||||
|
'repo': 'https://github.com/tulir/mautrix-whatsapp.git',
|
||||||
|
'rev': node.metadata['mautrix-whatsapp']['version'],
|
||||||
|
'triggers': {
|
||||||
|
'action:mautrix-whatsapp_build',
|
||||||
|
'svc_systemd:mautrix-whatsapp:restart',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
actions = {
|
||||||
|
'mautrix-whatsapp_build': {
|
||||||
|
'command': 'cd /opt/mautrix-whatsapp/src && go build',
|
||||||
|
'triggered': True,
|
||||||
|
'needs': {
|
||||||
|
'pkg_apt:golang-go',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
svc_systemd = {
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'needs': {
|
||||||
|
'action:mautrix-whatsapp_build',
|
||||||
|
'directory:/opt/mautrix-whatsapp/logs',
|
||||||
|
'file:/etc/systemd/system/mautrix-whatsapp.service',
|
||||||
|
'file:/opt/mautrix-whatsapp/config.yaml',
|
||||||
|
'postgres_db:mautrix-whatsapp',
|
||||||
|
'postgres_role:mautrix-whatsapp',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
files = {
|
||||||
|
'/opt/mautrix-whatsapp/registration.yaml': {
|
||||||
|
'content_type': 'mako',
|
||||||
|
'triggers': {
|
||||||
|
'svc_systemd:mautrix-whatsapp:restart',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'/opt/mautrix-whatsapp/config.yaml': {
|
||||||
|
'content_type': 'mako',
|
||||||
|
'triggers': {
|
||||||
|
'svc_systemd:mautrix-whatsapp:restart',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'/etc/systemd/system/mautrix-whatsapp.service': {
|
||||||
|
'triggers': {
|
||||||
|
'action:systemd-reload',
|
||||||
|
'svc_systemd:mautrix-whatsapp:restart',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if node.has_bundle('matrix-synapse'):
|
||||||
|
files['/opt/mautrix-whatsapp/registration.yaml']['triggers'].add('svc_systemd:matrix-synapse:restart')
|
64
bundles/mautrix-whatsapp/metadata.py
Normal file
64
bundles/mautrix-whatsapp/metadata.py
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
defaults = {
|
||||||
|
'apt': {
|
||||||
|
'packages': {
|
||||||
|
'libolm-dev': {},
|
||||||
|
'golang-go': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'icinga2_api': {
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'services': {
|
||||||
|
'MAUTRIX-WHATSAPP PROCESS': {
|
||||||
|
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C mautrix-whatsapp -c 1:',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'matrix-synapse': {
|
||||||
|
'appservice_configs': {
|
||||||
|
'/opt/mautrix-whatsapp/registration.yaml',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'database': {
|
||||||
|
'user': 'mautrix-whatsapp',
|
||||||
|
'password': repo.vault.password_for('{} postgresql mautrix-whatsapp'.format(node.name)),
|
||||||
|
'database': 'mautrix-whatsapp',
|
||||||
|
},
|
||||||
|
'as_token': repo.vault.password_for('{} mautrix-whatsapp as_token'.format(node.name)),
|
||||||
|
'hs_token': repo.vault.password_for('{} mautrix-whatsapp hs_token'.format(node.name)),
|
||||||
|
'sender_localpart': repo.vault.password_for('{} mautrix-whatsapp sender_localpart'.format(node.name)),
|
||||||
|
'provisioning': {
|
||||||
|
'enabled': False,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'postgresql': {
|
||||||
|
'roles': {
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'password': repo.vault.password_for('{} postgresql mautrix-whatsapp'.format(node.name)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'databases': {
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'owner': 'mautrix-whatsapp',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@metadata_reactor
|
||||||
|
def icinga_check_for_new_release(metadata):
|
||||||
|
return {
|
||||||
|
'icinga2_api': {
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'services': {
|
||||||
|
'MAUTRIX-WHATSAPP UPDATE': {
|
||||||
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_github_for_new_release tulir/mautrix-whatsapp {}'.format(metadata.get('mautrix-whatsapp/version')),
|
||||||
|
'vars.notification.mail': True,
|
||||||
|
'check_interval': '60m',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ nodes['htz.ex42-1048908'] = {
|
||||||
'jenkins-ci',
|
'jenkins-ci',
|
||||||
'matrix-synapse',
|
'matrix-synapse',
|
||||||
'mautrix-telegram',
|
'mautrix-telegram',
|
||||||
|
'mautrix-whatsapp',
|
||||||
'miniflux',
|
'miniflux',
|
||||||
'mx-puppet-discord',
|
'mx-puppet-discord',
|
||||||
'nodejs',
|
'nodejs',
|
||||||
|
@ -111,10 +112,6 @@ nodes['htz.ex42-1048908'] = {
|
||||||
'server_name': 'franzi.business',
|
'server_name': 'franzi.business',
|
||||||
'baseurl': 'matrix.franzi.business',
|
'baseurl': 'matrix.franzi.business',
|
||||||
'admin_contact': 'mailto:hostmaster@kunbox.net',
|
'admin_contact': 'mailto:hostmaster@kunbox.net',
|
||||||
'appservice_configs': {
|
|
||||||
# TODO move to bundles
|
|
||||||
'/opt/matrix-bridges/mautrix-whatsapp/registration.yaml',
|
|
||||||
},
|
|
||||||
'trusted_key_servers': {
|
'trusted_key_servers': {
|
||||||
'matrix.org',
|
'matrix.org',
|
||||||
'finallycoffee.eu',
|
'finallycoffee.eu',
|
||||||
|
@ -143,6 +140,16 @@ nodes['htz.ex42-1048908'] = {
|
||||||
'bot_token': vault.decrypt('encrypt$gAAAAABfVK51ErJ6gfsOOkbRxSHDnVYmf7EihAQf7Uwj9og3TlAw64WRsA6ZVEgTSvOdLB3SMKZ-cTEhwkCOpbymq-_WLhes-hZALhN-H_oXHaxTQErJ0lARynKmjM-4ZhoGlUWlfh4Q'),
|
'bot_token': vault.decrypt('encrypt$gAAAAABfVK51ErJ6gfsOOkbRxSHDnVYmf7EihAQf7Uwj9og3TlAw64WRsA6ZVEgTSvOdLB3SMKZ-cTEhwkCOpbymq-_WLhes-hZALhN-H_oXHaxTQErJ0lARynKmjM-4ZhoGlUWlfh4Q'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'mautrix-whatsapp': {
|
||||||
|
'version': 'v0.1.5',
|
||||||
|
'homeserver': {
|
||||||
|
'domain': 'franzi.business',
|
||||||
|
'url': 'https://matrix.franzi.business',
|
||||||
|
},
|
||||||
|
'permissions': {
|
||||||
|
"'@kunsi:franzi.business'": 100,
|
||||||
|
},
|
||||||
|
},
|
||||||
'miniflux': {
|
'miniflux': {
|
||||||
'domain': 'rss.kunsmann.eu',
|
'domain': 'rss.kunsmann.eu',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue