Another bit
This commit is contained in:
parent
fd52f70015
commit
8d3be057a8
|
@ -3,3 +3,15 @@
|
|||
"""
|
||||
Service startup script.
|
||||
"""
|
||||
|
||||
class Backive:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def serve(self):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
backive = Backive()
|
||||
backive.serve()
|
||||
|
|
|
@ -3,3 +3,13 @@
|
|||
"""
|
||||
Callable script for udev rules.
|
||||
"""
|
||||
import socket
|
||||
import sys
|
||||
|
||||
unix_socket = "/tmp/backive/backive.sock"
|
||||
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
sock.connect(unix_socket)
|
||||
if len(sys.argv) > 1:
|
||||
sock.send(sys.argv[1].encode())
|
||||
sock.close()
|
||||
|
|
|
@ -2,11 +2,9 @@ import os
|
|||
|
||||
|
||||
class Backup:
|
||||
|
||||
config = {}
|
||||
|
||||
def __init__(self, name, cfg=None):
|
||||
pass
|
||||
self.name = name
|
||||
self.config = cfg
|
||||
|
||||
def run(self):
|
||||
pass
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
import os
|
||||
import socket
|
||||
|
||||
|
||||
class EventInterface:
|
||||
def __init__(self, unix_socket=None):
|
||||
if not unix_socket:
|
||||
unix_socket = "/tmp/backive/backive.sock"
|
||||
self.socket = socket.socket(
|
||||
socket.AF_UNIX,
|
||||
socket.SOCK_STREAM
|
||||
)
|
||||
try:
|
||||
os.remove(unix_socket)
|
||||
except OSError:
|
||||
pass
|
||||
self.socket.bind(unix_socket)
|
||||
self.socket.listen()
|
||||
|
||||
def accept(self):
|
||||
return self.socket.accept()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue