diff --git a/bin/malpd b/bin/malpd index a018eaa..c196ca6 100755 --- a/bin/malpd +++ b/bin/malpd @@ -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 } diff --git a/systemd/malpd.service b/systemd/malpd.service new file mode 100644 index 0000000..978b6e3 --- /dev/null +++ b/systemd/malpd.service @@ -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 diff --git a/systemd/malpd.socket b/systemd/malpd.socket new file mode 100644 index 0000000..295cc77 --- /dev/null +++ b/systemd/malpd.socket @@ -0,0 +1,10 @@ +[Unit] +Description=malpd Unix socket + +[Socket] +ListenStream=/run/malpd/malpd.sock +SocketGroup=apache +SocketMode=0660 + +[Install] +WantedBy=sockets.target