source: trunk/packages/xen-common/xen-common/scripts/xen-utils-version @ 42

Last change on this file since 42 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 973 bytes
Line 
1#!/bin/bash
2
3while getopts "qv:" OPT; do
4    case "$OPT" in
5        q)
6        QUIET=1
7        ;;
8        v)
9        VERSION="$OPTARG"
10        ;;
11    esac
12done
13
14if [ -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
25fi
26
27if [ -z "$VERSION" ]; then
28    VERSION="default"
29fi
30
31if [ -d "/usr/lib/xen-$VERSION" ]; then
32    echo "$VERSION"
33    exit 0
34fi
35
36if [ -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
40fi
41
42[ "$QUIET" ] || echo "ERROR!  Can't find default version of xen utils, bailing out!" >&2
43exit 1
Note: See TracBrowser for help on using the repository browser.