summaryrefslogtreecommitdiffstats
path: root/buildfile
blob: a3d506aeb768a5a9b416b08fc009ab3173c51542 (plain)
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
#!/bin/sh

. $(dirname $0)/settings.sh
$BINDIR/prepare-repository

verbose=0
if [ "$1" = "-v" ]; then
    verbose=1
    shift
fi

if [ -z "$1" -o -z "$2" ]; then
    echo "Usage: $0 <filename> <hostname>"
    exit 1
fi

# check hostname
if ! grep -q "<Client profile=\"[^\"]*\" \([a-z]\\+=\"[^\"]*\" \)*name=\"$2\"" $REPO/Metadata/clients.xml; then
    echo "Host '$2' not found."
    exit 1
fi

bcfg2-info -Q "$REPO" buildfile "$@" | \
    if [ "$verbose" = "1" ]; then
        awk '/<Path/,/<\/Path>/{print}'
    else
        # only output lines between <Path></Path> (excluding </Path>)
        awk '/<\/Path>/{p=0} /<Path/{p=1} p' | \
        # remove opening path tag
        sed '1s/<Path\( [^=>]*="[^"]*"\)*>//'
    fi