diff options
Diffstat (limited to 'utils/pb-console')
-rw-r--r-- | utils/pb-console | 116 |
1 files changed, 12 insertions, 104 deletions
diff --git a/utils/pb-console b/utils/pb-console index 282fca1..924e1c3 100644 --- a/utils/pb-console +++ b/utils/pb-console @@ -3,91 +3,8 @@ # Petitboot utility script for running a petitboot UI program # on a console tty. # - -ui=petitboot-nc -shell=sh -getty=/sbin/getty -use_getty=0 -detach=0 -pb_config=pb-config - -usage() { - cat >&2 <<EOF -pb-console [OPTIONS] -- [ARGS] -OPTIONS - -d, --detach - Start in a detached (background) state. - - -g, --getty[=PATH] - Start a getty (specified by PATH, otherwise $getty), - passing additional ARGS to the getty process - - -s, --shell=PATH - Use PATH as the exit-to-shell shell - - -u, --ui=PATH - Use PATH as the petitboot UI - - -h, --help - Print a help message. -EOF - exit 1 -} - -opts=$(getopt --options 'hdg::s:u:' \ - --long 'help,detach,getty::,shell:,ui:' \ - -- "$@") -[ $? = 0 ] || exit 1 - -eval set -- "$opts" - -while : -do - case "$1" in - -d | --detach) - detach=1 - shift - ;; - -g | --getty) - use_getty=1 - getty_arg="$2" - shift 2 - ;; - -s | --shell) - shell="$2" - shift 2 - ;; - -u | --ui) - ui="$2" - shift 2 - ;; - --help | -h) - usage - ;; - --) - shift - break - ;; - *) - echo "getopt error" - exit 1 - esac -done - -if [ "$use_getty" = 1 ] -then - if [ -n "$getty_arg" ] - then - getty="$getty_arg" - fi - if [ "$detach" = 1 ] - then - $getty -l $0 "$@" & - exit - else - exec $getty -l $0 "$@" - fi -fi +# Copyright © 2017 Raptor Engineering, LLC +# Released under the terms of the GNU GPL v2 for f in /etc/environment /etc/locale do @@ -97,14 +14,12 @@ do fi done -# we force local terminals to use the linux termcap definition case "$(tty)" in /dev/tty[0-9]*) export TERM=linux ;; esac -# we may have been run from udev - ensure we have a sensible PATH if [ -z "$PATH" ] then PATH=/usr/bin:/usr/sbin:/bin:/sbin @@ -112,21 +27,14 @@ fi PATH=/var/lib/pb-plugins/bin:$PATH export PATH -verbose_opt= -if $pb_config debug | grep -q enabled -then - verbose_opt=--verbose -fi - -# kernel messages may write over the ncurses ui - change log level to only -# show particularly important messages -dmesg -n 1 +echo 0 > /proc/sys/kernel/printk +clear -while : -do - $ui $verbose_opt - reset - echo "Exiting petitboot. Type 'exit' to return." - echo "You may run 'pb-sos' to gather diagnostic data" - $shell -done +if [ -e /etc/pb-lockdown ]; then + echo "Failed to launch petitboot, rebooting!" + echo 1 > /proc/sys/kernel/sysrq + echo b > /proc/sysrq-trigger +else + echo "Failed to launch petitboot, dropping to a shell" + exec sh +fi |