package/cups: add proper init script
authorAngelo Compagnucci <angelo@amarulasolutions.com>
Wed, 24 Jun 2020 20:43:43 +0000 (22:43 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Tue, 4 Aug 2020 21:00:10 +0000 (23:00 +0200)
Cups service for systemv was erroneously installed in /etc/rcX.d and
therefore not working. Also, its init script installed in /etc/init.d
was definitely not a Buildroot-style init script.

This patch adds a Buildroot style init script instead of using the
example provided by the package.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/cups/S81cupsd [new file with mode: 0644]
package/cups/cups.mk

diff --git a/package/cups/S81cupsd b/package/cups/S81cupsd
new file mode 100644 (file)
index 0000000..45d0cbc
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+DAEMON="cupsd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+start() {
+       printf 'Starting %s: ' "$DAEMON"
+       # shellcheck disable=SC2086 # we need the word splitting
+       start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
+               -- -C /etc/cups/cupsd.conf -s /etc/cups/cups-files
+       status=$?
+       if [ "$status" -eq 0 ]; then
+               echo "OK"
+       else
+               echo "FAIL"
+       fi
+       return "$status"
+}
+
+stop() {
+       printf 'Stopping %s: ' "$DAEMON"
+       start-stop-daemon -K -q -p "$PIDFILE"
+       status=$?
+       if [ "$status" -eq 0 ]; then
+               rm -f "$PIDFILE"
+               echo "OK"
+       else
+               echo "FAIL"
+       fi
+       return "$status"
+}
+
+restart() {
+       stop
+       sleep 1
+       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
index 18f01d8484e449b33626740a1785c69b191c1599..53b0e2ab08e6bafb5227d3451e6426fc62eee24d 100644 (file)
@@ -21,7 +21,8 @@ CUPS_CONF_OPTS = \
        --with-docdir=/usr/share/cups/doc-root \
        --disable-gssapi \
        --disable-pam \
-       --libdir=/usr/lib
+       --libdir=/usr/lib \
+       --without-rcdir
 CUPS_CONFIG_SCRIPTS = cups-config
 CUPS_DEPENDENCIES = \
        host-autoconf \
@@ -71,4 +72,9 @@ else
 CUPS_CONF_OPTS += --disable-avahi
 endif
 
+define CUPS_INSTALL_INIT_SYSV
+       $(INSTALL) -D -m 0755 package/cups/S81cupsd \
+               $(TARGET_DIR)/etc/init.d/S81cupsd
+endef
+
 $(eval $(autotools-package))