Déc 28 2012

Replace xinetd with systemd

While reading the Samba ArchWiki page, I discovered that samba now include a web admin tool (SWAT). The ArchWiki propose to use xinet to start it… I remembered that systemd provide a socket management solution that can replace xinet (or inet)…

The mechanism behind xinet is that it’s configured to listen on a socket, and when a connection is received to the socket, it launch a program and bind its input and output to the socket stream…

To configure swat with systemd, you just have to create two new unit in /etc/systemd/system.
swat.socket

1
2
3
4
5
6
7
8
9
[Unit]
Description=SWAT Samba Web Admin Tool

[Socket]
ListenStream=127.0.0.1:901
Accept=true

[Install]
WantedBy=sockets.target

swat@.service

1
2
3
4
5
6
7
[Unit]
Description=SWAT Samba Web Admin Tool
After=local-fs.target

[Service]
ExecStart=/usr/sbin/swat
StandardInput=socket

Mind the @ at the end of the service unit… It tells systemd that the unit is started by the socket…

You can start the socket (and enable it, if you want this to be persistent).

1
systemctl start swat.socket

Then go to http://localhost:901/ and enjoy 😉

Tomorrow, I’ll try to submit a patch to the samba arch package maintainer…

Laisser un commentaire

Your email address will not be published.