extra_java_opts = []

for opt, value in sorted(node.metadata.get('openhab/java_opts', {}).items()):
    if value is None:
        extra_java_opts.append(f'-D{opt}')
    else:
        extra_java_opts.append(f'-D{opt}={value}')

files = {
    '/etc/default/openhab': {
        'content_type': 'mako',
        'context': {
            'extra_java_opts': ' '.join(extra_java_opts),
        },
        'triggers': {
            'svc_systemd:openhab:restart',
        },
    },
    '/etc/backup-pre-hooks.d/40-openhab': {
        'source': 'backup-pre-hook',
        'mode': '0755',
    }
}

svc_systemd = {
    'openhab': {
        'needs': {
            'pkg_apt:openhab',
            'pkg_apt:openhab-addons',
        },
    },
}
