24 lines
595 B
Python
Executable File
24 lines
595 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Callable script for udev rules.
|
|
"""
|
|
import socket
|
|
import os
|
|
import json
|
|
|
|
|
|
with open("/tmp/backive/udev.log", "a") as stream:
|
|
stream.write("udev run...")
|
|
for k, v in os.environ.items():
|
|
stream.write("{k}: {v}\n".format(k=k, v=v))
|
|
|
|
unix_socket = "/tmp/backive/backive.sock"
|
|
try:
|
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
sock.connect(unix_socket)
|
|
sock.send(json.dumps(dict(os.environ)).encode())
|
|
sock.close()
|
|
except Exception as e:
|
|
stream.write("Exception occurred: {}".format(str(e)))
|