56 lines
1.2 KiB
Bash
Executable File
56 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
#kd-win: virt-viewer launcher
|
|
|
|
declare -A cmdstring
|
|
declare -A uri
|
|
declare -a opts
|
|
|
|
cmdstring=([domain]="win10"
|
|
[startcmd]="virsh start ${cmdstring[domain]}")
|
|
|
|
uri=([remote]="qemu+ssh://kd-laptop/system"
|
|
[remotespice]="spice://10.10.0.14:5900"
|
|
[local]="qemu:///system")
|
|
|
|
|
|
case "$(uname -n)" in
|
|
kd-laptop)
|
|
cmdstring+=([cmd]="virt-viewer"
|
|
[uri]=${uri[local]}
|
|
[manuri]=${uri[local]}
|
|
[fullstartcmd]=${cmdstring[startcmd]})
|
|
opts=("--connect=${cmdstring[uri]}"
|
|
"--wait"
|
|
"--reconnect"
|
|
"--direct"
|
|
"${cmdstring[domain]}")
|
|
;;
|
|
*)
|
|
cmdstring+=([cmd]="remote-viewer"
|
|
[uri]=${uri[remotespice]}
|
|
[manuri]=${uri[remote]}
|
|
[fullstartcmd]="ssh kd-laptop ${cmdstring[startcmd]}")
|
|
opts=("${cmdstring[uri]}")
|
|
;;
|
|
esac
|
|
|
|
while :; do
|
|
case $1 in
|
|
-m)
|
|
cmdstring+=([cmd]="virt-manager")
|
|
opts=("--connect=${cmdstring[manuri]}"
|
|
"--show-domain-editor"
|
|
"${cmdstring[domain]}")
|
|
;;
|
|
*) break;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if grep "${cmdstring[domain]}" <(virsh list --state-shutoff --name); then
|
|
${cmdstring[fullstartcmd]}
|
|
fi
|
|
|
|
${cmdstring[cmd]} "${opts[@]}" &
|