mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
package/busybox: add httpd server startup script
In order to remove thttpd package from Buildroot, we have to replace it from our testsuite (TestWget and TestLibCurl). Busybox provide an httpd server applet but it's not enabled in our default busybox configuration. For the sake of those tests, add a new busybox option to build and install the Busybox's httpd server and its init script. Import S90thttpd from thttpd package to S90httpd but with some changes following S01syslogd init script as a reference [1]. [1]3dc8061444Cc: Julien Olivain <ju.o@free.fr> Cc: Fiona Klute (WIWA) <fiona.klute@gmx.de> Signed-off-by: Romain Naour <romain.naour@smile.fr> Reviewed-by: Fiona Klute <fiona.klute@gmx.de> Signed-off-by: Arnout Vandecappelle <arnout@rnout.be> (cherry picked from commitbcd97e1424) Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
This commit is contained in:
committed by
Titouan Christophe
parent
13eb6c293e
commit
33bd0a601c
@@ -69,6 +69,12 @@ config BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES
|
||||
comment "Busybox individual binaries need a toolchain w/ dynamic library"
|
||||
depends on BR2_STATIC_LIBS
|
||||
|
||||
config BR2_PACKAGE_BUSYBOX_HTTPD
|
||||
bool "Install the httpd server startup script"
|
||||
help
|
||||
Install the httpd server startup script,
|
||||
that just start at the boot the busybox httpd server
|
||||
|
||||
config BR2_PACKAGE_BUSYBOX_WATCHDOG
|
||||
bool "Install the watchdog daemon startup script"
|
||||
help
|
||||
|
||||
59
package/busybox/S90httpd
Normal file
59
package/busybox/S90httpd
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
|
||||
DAEMON="httpd"
|
||||
PIDFILE="/var/run/$DAEMON.pid"
|
||||
|
||||
HTTPD_ARGS="-h /var/www/data"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
||||
|
||||
# BusyBox' httpd does not create a pidfile, so pass "-f" in the command line
|
||||
# and use "--make-pidfile" to instruct start-stop-daemon to create one.
|
||||
start() {
|
||||
printf 'Starting %s: ' "$DAEMON"
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon --start --background --quiet --make-pidfile \
|
||||
--pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \
|
||||
-- -f $HTTPD_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf 'Stopping %s: ' "$DAEMON"
|
||||
start-stop-daemon --stop --quiet --pidfile "$PIDFILE"
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
|
||||
--exec "/usr/sbin/$DAEMON"; do
|
||||
sleep 0.1
|
||||
done
|
||||
rm -f "$PIDFILE"
|
||||
return "$status"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
esac
|
||||
@@ -258,6 +258,19 @@ define BUSYBOX_SET_SELINUX
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(BR2_PACKAGE_BUSYBOX_HTTPD),y)
|
||||
define BUSYBOX_SET_HTTPD
|
||||
$(call KCONFIG_ENABLE_OPT,CONFIG_HTTPD)
|
||||
endef
|
||||
define BUSYBOX_INSTALL_HTTPD_SCRIPT
|
||||
if grep -q CONFIG_HTTPD=y $(@D)/.config; then \
|
||||
mkdir -p $(TARGET_DIR)/var/www/data ;\
|
||||
$(INSTALL) -m 0755 -D package/busybox/S90httpd \
|
||||
$(TARGET_DIR)/etc/init.d/S90httpd ; \
|
||||
fi
|
||||
endef
|
||||
endif
|
||||
|
||||
# enable relevant options to allow the Busybox less applet to be used
|
||||
# as a systemd pager
|
||||
ifeq ($(BR2_PACKAGE_SYSTEMD):$(BR2_PACKAGE_LESS),y:)
|
||||
@@ -418,6 +431,7 @@ define BUSYBOX_KCONFIG_FIXUP_CMDS
|
||||
$(BUSYBOX_SET_WATCHDOG)
|
||||
$(BUSYBOX_SET_SELINUX)
|
||||
$(BUSYBOX_SET_LESS_FLAGS)
|
||||
$(BUSYBOX_SET_HTTPD)
|
||||
$(BUSYBOX_SET_INDIVIDUAL_BINARIES)
|
||||
$(BUSYBOX_DISABLE_IP_LINK_CAN)
|
||||
$(PACKAGES_BUSYBOX_CONFIG_FIXUPS)
|
||||
@@ -447,6 +461,7 @@ define BUSYBOX_INSTALL_INIT_OPENRC
|
||||
$(BUSYBOX_INSTALL_IFPLUGD_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_CROND_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_TELNET_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_HTTPD_SCRIPT)
|
||||
endef
|
||||
|
||||
define BUSYBOX_INSTALL_INIT_SYSTEMD
|
||||
@@ -461,6 +476,7 @@ define BUSYBOX_INSTALL_INIT_SYSV
|
||||
$(BUSYBOX_INSTALL_IFPLUGD_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_CROND_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_TELNET_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_HTTPD_SCRIPT)
|
||||
endef
|
||||
|
||||
# Checks to give errors that the user can understand
|
||||
|
||||
Reference in New Issue
Block a user