Add systemd unit files for malpd and support systemd socket activation

This commit is contained in:
Josh Holtrop 2026-04-01 21:05:57 -04:00
parent c717b5d589
commit 1180849b44
3 changed files with 29 additions and 5 deletions

View File

@ -62,12 +62,16 @@ if Process.uid != 0
exit(1)
end
FileUtils.mkdir_p(File.dirname(SOCKET_PATH))
FileUtils.rm_f(SOCKET_PATH)
if ENV["LISTEN_FDS"]
server = UNIXServer.for_fd(3)
else
FileUtils.mkdir_p(File.dirname(SOCKET_PATH))
FileUtils.rm_f(SOCKET_PATH)
server = UNIXServer.new(SOCKET_PATH)
File.chmod(0660, SOCKET_PATH)
FileUtils.chown(nil, "apache", SOCKET_PATH)
server = UNIXServer.new(SOCKET_PATH)
File.chmod(0660, SOCKET_PATH)
FileUtils.chown(nil, "apache", SOCKET_PATH)
end
Signal.trap("TERM") { server.close }
Signal.trap("INT") { server.close }

10
systemd/malpd.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=MALP monitoring daemon
Requires=malpd.socket
[Service]
Type=simple
ExecStart=/var/www/malp/bin/malpd
[Install]
WantedBy=multi-user.target

10
systemd/malpd.socket Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=malpd Unix socket
[Socket]
ListenStream=/run/malpd/malpd.sock
SocketGroup=apache
SocketMode=0660
[Install]
WantedBy=sockets.target