#!/bin/bash set -e fail () { printf >&2 "%s: %s\n" "$0" "$*"; exit 127; } if test -f /etc/lsb-release; then . /etc/lsb-release; fi d="${USERV_U_distro:-$DISTRIB_CODENAME}" n="${USERV_U_nominum:-adt}" nd="${n}_${d}" case "$nd" in */*|.*|*.*|*_*_*) fail 'dangerous format in distro or nominum' ;; adt*) ;; *) fail 'userv adtxenlvm only supports nominums starting with adt' ;; esac nddir=/var/lib/autopkgtest/xenlvm/"$nd" test -d "$nddir" || fail 'unknown distro or nominum' run () { base="$1"; shift exec "$base" --adt-distro="$d" --adt-nominum="$n" "$@" } case "$1" in with) run adt-xenlvm-with-testbed sh -c 'echo y && exec cat' ;; pon0) run adt-xenlvm-on-testbed -- --print0-command ;; *) fail 'unknown mode' esac