Browse Source

package/petitboot: run script when exiting to shell

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>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
Reza Arbab 1 year ago
parent
commit
d5ba2db401
2 changed files with 13 additions and 0 deletions
  1. 10 0
      package/petitboot/pb-shell
  2. 3 0
      package/petitboot/petitboot.mk

+ 10 - 0
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

+ 3 - 0
package/petitboot/petitboot.mk

@@ -30,6 +30,7 @@ PETITBOOT_CONF_OPTS = \
 	--without-twin-x11 \
 	--without-twin-x11 \
 	$(if $(BR2_PACKAGE_BUSYBOX),--enable-busybox,--disable-busybox) \
 	$(if $(BR2_PACKAGE_BUSYBOX),--enable-busybox,--disable-busybox) \
 	HOST_PROG_KEXEC=/usr/sbin/kexec \
 	HOST_PROG_KEXEC=/usr/sbin/kexec \
+	HOST_PROG_SH=/usr/libexec/petitboot/pb-shell \
 	HOST_PROG_SHUTDOWN=/usr/libexec/petitboot/kexec-restart
 	HOST_PROG_SHUTDOWN=/usr/libexec/petitboot/kexec-restart
 
 
 # HPA and Busybox tftp are supported. HPA tftp is part of Buildroot's tftpd
 # HPA and Busybox tftp are supported. HPA tftp is part of Buildroot's tftpd
@@ -94,6 +95,8 @@ define PETITBOOT_POST_INSTALL
 		$(TARGET_DIR)/etc/init.d/S15pb-discover
 		$(TARGET_DIR)/etc/init.d/S15pb-discover
 	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/pb-console \
 	$(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/pb-console \
 		$(TARGET_DIR)/etc/init.d/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
 	mkdir -p $(TARGET_DIR)/etc/udev/rules.d
 	for port in $(PETITBOOT_GETTY_PORT); do \
 	for port in $(PETITBOOT_GETTY_PORT); do \