bundles/wireguard: add wg_health_check
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-10-14 08:52:03 +02:00
parent f79365304c
commit 9188b28b7a
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 57 additions and 1 deletions

View file

@ -8,6 +8,7 @@ files = {
},
}
health_checks = {}
for number, (peer, config) in enumerate(sorted(node.metadata.get('wireguard/peers', {}).items())):
files[f'/etc/systemd/network/wg{number}.netdev'] = {
'content_type': 'mako',
@ -29,6 +30,21 @@ for number, (peer, config) in enumerate(sorted(node.metadata.get('wireguard/peer
},
}
if config.get('health_check', False):
health_checks[peer] = config['their_ip']
if health_checks:
files['/usr/local/bin/wg_health_check'] = {
'content_type': 'mako',
'context': {
'peers': health_checks,
},
'mode': '0755',
}
files['/etc/cron.d/wg_health_check'] = {
'content': '* * * * * root /usr/local/bin/wg_health_check | logger -t wg_health_check\n',
}
if node.has_bundle('pppd'):
files['/etc/ppp/ip-up.d/reconnect-wireguard'] = {
'source': 'pppd-ip-up',