-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuvm.sh
More file actions
executable file
·43 lines (35 loc) · 806 Bytes
/
uvm.sh
File metadata and controls
executable file
·43 lines (35 loc) · 806 Bytes
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
#!/bin/bash
errf() { printf "${@}" >&2; exit 1; }
# import ${qvmdir} variable
which evars.sh &>/dev/null || errf "evars.sh not found\n"
source $(which evars.sh)
print_help() { errf "Usage: $(basename ${0}) <vmname> <a|d|l> [device_name]\n"; }
vmname=${1}
action=${2}
devname=${3}
vmdir=${qvmdir}/${vmname}
vmexec="${vmdir}/run.sh"
case "${action}" in
a)
act="usb-attach"
;;
d)
act="usb-detach"
;;
l)
act="usb-list"
;;
*)
print_help
;;
esac
if [[ "${action}" != "l" ]]; then
# devid=${!devname}
declare -n devid=${devname}
[[ -n "${devid}" ]] || errf "undefined device: ${devname}\n"
fi
if [[ -d "${vmdir}" && -x "${vmexec}" ]]; then
"${vmexec}" ${act} ${devid}
else
errf "${vmname} not found\n"
fi