-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·77 lines (70 loc) · 1.88 KB
/
entrypoint.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
rootTag="$HPQLOCFG_ROOT_TAG"
tempInput=/tmp/ribcl.tmp.xml
hpCmdLog=/tmp/hpqlocfg.log
rm -f $tempInput $hpCmdLog
iloArgs=( )
xmllintArgs=( --format )
while [[ $# -gt 0 ]]; do
if [[ $1 = --xpath ]]; then
shift
xmllintArgs=( "${xmllintArgs[@]}" --xpath "$1" )
shift
elif [[ $1 = -s ]]; then
shift
iloServer="$1"
shift
elif [[ $1 = -u ]]; then
shift
iloUser="$1"
shift
elif [[ $1 = -p ]]; then
shift
iloPassword="$1"
shift
elif [[ $1 = -f && $2 = - ]]; then # Read from stdin
shift
shift
cat > $tempInput
iloArgs=( "${iloArgs[@]}" -f $tempInput )
elif [[ $1 = -f && -f $2 && $2 != *.xml ]]; then # Allow file extensions other than .xml
ln -sfn $2 $tempInput
shift
shift
iloArgs=( "${iloArgs[@]}" -f $tempInput )
else
iloArgs=( "${iloArgs[@]}" "$1" )
shift
fi
done
if [[ -n ${iloServer+x} ]]; then
iloArgs=( "${iloArgs[@]}" -s "$iloServer" )
elif [[ -n $ILO_SERVER ]]; then
iloArgs=( "${iloArgs[@]}" -s "$ILO_SERVER" )
fi
if [[ -n ${iloUser+x} ]]; then
iloArgs=( "${iloArgs[@]}" -u "$iloUser" )
elif [[ -n $ILO_USER ]]; then
iloArgs=( "${iloArgs[@]}" -u "$ILO_USER" )
fi
if [[ -n ${iloPassword+x} ]]; then
iloArgs=( "${iloArgs[@]}" -p "$iloPassword" )
elif [[ -n $ILO_PASSWORD ]]; then
iloArgs=( "${iloArgs[@]}" -p "$ILO_PASSWORD" )
fi
WINEDEBUG=-all wine /bin/hp/HPQLOCFG.exe "${iloArgs[@]}" | \
tr -d '\r' | \
tee $hpCmdLog | \
grep -e '^<' -e '^ ' | \
grep -v '<\?xml' | \
{
output="$(cat)"
if [[ -z $output ]]; then
cat $hpCmdLog >&2
exit 1
elif [[ -n $rootTag ]]; then
echo "<$rootTag>$output</$rootTag>" | xmllint "${xmllintArgs[@]}" -
else
echo "$output"
fi
}