#!/usr/bin/env bash #vatsim-win: virt-viewer launcher declare -A cmdstring declare -A uri declare -a opts cmdstring=([domain]="vatsim-ame" [startcmd]="virsh start ${cmdstring[domain]}") uri=([remote]="qemu+ssh://lark-desktop/system" [remotespice]="spice://10.10.0.106:5900" [local]="qemu:///system") case "$(uname -n)" in lark-desktop) 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 lark-desktop ${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[@]}" &