utils: Add pb-exec wrapper
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 25 Jul 2017 06:08:11 +0000 (16:08 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 15 Aug 2017 03:03:28 +0000 (13:03 +1000)
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>
utils/pb-exec [new file with mode: 0755]

diff --git a/utils/pb-exec b/utils/pb-exec
new file mode 100755 (executable)
index 0000000..bfe13f6
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# Run a program specified by Petitboot.
+$@
+echo "$0 ran '$@'"
+
+# Wait for the user to exit back to Petitboot.
+read -n 1 -r -p "Press ENTER to return to Petitboot or any other key to drop to a shell" key
+
+if [ "$key" == "" ]; then
+       echo "Returning to Petitboot.."
+       exit 0
+fi
+
+printf "\nLaunching shell. Type 'exit' to return\n"
+/bin/sh