All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] package/restorecond: Add new init script
@ 2021-08-20 11:23 José Pekkarinen
  2021-08-20 21:36 ` Thomas Petazzoni
  0 siblings, 1 reply; 5+ messages in thread
From: José Pekkarinen @ 2021-08-20 11:23 UTC (permalink / raw)
  To: buildroot; +Cc: José Pekkarinen, thomas.petazzoni

The current restorecond upstream init script is no
good fit for the user space generated by buildroot,
this script is an extension of the original, that
brings some changes from the debian init script to
use start-stop-daemon instead of daemon, while
removing dependencies on /etc/rc.d/init.d/functions
and /lib/lsb/init-functions.

Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
---
[ v1 -> v2 ] Moved to upstream script template

 package/restorecond/S02restorecond | 75 ++++++++++++++++++++++++++++++
 package/restorecond/restorecond.mk |  4 +-
 2 files changed, 77 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..ae5acbf73a
--- /dev/null
+++ b/package/restorecond/S02restorecond
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+DAEMON=restorecond
+PIDFILE=/var/run/$DAEMON.pid
+
+RESTORECOND_ARGS=""
+
+start()
+{
+	# Return
+	#   0 if daemon has been started
+	#   1 if daemon was already running
+	#   2 if daemon could not be started
+	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()
+{
+	# Return
+	#   0 if daemon has been stopped
+	#   1 if daemon was already stopped
+	#   2 if daemon could not be stopped
+	#   other if a failure occurred
+	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
+}
+
+check_status()
+{
+	start-stop-daemon -K -t -p $PIDFILE -n $DAEMON
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "RUNNING"
+	else
+		echo "STOPPED"
+	fi
+}
+
+case "$1" in
+	start|stop|restart)
+		"$1";;
+	status)
+		check_status;;
+	force-reload|restart|reload)
+		restart;;
+	condrestart)
+		[ -e /var/lock/subsys/restorecond ] && restart || :;;
+	*)
+		echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart}"
+		exit 1
+esac
diff --git a/package/restorecond/restorecond.mk b/package/restorecond/restorecond.mk
index 7ab7e978dd..3c6fb57ea6 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.25.1

_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH v2] package/restorecond: Add new init script
  2021-08-20 11:23 [Buildroot] [PATCH v2] package/restorecond: Add new init script José Pekkarinen
@ 2021-08-20 21:36 ` Thomas Petazzoni
  2021-08-23  5:45   ` José Pekkarinen
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2021-08-20 21:36 UTC (permalink / raw)
  To: José Pekkarinen; +Cc: buildroot

Hello José,

On Fri, 20 Aug 2021 14:23:22 +0300
José Pekkarinen <jose.pekkarinen@unikie.com> wrote:

> The current restorecond upstream init script is no
> good fit for the user space generated by buildroot,
> this script is an extension of the original, that
> brings some changes from the debian init script to
> use start-stop-daemon instead of daemon, while
> removing dependencies on /etc/rc.d/init.d/functions
> and /lib/lsb/init-functions.
> 
> Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
> ---
> [ v1 -> v2 ] Moved to upstream script template

I have further simplified the script to better match the S01syslogd
template, added the inclusion of /etc/default/restorecond, and applied
to next. Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH v2] package/restorecond: Add new init script
  2021-08-20 21:36 ` Thomas Petazzoni
@ 2021-08-23  5:45   ` José Pekkarinen
  2021-08-23 15:09     ` [Buildroot] [External] " Weber, Matthew L Collins via buildroot
  0 siblings, 1 reply; 5+ messages in thread
From: José Pekkarinen @ 2021-08-23  5:45 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 911 bytes --]

On Sat, Aug 21, 2021 at 12:36 AM Thomas Petazzoni <
thomas.petazzoni@bootlin.com> wrote:

> Hello José,
>
> On Fri, 20 Aug 2021 14:23:22 +0300
> José Pekkarinen <jose.pekkarinen@unikie.com> wrote:
>
> > The current restorecond upstream init script is no
> > good fit for the user space generated by buildroot,
> > this script is an extension of the original, that
> > brings some changes from the debian init script to
> > use start-stop-daemon instead of daemon, while
> > removing dependencies on /etc/rc.d/init.d/functions
> > and /lib/lsb/init-functions.
> >
> > Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
> > ---
> > [ v1 -> v2 ] Moved to upstream script template
>
> I have further simplified the script to better match the S01syslogd
> template, added the inclusion of /etc/default/restorecond, and applied
> to next. Thanks!
>

Perfect! Thanks!


José.

