summaryrefslogtreecommitdiffstats
path: root/utils/pb-console
blob: 00b25acf44c8d996bafaf178673805766a0f88b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
#
# Petitboot utility script for running a petitboot UI program
# on a console tty.
#

ui=petitboot-nc
shell=sh

detach=0

usage() {
	cat >&2 <<EOF
pb-console [OPTIONS] console_dev
OPTIONS
     -d, --detach
             Start in a detached (background) state.
     -h, --help
             Print a help message.
EOF
	exit 1
}

while [ -n "$1" ]
do
	case "$1" in
	--detach | -d)
		detach=1
		;;
	--help | -h)
		usage
		;;
	--)
		;;
	*)
		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
OpenPOWER on IntegriCloud