forked from pr1ntf/iohyve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathioh-console
36 lines (32 loc) · 984 Bytes
/
ioh-console
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
#!/bin/sh
# List consoles in use
__conlist() {
local pool="$(zfs list -H | grep iohyve | cut -d '/' -f 1 | head -n 1)"
local guestlist="$(zfs list -H | grep iohyve | grep -v -e ISO -e disk -e Firmware | sed 1d | cut -f 1 | cut -d '/' -f 3)"
(
printf 'Guest\tConsole\n'
for guest in $guestlist; do
local con="$(zfs get -H -o value iohyve:con $pool/iohyve/$guest)"
printf $guest'\t'$con'\n'
done
) | column -t
}
# Run console
__console() {
local name=$2
if [ -z "$name" ]; then
printf "missing argument\nusage:\n"
printf "\tconsole <name>\n"
exit 1
fi
local pool="$(zfs list -H -t volume | grep iohyve/$name.*disk0 | cut -d '/' -f 1-3 | head -n 1)"
local con="$(zfs get -H -o value iohyve:con $pool)"
echo "Starting console on $name..."
echo "~~. to escape console [uses cu(1) for console]"
cu -l /dev/${con}B -s 9600
}
# Reset all consoles. This kills the cu(1)
__conreset() {
# XXX This also kills cu(1) processes not started by iohyve.
killall cu
}