package/polkit: add init S50polkit script
authorAdam Duskett <aduskett@gmail.com>
Wed, 21 Jul 2021 21:45:16 +0000 (14:45 -0700)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sat, 24 Jul 2021 21:29:21 +0000 (23:29 +0200)
The Polkit source does not come with non-systemd init script. Add one that is
modeled after package/busybox/S01syslogd.

Signed-off-by: Adam Duskett <aduskett@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/polkit/S50polkit [new file with mode: 0755]
package/polkit/polkit.mk

diff --git a/package/polkit/S50polkit b/package/polkit/S50polkit
new file mode 100755 (executable)
index 0000000..f07e2d6
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+DAEMON="polkitd"
+DAEMON_PATH="/usr/lib/polkit-1/${DAEMON}"
+PIDFILE="/var/run/${DAEMON}.pid"
+POLKITD_ARGS="--no-debug"
+
+# polkitd does not create a pidfile, so pass "-n" in the command line
+# and use "-m" to instruct start-stop-daemon to create one.
+start() {
+       printf 'Starting %s: ' "${DAEMON}"
+       # shellcheck disable=SC2086 # we need the word splitting
+       start-stop-daemon -bmSqp "$PIDFILE" -x ${DAEMON_PATH} -- ${POLKITD_ARGS}
+       status=$?
+       if [ "$status" -eq 0 ]; then
+               echo "OK"
+       else
+               echo "FAIL"
+       fi
+       return "$status"
+}
+
+stop() {
+       printf 'Stopping %s: ' "${DAEMON}"
+       start-stop-daemon -Kqp "$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|reload)
+               "$1";;
+       reload)
+               # Restart, since there is no true "reload" feature.
+               restart;;
+       *)
+               echo "Usage: $0 {start|stop|restart|reload}"
+               exit 1
+esac
index f48c103a5243410638f61a9ef46cd2404b80fb93..d5b3955ddbdd8db8820fccf0438e5f53f3d6c79f 100644 (file)
@@ -57,4 +57,9 @@ define POLKIT_INSTALL_INIT_SYSTEMD
 
 endef
 
+define POLKIT_INSTALL_INIT_SYSV
+       $(INSTALL) -D -m 0755 package/polkit/S50polkit \
+               $(TARGET_DIR)/etc/init.d/S50polkit
+endef
+
 $(eval $(autotools-package))