mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-05-31 13:20:03 +00:00
thingsboard-gateway: Update systemd service
Update the systemd service file to reflect the changes of the source repository. Add a user and group "thingsboard_gateway" which the service runs under, instead of root. Store temporary files, like logs, in /var and make use of the newly created user and group. Additionally, the service should start after and wants a network connection to be online, not just be activated. Signed-off-by: Martin Schwan <m.schwan@phytec.de> Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
+11
-7
@@ -1,13 +1,17 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description = Systemd service for Thingsboard Gateway
|
Description=ThingsBoard Gateway
|
||||||
After = network.target
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
ConditionPathExists=/etc/thingsboard-gateway/config/tb_gateway.json
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart = /usr/bin/python3 /usr/bin/thingsboard-gateway
|
Type=simple
|
||||||
ExecStop = /bin/kill -INT $MAINPID
|
User=thingsboard_gateway
|
||||||
ExecReload = /bin/kill -TERM $MAINPID
|
Group=thingsboard_gateway
|
||||||
Restart = always
|
ExecStart=/usr/bin/python3 /usr/bin/thingsboard-gateway
|
||||||
Type = simple
|
ExecStop=/bin/kill -INT $MAINPID
|
||||||
|
ExecReload=/bin/kill -TERM $MAINPID
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
+21
-3
@@ -43,21 +43,39 @@ RDEPENDS:${PN} += " python3-jsonpath-rw \
|
|||||||
|
|
||||||
SRC_URI += "file://thingsboard-gateway.service"
|
SRC_URI += "file://thingsboard-gateway.service"
|
||||||
|
|
||||||
|
inherit systemd useradd
|
||||||
inherit systemd
|
|
||||||
|
|
||||||
SYSTEMD_PACKAGES = "${PN}"
|
SYSTEMD_PACKAGES = "${PN}"
|
||||||
SYSTEMD_SERVICE:${PN} = "thingsboard-gateway.service"
|
SYSTEMD_SERVICE:${PN} = "thingsboard-gateway.service"
|
||||||
|
|
||||||
|
USERADD_PACKAGES = "${PN}"
|
||||||
|
USERADD_PARAM:${PN} = " \
|
||||||
|
--system --no-create-home \
|
||||||
|
--comment 'ThingsBoard-Gateway Service' \
|
||||||
|
--home-dir ${localstatedir}/lib/${BPN} \
|
||||||
|
--shell ${base_sbindir}/nologin \
|
||||||
|
--gid thingsboard_gateway thingsboard_gateway"
|
||||||
|
GROUPADD_PARAM:${PN} = "--system thingsboard_gateway"
|
||||||
|
|
||||||
FILES:${PN} += "/etc \
|
FILES:${PN} += "/etc \
|
||||||
/lib \
|
/lib \
|
||||||
/usr \
|
/usr \
|
||||||
|
${localstatedir} \
|
||||||
"
|
"
|
||||||
|
|
||||||
do_install:append(){
|
do_install:append(){
|
||||||
install -d ${D}${sysconfdir}/${BPN}/config
|
install -d ${D}${sysconfdir}/${BPN}/config
|
||||||
install -m 0644 ${S}/thingsboard_gateway/config/*.json ${D}${sysconfdir}/${BPN}/config
|
install -m 0644 ${S}/thingsboard_gateway/config/*.json ${D}${sysconfdir}/${BPN}/config
|
||||||
|
chown -R thingsboard_gateway:thingsboard_gateway ${D}${sysconfdir}/${BPN}
|
||||||
|
|
||||||
install -d ${D}${systemd_unitdir}/system/
|
install -d ${D}${systemd_system_unitdir}/
|
||||||
install -m 0644 ${UNPACKDIR}/thingsboard-gateway.service ${D}${systemd_system_unitdir}/thingsboard-gateway.service
|
install -m 0644 ${UNPACKDIR}/thingsboard-gateway.service ${D}${systemd_system_unitdir}/thingsboard-gateway.service
|
||||||
|
|
||||||
|
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
|
||||||
|
install -d ${D}${sysconfdir}/tmpfiles.d
|
||||||
|
echo "d ${localstatedir}/log/${BPN} 0755 thingsboard_gateway thingsboard_gateway -" \
|
||||||
|
> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
|
||||||
|
echo "d ${localstatedir}/lib/${BPN} 0755 thingsboard_gateway thingsboard_gateway -" \
|
||||||
|
>> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user