[04/10] utils: Add pb-exec wrapper

Submitted by Sam Mendoza-Jonas on June 23, 2017, 6:27 a.m.

Details

Message ID 20170623062709.16035-5-sam@mendozajonas.com
State New
Headers show

Commit Message

Sam Mendoza-Jonas June 23, 2017, 6:27 a.m.
Add a small wrapper script for the Petitboot UI to call interactable
programs with. The wrapper calls the program and waits for user input
before returning to the Petitboot UI.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 configure.ac        |  1 +
 lib/system/system.c |  1 +
 lib/system/system.h |  1 +
 utils/Makefile.am   |  2 +-
 utils/pb-exec       | 15 +++++++++++++++
 5 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100755 utils/pb-exec

Patch hide | download patch | download mbox

diff --git a/configure.ac b/configure.ac
index 72348d6..a87120a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -333,6 +333,7 @@  DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
 DEFINE_HOST_PROG(IP, ip, [/sbin/ip])
 DEFINE_HOST_PROG(UDHCPC, udhcpc, [/sbin/udhcpc])
 DEFINE_HOST_PROG(PB_PLUGIN, pb-plugin, [/usr/sbin/pb-plugin])
+DEFINE_HOST_PROG(PB_EXEC, pb-exec, [/usr/sbin/pb-exec])
 
 AC_ARG_WITH(
     [tftp],
diff --git a/lib/system/system.c b/lib/system/system.c
index b04ebd4..f702bf8 100644
--- a/lib/system/system.c
+++ b/lib/system/system.c
@@ -29,6 +29,7 @@  const struct pb_system_apps pb_system_apps = {
 	.ip		= HOST_PROG_IP,
 	.udhcpc		= HOST_PROG_UDHCPC,
 	.pb_plugin	= HOST_PROG_PB_PLUGIN,
+	.pb_exec	= HOST_PROG_PB_EXEC,
 };
 
 #ifndef TFTP_TYPE
diff --git a/lib/system/system.h b/lib/system/system.h
index e50302a..1143e36 100644
--- a/lib/system/system.h
+++ b/lib/system/system.h
@@ -14,6 +14,7 @@  struct pb_system_apps {
 	const char *ip;
 	const char *udhcpc;
 	const char *pb_plugin;
+	const char *pb_exec;
 };
 
 extern const struct pb_system_apps pb_system_apps;
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 6c708eb..3ef3fe8 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -12,7 +12,7 @@ 
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-dist_sbin_SCRIPTS += utils/pb-udhcpc utils/pb-plugin utils/pb-sos
+dist_sbin_SCRIPTS += utils/pb-udhcpc utils/pb-plugin utils/pb-sos utils/pb-exec
 dist_pkglibexec_SCRIPTS = utils/pb-console
 sbin_PROGRAMS += utils/pb-event utils/pb-config
 
diff --git a/utils/pb-exec b/utils/pb-exec
new file mode 100755
index 0000000..f770afc
--- /dev/null
+++ b/utils/pb-exec
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+
+# Run a program specified by Petitboot. Assume for now this is a single program
+# with no arguments.
+$1
+
+# Wait for the user to exit back to Petitboot.
+while :; do
+	read -r -p "Press ENTER to return to Petitboot" key
+
+	if [ "$key" == "" ]; then
+		echo "Returning to Petitboot.."
+		exit 0
+	fi
+done