users = {
    'mautrix-whatsapp': {
        'home': '/opt/mautrix-whatsapp',
    },
}

directories = {
    '/opt/mautrix-whatsapp': {},
    '/opt/mautrix-whatsapp/logs': {
        'owner': 'mautrix-whatsapp',
    },
}
svc_systemd = {
    'mautrix-whatsapp': {
        'needs': {
            'directory:/opt/mautrix-whatsapp/logs',
            'file:/etc/systemd/system/mautrix-whatsapp.service',
            'file:/opt/mautrix-whatsapp/config.yaml',
            'file:/opt/mautrix-whatsapp/mautrix-whatsapp',
            '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',
        },
    },
    '/opt/mautrix-whatsapp/mautrix-whatsapp': {
        'content_hash': node.metadata.get('mautrix-whatsapp/sha1', None),
        'content_type': 'download',
        'mode': '0755',
        'source': 'https://github.com/mautrix/whatsapp/releases/download/{}/mautrix-whatsapp-amd64'.format(node.metadata.get('mautrix-whatsapp/version')),
        'triggers': {
            'svc_systemd:mautrix-whatsapp:restart',
        },
    },
}

if node.has_bundle('matrix-synapse'):
    files['/opt/mautrix-whatsapp/registration.yaml']['triggers'].add('svc_systemd:matrix-synapse:restart')