Make-initrd development discussion
 help / color / mirror / Atom feed
* [make-initrd] [PATCH v1 21/41] fork pipeline: bootchain sysvinit script now use external hooks
@ 2021-09-24 15:57 Leonid Krivoshein
  2021-09-26 14:09 ` Alexey Gladkov
  0 siblings, 1 reply; 9+ messages in thread
From: Leonid Krivoshein @ 2021-09-24 15:57 UTC (permalink / raw)
  To: make-initrd

---
  .../data/etc/rc.d/init.d/bootchain            | 33 ++++++++++---------
  .../data/lib/bootchain-prepare.d/300-waitdev  | 12 +++++++
  2 files changed, 29 insertions(+), 16 deletions(-)
  create mode 100644 
make-initrd/features/bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev

diff --git 
a/make-initrd/features/bootchain-core/data/etc/rc.d/init.d/bootchain 
b/make-initrd/features/bootchain-core/data/etc/rc.d/init.d/bootchain
index 89d9de5..7bdb1cf 100755
--- a/make-initrd/features/bootchain-core/data/etc/rc.d/init.d/bootchain
+++ b/make-initrd/features/bootchain-core/data/etc/rc.d/init.d/bootchain
@@ -1,6 +1,6 @@
  #!/bin/bash
  ### BEGIN INIT INFO
-# Provides:            pipeline
+# Provides:            bootchain
  # Required-Start:      uevent udev
  # Should-Start:
  # Required-Stop:
@@ -13,27 +13,28 @@
  . /.initrd/initenv
  . /etc/init.d/template
  -NAME=pipelined
+NAME=bootchained
  PIDFILE="/var/run/$NAME.pid"
  ARGS="--lockfile $LOCKFILE --pidfile $PIDFILE --name $NAME 
--displayname $NAME"
  -prepare() {
-	local dir i n
-
-	dir=/.initrd/pipeline/waitdev
-	mkdir -p -- "$dir"
-
-	i=0
-	while [ "$i" -lt "${WAITDEV:-0}" ]; do
-		touch "$dir/$i"
-		i=$(($i + 1))
-	done
+use_hooks()
+{
+	local hook hdir="$1"
+
+	if [ -d "$hdir" ]; then
+		# shellcheck disable=SC2012
+		for hook in $(ls -1 -- "$hdir"/* |sort) _; do
+			[ -s "$hook" ] ||
+				continue
+			. "$hook"
+		done
+	fi
  }
   start() {
  	RETVAL=0
-	if [ "${ROOT-}" = pipeline ]; then
-		prepare
+	if [ "${ROOT-}" = bootchain ] || [ "${ROOT-}" = pipeline ]; then
+		use_hooks /lib/bootchain-prepare.d
  		start_daemon --background $ARGS "$NAME"
  		RETVAL=$?
  	fi
@@ -43,7 +44,7 @@ start() {
  stop() {
  	stop_daemon $ARGS "$NAME"
  	RETVAL=$?
-	[ ! -f "$PIDFILE" ] || rm -f -- "$PIDFILE"
+	rm -f -- "$PIDFILE"
  	return $RETVAL
  }
  diff --git 
a/make-initrd/features/bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev 
b/make-initrd/features/bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev
new file mode 100644
index 0000000..f7315a3
--- /dev/null
+++ 
b/make-initrd/features/bootchain-waitdev/data/lib/bootchain-prepare.d/300-waitdev
@@ -0,0 +1,12 @@
+#!/bin/bash -efu
+
+dir=/.initrd/bootchain/waitdev
+mkdir -p -- "$dir"
+
+[ -z "${WAITDEV_TIMEOUT-}" ] ||
+	printf '%s\n' "$WAITDEV_TIMEOUT" >"$dir/TIMECNT"
+i=0
+while [ "$i" -lt "${WAITDEV:-0}" ]; do
+	touch "$dir/$i"
+	i=$((1 + $i))
+done
-- 
2.21.0




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

end of thread, other threads:[~2021-09-28  7:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 15:57 [make-initrd] [PATCH v1 21/41] fork pipeline: bootchain sysvinit script now use external hooks Leonid Krivoshein
2021-09-26 14:09 ` Alexey Gladkov
2021-09-26 19:53   ` Leonid Krivoshein
2021-09-27  9:09     ` Alexey Gladkov
2021-09-27 13:11       ` Leonid Krivoshein
2021-09-27 13:57         ` Alexey Gladkov
2021-09-27 17:22           ` Leonid Krivoshein
2021-09-28  0:40             ` Leonid Krivoshein
2021-09-28  7:11             ` Leonid Krivoshein

Make-initrd development discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
		make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
	public-inbox-index make-initrd

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.make-initrd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git