diff mbox series

[v5,4/5] package/petitboot: run script when exiting to shell

Message ID 20240207175135.1532037-5-arbab@linux.ibm.com
State New
Headers show
Series package/petitboot: misc fixes/enhancement | expand

Commit Message

Reza Arbab Feb. 7, 2024, 5:51 p.m. UTC
When the user selects the shell escape option from the petitboot menu,
reset the terminal so output is raw rather than being confined to the
ncurses window set up for the petitboot menu, and print some helpful
text before running the shell.

To do this, override the default HOST_PROG_SH (/bin/sh) with a small
script. Doing so also enables someone to customize this behavior by
overlaying a different script.

Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
 package/petitboot/pb-shell     | 10 ++++++++++
 package/petitboot/petitboot.mk |  3 +++
 2 files changed, 13 insertions(+)
 create mode 100644 package/petitboot/pb-shell
diff mbox series

Patch

diff --git a/package/petitboot/pb-shell b/package/petitboot/pb-shell
new file mode 100644
index 000000000000..99887c3f3b87
--- /dev/null
+++ b/package/petitboot/pb-shell
@@ -0,0 +1,10 @@ 
+#!/bin/sh
+
+reset
+
+cat <<EOM
+Exiting petitboot. Type 'exit' to return.
+You may run 'pb-sos' to gather diagnostic data.
+EOM
+
+exec /bin/sh
diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk
index 291083269ae9..e2f762842534 100644
--- a/package/petitboot/petitboot.mk
+++ b/package/petitboot/petitboot.mk
@@ -29,6 +29,7 @@  PETITBOOT_CONF_OPTS = \
 	--without-twin-x11 \
 	$(if $(BR2_PACKAGE_BUSYBOX),--enable-busybox,--disable-busybox) \
 	HOST_PROG_KEXEC=/usr/sbin/kexec \
+	HOST_PROG_SH=/usr/libexec/petitboot/pb-shell \
 	HOST_PROG_SHUTDOWN=/usr/sbin/kexec-restart
 
 # HPA and Busybox tftp are supported. HPA tftp is part of Buildroot's tftpd
@@ -81,6 +82,8 @@  define PETITBOOT_POST_INSTALL
 		$(TARGET_DIR)/usr/sbin/kexec-restart
 	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/pb-console \
 		$(TARGET_DIR)/etc/init.d/pb-console
+	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/pb-shell \
+		$(TARGET_DIR)/usr/libexec/petitboot/pb-shell
 
 	mkdir -p $(TARGET_DIR)/etc/udev/rules.d
 	for port in $(PETITBOOT_GETTY_PORT); do \