[-- Attachment #1.2: Type: text/html, Size: 1712 bytes --]

[-- Attachment #2: Type: text/plain, Size: 145 bytes --]

_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [External] Re: [PATCH v2] package/restorecond: Add new init script
  2021-08-23  5:45   ` José Pekkarinen
@ 2021-08-23 15:09     ` Weber, Matthew L Collins via buildroot
  2021-08-24  7:25       ` José Pekkarinen
  0 siblings, 1 reply; 5+ messages in thread
From: Weber, Matthew L Collins via buildroot @ 2021-08-23 15:09 UTC (permalink / raw)
  To: José Pekkarinen, Thomas Petazzoni; +Cc: buildroot

Yann / Jose,

> From: buildroot <buildroot-bounces@busybox.net> on behalf of José Pekkarinen <jose.pekkarinen@unikie.com>
> Sent: Monday, August 23, 2021 12:45 AM
> To: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: buildroot@buildroot.org <buildroot@buildroot.org>
> Subject: [External] Re: [Buildroot] [PATCH v2] package/restorecond: Add new init script
>
> On Sat, Aug 21, 2021 at 12:36 AM Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:
> Hello José,
>
> On Fri, 20 Aug 2021 14:23:22 +0300
> José Pekkarinen <jose.pekkarinen@unikie.com> wrote:
>
> > The current restorecond upstream init script is no
> > good fit for the user space generated by buildroot,
> > this script is an extension of the original, that
> > brings some changes from the debian init script to
> > use start-stop-daemon instead of daemon, while
> > removing dependencies on /etc/rc.d/init.d/functions
> > and /lib/lsb/init-functions.

Oops, I was reviewing patches this morning and missed this one when I responded to the "autorelabel" email thread.

I think the example script I referenced in that email is still the most basic way to do the boot fixup, however, it would be worth going through the upstream scripts/daemons to see if they are viable and fit the general criteria Buildroot projects might desire.  Some things that come to mind the upstream scripts would need to consider.
- .autorelabel is different from handling all our memory-based filesystems on each boot.  Does "fixfiles" cover this without requiring a .autorelabel set?
- No impact to boot time or requirement to run on first boot
- read-only filesystem support (may need to tweak the scripts)
- Additional Buildroot package dependencies to support "fixfiles" as is.  Can we make the selection of this conditional on using ".autorelabel"?

Regards,
Matt
_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [External] Re: [PATCH v2] package/restorecond: Add new init script
  2021-08-23 15:09     ` [Buildroot] [External] " Weber, Matthew L Collins via buildroot
@ 2021-08-24  7:25       ` José Pekkarinen
  0 siblings, 0 replies; 5+ messages in thread
From: José Pekkarinen @ 2021-08-24  7:25 UTC (permalink / raw)
  To: Weber, Matthew L Collins; +Cc: Thomas Petazzoni, buildroot


[-- Attachment #1.1: Type: text/plain, Size: 2276 bytes --]

On Mon, Aug 23, 2021 at 6:10 PM Weber, Matthew L Collins <
Matthew.Weber@collins.com> wrote:

> Yann / Jose,
>
> > From: buildroot <buildroot-bounces@busybox.net> on behalf of José
> Pekkarinen <jose.pekkarinen@unikie.com>
> > Sent: Monday, August 23, 2021 12:45 AM
> > To: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> > Cc: buildroot@buildroot.org <buildroot@buildroot.org>
> > Subject: [External] Re: [Buildroot] [PATCH v2] package/restorecond: Add
> new init script
> >
> > On Sat, Aug 21, 2021 at 12:36 AM Thomas Petazzoni <
> thomas.petazzoni@bootlin.com> wrote:
> > Hello José,
> >
> > On Fri, 20 Aug 2021 14:23:22 +0300
> > José Pekkarinen <jose.pekkarinen@unikie.com> wrote:
> >
> > > The current restorecond upstream init script is no
> > > good fit for the user space generated by buildroot,
> > > this script is an extension of the original, that
> > > brings some changes from the debian init script to
> > > use start-stop-daemon instead of daemon, while
> > > removing dependencies on /etc/rc.d/init.d/functions
> > > and /lib/lsb/init-functions.
>
> Oops, I was reviewing patches this morning and missed this one when I
> responded to the "autorelabel" email thread.
>
> I think the example script I referenced in that email is still the most
> basic way to do the boot fixup, however, it would be worth going through
> the upstream scripts/daemons to see if they are viable and fit the general
> criteria Buildroot projects might desire.  Some things that come to mind
> the upstream scripts would need to consider.
> - .autorelabel is different from handling all our memory-based filesystems
> on each boot.  Does "fixfiles" cover this without requiring a .autorelabel
> set?
> - No impact to boot time or requirement to run on first boot
> - read-only filesystem support (may need to tweak the scripts)
> - Additional Buildroot package dependencies to support "fixfiles" as is.
> Can we make the selection of this conditional on using ".autorelabel"?
>

Hi,

To ease the reading/tracking of the script

Matthew was refering to, here is the link.

[1]
https://patchwork.ozlabs.org/project/buildroot/patch/1458128701-14841-1-git-send-email-niranjan.reddy@rockwellcollins.com/

Thanks!


José.

[-- Attachment #1.2: Type: text/html, Size: 3948 bytes --]

[-- Attachment #2: Type: text/plain, Size: 145 bytes --]

_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-24  7:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 11:23 [Buildroot] [PATCH v2] package/restorecond: Add new init script José Pekkarinen
2021-08-20 21:36 ` Thomas Petazzoni
2021-08-23  5:45   ` José Pekkarinen
2021-08-23 15:09     ` [Buildroot] [External] " Weber, Matthew L Collins via buildroot
2021-08-24  7:25       ` José Pekkarinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.