Line | |
---|
1 | #!/bin/bash |
---|
2 | |
---|
3 | while getopts "qv:" OPT; do |
---|
4 | case "$OPT" in |
---|
5 | q) |
---|
6 | QUIET=1 |
---|
7 | ;; |
---|
8 | v) |
---|
9 | VERSION="$OPTARG" |
---|
10 | ;; |
---|
11 | esac |
---|
12 | done |
---|
13 | |
---|
14 | if [ -z "$VERSION" ]; then |
---|
15 | if [ -d "/sys/hypervisor" ]; then |
---|
16 | if [ "$(cat /sys/hypervisor/type)" = xen ]; then |
---|
17 | dir=/sys/hypervisor/version/ |
---|
18 | VERSION="$(cat $dir/major).$(cat $dir/minor)$(cat $dir/extra)" |
---|
19 | else |
---|
20 | [ "$QUIET" ] || echo "WARING! Can't read type from sysfs!" >&2 |
---|
21 | fi |
---|
22 | else |
---|
23 | [ "$QUIET" ] || echo "WARING! Can't find hypervisor information in sysfs!" >&2 |
---|
24 | fi |
---|
25 | fi |
---|
26 | |
---|
27 | if [ -z "$VERSION" ]; then |
---|
28 | VERSION="default" |
---|
29 | fi |
---|
30 | |
---|
31 | if [ -d "/usr/lib/xen-$VERSION" ]; then |
---|
32 | echo "$VERSION" |
---|
33 | exit 0 |
---|
34 | fi |
---|
35 | |
---|
36 | if [ -d "/usr/lib/xen-default" ]; then |
---|
37 | [ "$QUIET" ] || echo "WARING! Can't find version $VERSION of xen utils, fallback to default version!" >&2 |
---|
38 | echo "default" |
---|
39 | exit 0 |
---|
40 | fi |
---|
41 | |
---|
42 | [ "$QUIET" ] || echo "ERROR! Can't find default version of xen utils, bailing out!" >&2 |
---|
43 | exit 1 |
---|
Note: See
TracBrowser
for help on using the repository browser.