diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-16 13:55:03 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-05-20 11:27:06 +0800 |
commit | d28c07b5e23237a97387435e157e248e19128598 (patch) | |
tree | 0f14189bcebd0b7783b319f887c349317d64a90a /utils/pb-console | |
parent | 6e2d2e78a178a40bcbce903020626c62f74bf046 (diff) | |
download | talos-petitboot-d28c07b5e23237a97387435e157e248e19128598.tar.gz talos-petitboot-d28c07b5e23237a97387435e157e248e19128598.zip |
utils/pb-console: use getty rather than exec
exec is a bit flaky for starting on consoles, so use getty instead.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'utils/pb-console')
-rw-r--r-- | utils/pb-console | 89 |
1 files changed, 58 insertions, 31 deletions
diff --git a/utils/pb-console b/utils/pb-console index 00b25ac..81be218 100644 --- a/utils/pb-console +++ b/utils/pb-console @@ -6,63 +6,90 @@ ui=petitboot-nc shell=sh - +getty=/sbin/getty +use_getty=0 detach=0 usage() { cat >&2 <<EOF -pb-console [OPTIONS] console_dev +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 } -while [ -n "$1" ] +opts=$(getopt --options 'hdg::s:u:' \ + --long 'help,detach,getty::,shell:,ui:' \ + -- "$@") +[ $? = 0 ] || exit 1 + +eval set -- "$opts" + +while : do case "$1" in - --detach | -d) + -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 ;; *) - console=$1 - ;; + echo "getopt error" + exit 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" ] +if [ "$use_getty" = 1 ] then - exec <$console >$console 2>&1 + if [ -n "$getty_arg" ] + then + getty="$getty_arg" + fi + if [ "$detach" = 1 ] + then + $getty -l $0 "$@" & + else + exec $getty -l $0 "$@" + fi fi -if [ "$detach" = 1 ] -then - ( - pb_loop - ) & -else - pb_loop -fi +while : +do + $ui + echo "Exiting petitboot. Type 'exit' to return." + $shell +done |