busybox http: add systemd service

Currently in a systemd based init, the httpd server is not launched. A
systemd service is needed, so add it.

Also install a CGI script that allows to use the device for the
NetworkManager connectivity check.

https://jira.digi.com/browse/DEL-6577

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2019-05-07 18:09:17 +02:00
parent a3c190dfff
commit 78e8c021b2
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,12 @@
[Unit]
Description=Busybox HTTP daemon
After=network.target
[Service]
Type=forking
ExecStart=@sbindir@/httpd -h /srv/www
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,6 @@
#!/bin/sh
printf "Content-Type: text/plain; charset=utf-8\r\n"
printf "X-NetworkManager-Status: online\r\n"
printf "\r\n"
printf "NetworkManager is online\r\n"

View File

@ -8,6 +8,8 @@ SRC_URI += "file://standby \
file://busybox-ntpd \
file://index.html \
file://digi-logo.png \
file://busybox-httpd.service.in \
file://nm \
file://busybox-acpid \
file://acpid.map \
file://pswitch-standby \
@ -22,6 +24,11 @@ INITSCRIPT_PARAMS_${PN}-hwclock = "start 20 S . stop 20 0 6 ."
FILES_${PN}_append = " ${systemd_unitdir}/system-sleep/"
# HTTPD package
FILES_${PN}-httpd_append = " ${systemd_unitdir}/system/busybox-httpd.service"
SYSTEMD_PACKAGES += "${PN}-httpd"
SYSTEMD_SERVICE_${PN}-httpd = "busybox-httpd.service"
# NTPD package
PACKAGES =+ "${PN}-ntpd"
FILES_${PN}-ntpd = "${sysconfdir}/init.d/busybox-ntpd"
@ -46,8 +53,15 @@ do_install_append() {
install -m 0755 ${WORKDIR}/busybox-ntpd ${D}${sysconfdir}/init.d/
fi
if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then
install -d ${D}/srv/www/cgi-bin
install -m 0644 ${WORKDIR}/index.html ${D}/srv/www/
install -m 0644 ${WORKDIR}/digi-logo.png ${D}/srv/www/
install -m 0755 ${WORKDIR}/nm ${D}/srv/www/cgi-bin/
if ${HAS_SYSTEMD}; then
install -d ${D}${systemd_unitdir}/system
sed 's,@sbindir@,${sbindir},g' < ${WORKDIR}/busybox-httpd.service.in \
> ${D}${systemd_unitdir}/system/busybox-httpd.service
fi
fi
# Install one standby script or another depending on having systemd or not
if ${HAS_SYSTEMD}; then