From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 26 Sep 2021 16:09:17 +0200 From: Alexey Gladkov To: make-initrd@lists.altlinux.org Message-ID: <20210926140917.4xky7nfnlemy4jh3@example.org> References: <7636585b-202d-95e0-eb0a-d320f69cc77a@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7636585b-202d-95e0-eb0a-d320f69cc77a@gmail.com> Subject: Re: [make-initrd] [PATCH v1 21/41] fork pipeline: bootchain sysvinit script now use external hooks X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Sep 2021 14:09:19 -0000 Archived-At: List-Archive: On Fri, Sep 24, 2021 at 06:57:45PM +0300, Leonid Krivoshein wrote: Что это за хуки и зачем они нужны ? > --- > .../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 > > > _______________________________________________ > Make-initrd mailing list > Make-initrd@lists.altlinux.org > https://lists.altlinux.org/mailman/listinfo/make-initrd > -- Rgrds, legion