Initial commit
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import sys
|
||||
from os import environ as env
|
||||
|
||||
import posix_ipc
|
||||
|
||||
if __name__ != '__main__':
|
||||
print('You shouldn\'t be importing this script!')
|
||||
sys.exit(1)
|
||||
|
||||
event = {'type': sys.argv[1]}
|
||||
if event['type'] in ('bound', 'renew'):
|
||||
if 'ipv6' in env:
|
||||
event['ip'] = env['ipv6']
|
||||
else:
|
||||
event['ip'] = f'{env["ip"]}/{env["mask"]}'
|
||||
if 'router' in env:
|
||||
event['gateway'] = env['router']
|
||||
if 'domain' in env:
|
||||
event['domain'] = env['domain']
|
||||
elif event['type'] in ('deconfig', 'leasefail', 'nak'):
|
||||
pass
|
||||
else:
|
||||
event['type'] = 'unknown'
|
||||
|
||||
queue = posix_ipc.MessageQueue(env['EVENT_QUEUE'])
|
||||
queue.send(json.dumps(event))
|
||||
queue.close()
|
||||
Reference in New Issue
Block a user