utils: Add pb-console util
authorJeremy Kerr <jk@ozlabs.org>
Tue, 7 May 2013 07:39:53 +0000 (15:39 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 9 May 2013 00:47:54 +0000 (08:47 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
utils/Makefile.am
utils/pb-console [new file with mode: 0644]

index 67d64ccb60bc6ffd40c710e3eeee71283c7b29ad..3c13e6181a2f138f126886ce3e4c22f5cc3a16f0 100644 (file)
@@ -21,6 +21,7 @@ AM_CFLAGS = \
        $(DEFAULT_CFLAGS)
 
 dist_sbin_SCRIPTS = pb-udhcpc
+pkglibexec_SCRIPTS = pb-console
 
 sbin_PROGRAMS = pb-event
 
diff --git a/utils/pb-console b/utils/pb-console
new file mode 100644 (file)
index 0000000..636c5ad
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+ui=petitboot-nc
+shell=sh
+
+detach=0
+
+while [ -n "$1" ]
+do
+       case "$1" in
+       -d)
+               detach=1
+               ;;
+       --)
+               ;;
+       *)
+               console=$1
+               ;;
+       esac
+       shift
+done
+
+if [ -n "$console" -a "${console#/dev/}" = "$console" ]
+then
+       console="/dev/$console"
+fi
+
+pb_loop() {
+       while :
+       do
+               $ui
+               echo "Exiting petitboot. Type 'exit' to return"
+               $shell
+       done
+}
+
+if [ -n "$console" ]
+then
+       exec <$console >$console 2>&1
+fi
+
+if [ "$detach" = 1 ]
+then
+       (
+               pb_loop
+       ) &
+else
+       pb_loop
+fi