Debian Codegraph @

debian/scripts/xen-utils-wrapper

raw symbols SCIP
1 #!/bin/sh
2
3 # This portion is fast-path, avoid external programs, NOTE: NOT -e HERE!
4
5 COMMAND="${0##*/}"
6
7 DIR=/sys/hypervisor/version
8 # these return non-zero if hypervisor is absent, this is detected below
9 read major 2> /dev/null < $DIR/major
10 read minor 2> /dev/null < $DIR/minor
11 VERSION="$major.$minor"
12
13 DIR="/usr/lib/xen-$VERSION/bin"
14
15 [ -x "$DIR/$COMMAND" ] && exec "$DIR/$COMMAND" "$@"
16
17
18 # Certainly didn't work, now report failures, slower-path
19 set -e
20
21 error() {
22 err="$1"
23 shift
24 echo "ERROR: " "$@" >&2
25 exit $err
26 }
27
28 [ -e "/sys/hypervisor/type" ] || error 1 "Can't find hypervisor information in sysfs!"
29
30 read type < /sys/hypervisor/type
31 if [ "$type" != xen ]; then
32 [ -n "$type" ] || error 1 "Can't read hypervisor type from sysfs!"
33 error 1 "Hypervisor is not xen but '$type'!"
34 fi
35
36 if [ ! -d "/usr/lib/xen-$VERSION" ]; then
37 error 127 "Can't find version $VERSION of xen utils (maybe xen-utils-$VERSION was already removed before rebooting out of Xen $VERSION), bailing out!"
38 fi
39
40 error 127 "Unable to execute $DIR/$COMMAND"
41