2020-08-11 17:05:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
#kd-win: virt-viewer launcher
|
|
|
|
|
2020-08-11 17:06:59 +00:00
|
|
|
declare -A cmdstring
|
|
|
|
declare -A uri
|
|
|
|
declare -a opts
|
|
|
|
|
2020-09-09 16:14:36 +00:00
|
|
|
cmdstring=([domain]="win10"
|
|
|
|
[startcmd]="virsh start ${cmdstring[domain]}")
|
2020-08-11 17:06:59 +00:00
|
|
|
|
|
|
|
uri=([remote]="qemu+ssh://kd-laptop/system"
|
2020-08-11 17:13:56 +00:00
|
|
|
[remotespice]="spice://10.10.0.14:5900"
|
2020-08-11 17:06:59 +00:00
|
|
|
[local]="qemu:///system")
|
|
|
|
|
|
|
|
|
|
|
|
case "$(uname -n)" in
|
|
|
|
kd-laptop)
|
2020-08-12 15:12:50 +00:00
|
|
|
cmdstring+=([cmd]="virt-viewer"
|
2020-08-11 17:06:59 +00:00
|
|
|
[uri]=${uri[local]}
|
2020-09-09 16:14:36 +00:00
|
|
|
[manuri]=${uri[local]}
|
|
|
|
[fullstartcmd]=${cmdstring[startcmd]})
|
2020-08-11 17:06:59 +00:00
|
|
|
opts=("--connect=${cmdstring[uri]}"
|
|
|
|
"--wait"
|
|
|
|
"--reconnect"
|
|
|
|
"--direct"
|
|
|
|
"${cmdstring[domain]}")
|
|
|
|
;;
|
|
|
|
*)
|
2020-08-12 15:12:50 +00:00
|
|
|
cmdstring+=([cmd]="remote-viewer"
|
2020-08-11 17:06:59 +00:00
|
|
|
[uri]=${uri[remotespice]}
|
2020-09-09 16:14:36 +00:00
|
|
|
[manuri]=${uri[remote]}
|
|
|
|
[fullstartcmd]="ssh kd-laptop ${cmdstring[startcmd]}")
|
2020-08-11 17:06:59 +00:00
|
|
|
opts=("${cmdstring[uri]}")
|
|
|
|
;;
|
|
|
|
esac
|
2020-08-11 17:05:17 +00:00
|
|
|
|
2020-08-11 17:06:00 +00:00
|
|
|
while :; do
|
|
|
|
case $1 in
|
|
|
|
-m)
|
2020-08-12 15:12:50 +00:00
|
|
|
cmdstring+=([cmd]="virt-manager")
|
2020-08-11 17:06:59 +00:00
|
|
|
opts=("--connect=${cmdstring[manuri]}"
|
2020-09-24 14:13:35 +00:00
|
|
|
"--show-domain-editor"
|
|
|
|
"${cmdstring[domain]}")
|
2020-08-11 17:06:00 +00:00
|
|
|
;;
|
|
|
|
*) break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2020-09-09 16:14:36 +00:00
|
|
|
if grep "${cmdstring[domain]}" <(virsh list --state-shutoff --name); then
|
|
|
|
${cmdstring[fullstartcmd]}
|
|
|
|
fi
|
|
|
|
|
2020-08-11 17:06:59 +00:00
|
|
|
${cmdstring[cmd]} "${opts[@]}" &
|