File: xen-toolstack

package info (click to toggle)
xen 4.4.1-9
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 35,032 kB
  • sloc: ansic: 407,163; python: 53,506; sh: 9,487; asm: 6,944; makefile: 5,716; ml: 4,138; perl: 2,990; lex: 311; pascal: 252; yacc: 43; xml: 35
file content (42 lines) | stat: -rwxr-xr-x 921 bytes parent folder | download | duplicates (4)
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/sh -e

configfile=/etc/default/xen

dir=$(. /usr/lib/xen-common/bin/xen-dir); ret=$?; [ $ret -eq 0 ] || exit $ret

check() {
    local PATH
    if [ "$1" = xm ] || [ "$1" = xl ]; then
        PATH="$dir/bin"
    else
        PATH="$dir/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    fi
    command -v "$1" || :
}

if [ -e $configfile ]; then
    . $configfile || true
fi

if [ "$TOOLSTACK" ]; then
    cmd=$(check "$TOOLSTACK")
    if [ "$cmd" ]; then
        echo "$cmd"
    else
        echo "WARING:  Can't find toolstack $TOOLSTACK, fallback to default!" >&2
        TOOLSTACK=
    fi
fi

if [ -z "$TOOLSTACK" ]; then
    cmd_xm=$(check xm)
    cmd_xl=$(check xl)
    if [ "$cmd_xm" ]; then
        echo "$cmd_xm"
    elif [ "$cmd_xl" ]; then
        echo "$cmd_xl"
    else
        echo "ERROR:  Toolstack not specifed and nothing detected, bailing out!" >&2
        exit 127
    fi
fi