ser2net: add a systemd service file

This adds and installs a simple systemd service for ser2net.
The service is only started in case a non-zero configuration file
/etc/ser2net/ser2net.yaml exists.

Additionally, this configuration file a marked as such in the recipe.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Michael Heimpold 2024-03-10 11:23:06 +01:00 committed by Khem Raj
parent 3e6f301fb5
commit fc34acf93f
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 29 additions and 2 deletions

View File

@ -0,0 +1,13 @@
[Unit]
Description=Serial port to network proxy
Documentation=man:ser2net(8)
After=network.target
Wants=network.target
ConditionFileNotEmpty=@SYSCONFDIR@/ser2net/ser2net.yaml
[Service]
Type=exec
ExecStart=@SBINDIR@/ser2net -n
[Install]
WantedBy=multi-user.target

View File

@ -7,10 +7,24 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
DEPENDS = "gensio libyaml"
SRC_URI = "${SOURCEFORGE_MIRROR}/project/ser2net/ser2net/ser2net-${PV}.tar.gz"
SRC_URI = "${SOURCEFORGE_MIRROR}/project/ser2net/ser2net/ser2net-${PV}.tar.gz \
file://ser2net.service \
"
SRC_URI[sha256sum] = "78ffee19d9b97e93ae65b5cec072da2b7b947fc484e9ccb3f535702f36f6ed19"
UPSTREAM_CHECK_URI = "http://sourceforge.net/projects/ser2net/files/ser2net"
inherit autotools pkgconfig
inherit autotools pkgconfig systemd
SYSTEMD_SERVICE:${PN} = "ser2net.service"
CONFFILES:${PN} += "${sysconfdir}/ser2net/ser2net.yaml"
do_install:append() {
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/ser2net.service ${D}${systemd_unitdir}/system/
sed -i -e 's,@SBINDIR@,${sbindir},g' -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/ser2net.service
fi
}