diff mbox series

[RFC,1/1] initramfs-framework: support force reboot if fatal error occurs

Message ID 20240520153106.150218-1-igor.opaniuk@foundries.io
State Accepted, archived
Commit 6990855e91f2d5891e95995f3f4a1c3b5891c619
Headers show
Series [RFC,1/1] initramfs-framework: support force reboot if fatal error occurs | expand

Commit Message

Igor Opaniuk May 20, 2024, 3:31 p.m. UTC
Add support for force reboot in the case of fatal error. In some cases
it's better to force reboot (especially when hw watchdog is not
engaged) instead of waiting for 3600 seconds, for example in order to
trigger some recovery procedure during next boot procedure
(after unsuccessful OTA update etc).

ALso fix indendation issues in the fatal() function implementation.

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
---
 .../initrdscripts/initramfs-framework/init    | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)

Comments

Alexander Kanavin May 21, 2024, 11:17 a.m. UTC | #1
Seems ok to me, you can resend without the RFC.

Alex

On Mon, 20 May 2024 at 17:31, Igor Opaniuk via lists.openembedded.org
<igor.opaniuk=foundries.io@lists.openembedded.org> wrote:
>
> Add support for force reboot in the case of fatal error. In some cases
> it's better to force reboot (especially when hw watchdog is not
> engaged) instead of waiting for 3600 seconds, for example in order to
> trigger some recovery procedure during next boot procedure
> (after unsuccessful OTA update etc).
>
> ALso fix indendation issues in the fatal() function implementation.
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
> ---
>  .../initrdscripts/initramfs-framework/init    | 23 +++++++++++--------
>  1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
> index 567694aff7..e3d8caa0e1 100755
> --- a/meta/recipes-core/initrdscripts/initramfs-framework/init
> +++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
> @@ -54,17 +54,20 @@ debug() {
>  }
>
>  # Prints a message and start a endless loop
> +# Force reboot if init_fatal_reboot bootparam is set
>  fatal() {
> -    echo $1 >/dev/console
> -    echo >/dev/console
> -
> -    if [ -n "$bootparam_init_fatal_sh" ]; then
> -        sh
> -    else
> -       while [ "true" ]; do
> -               sleep 3600
> -       done
> -    fi
> +       echo $1 >/dev/console
> +       echo >/dev/console
> +
> +       if [ -n "$bootparam_init_fatal_reboot" ]; then
> +               reboot -f
> +       elif [ -n "$bootparam_init_fatal_sh" ]; then
> +               sh
> +       else
> +               while [ "true" ]; do
> +                       sleep 3600
> +               done
> +       fi
>  }
>
>  # Variables shared amoung modules
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#199595): https://lists.openembedded.org/g/openembedded-core/message/199595
> Mute This Topic: https://lists.openembedded.org/mt/106205536/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Igor Opaniuk May 21, 2024, 1:54 p.m. UTC | #2
Hello Alex,

On Tue, May 21, 2024 at 1:17 PM Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
>
> Seems ok to me, you can resend without the RFC.
I'll just send v2 without the RFC tag, thanks!

>
> Alex
>
> On Mon, 20 May 2024 at 17:31, Igor Opaniuk via lists.openembedded.org
> <igor.opaniuk=foundries.io@lists.openembedded.org> wrote:
> >
> > Add support for force reboot in the case of fatal error. In some cases
> > it's better to force reboot (especially when hw watchdog is not
> > engaged) instead of waiting for 3600 seconds, for example in order to
> > trigger some recovery procedure during next boot procedure
> > (after unsuccessful OTA update etc).
> >
> > ALso fix indendation issues in the fatal() function implementation.
> >
> > Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
> > ---
> >  .../initrdscripts/initramfs-framework/init    | 23 +++++++++++--------
> >  1 file changed, 13 insertions(+), 10 deletions(-)
> >
> > diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
> > index 567694aff7..e3d8caa0e1 100755
> > --- a/meta/recipes-core/initrdscripts/initramfs-framework/init
> > +++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
> > @@ -54,17 +54,20 @@ debug() {
> >  }
> >
> >  # Prints a message and start a endless loop
> > +# Force reboot if init_fatal_reboot bootparam is set
> >  fatal() {
> > -    echo $1 >/dev/console
> > -    echo >/dev/console
> > -
> > -    if [ -n "$bootparam_init_fatal_sh" ]; then
> > -        sh
> > -    else
> > -       while [ "true" ]; do
> > -               sleep 3600
> > -       done
> > -    fi
> > +       echo $1 >/dev/console
> > +       echo >/dev/console
> > +
> > +       if [ -n "$bootparam_init_fatal_reboot" ]; then
> > +               reboot -f
> > +       elif [ -n "$bootparam_init_fatal_sh" ]; then
> > +               sh
> > +       else
> > +               while [ "true" ]; do
> > +                       sleep 3600
> > +               done
> > +       fi
> >  }
> >
> >  # Variables shared amoung modules
> > --
> > 2.34.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#199595): https://lists.openembedded.org/g/openembedded-core/message/199595
> > Mute This Topic: https://lists.openembedded.org/mt/106205536/1686489
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
diff mbox series

Patch

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
index 567694aff7..e3d8caa0e1 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/init
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
@@ -54,17 +54,20 @@  debug() {
 }
 
 # Prints a message and start a endless loop
+# Force reboot if init_fatal_reboot bootparam is set
 fatal() {
-    echo $1 >/dev/console
-    echo >/dev/console
-
-    if [ -n "$bootparam_init_fatal_sh" ]; then
-        sh
-    else
-	while [ "true" ]; do
-		sleep 3600
-	done
-    fi
+	echo $1 >/dev/console
+	echo >/dev/console
+
+	if [ -n "$bootparam_init_fatal_reboot" ]; then
+		reboot -f
+	elif [ -n "$bootparam_init_fatal_sh" ]; then
+		sh
+	else
+		while [ "true" ]; do
+			sleep 3600
+		done
+	fi
 }
 
 # Variables shared amoung modules