From 99896b841b30043f05a7dd2e9d9a9a48376f3aa3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Pekkarinen?= Date: Fri, 20 Aug 2021 14:23:22 +0300 Subject: [PATCH] package/restorecond: Add new init script MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current restorecond upstream init script is no good fit for the user space generated by buildroot, so we provide our own one. Signed-off-by: José Pekkarinen Signed-off-by: Thomas Petazzoni --- package/restorecond/S02restorecond | 54 ++++++++++++++++++++++++++++++ package/restorecond/restorecond.mk | 4 +-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 package/restorecond/S02restorecond diff --git a/package/restorecond/S02restorecond b/package/restorecond/S02restorecond new file mode 100644 index 0000000000..796b07a32f --- /dev/null +++ b/package/restorecond/S02restorecond @@ -0,0 +1,54 @@ +#!/bin/sh + +DAEMON=restorecond +PIDFILE=/var/run/$DAEMON.pid + +RESTORECOND_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +start() +{ + printf 'Starting %s: ' "$DAEMON" + start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ + -- $RESTORECOND_ARGS + 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 -R TERM/30/KILL/5 -n $DAEMON + 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;; + *) + echo $"Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/restorecond/restorecond.mk b/package/restorecond/restorecond.mk index d08e0a722e..671f071b1d 100644 --- a/package/restorecond/restorecond.mk +++ b/package/restorecond/restorecond.mk @@ -27,8 +27,8 @@ define RESTORECOND_BUILD_CMDS endef define RESTORECOND_INSTALL_INIT_SYSV - $(INSTALL) -m 0755 -D $(@D)/restorecond.init \ - $(TARGET_DIR)/etc/init.d/S20restorecond + $(INSTALL) -m 0755 -D package/restorecond/S02restorecond \ + $(TARGET_DIR)/etc/init.d/S02restorecond endef define RESTORECOND_INSTALL_INIT_SYSTEMD -- 2.30.2