blob: 6260a8ac7c2894f6b92bb623925378d5726f5cb9 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#! /bin/sh
# Example script!
# This script looks up radsec srv records in DNS for the one
# realm given as argument, and creates a server template based
# on that. It currently ignores any weight or priority markers.
usage() {
echo "Usage: ${0} <realm>"
exit 1
}
test -n "${1}" || usage
REALM="${1}"
DIGCMD=$(command -v dig)
HOSTCMD=$(command -v host)
dig_it() {
${DIGCMD} +short srv _radsec._tcp.${REALM} |
while read line ; do
set $line ; PORT=$3 ; HOST=$4
echo "\thost ${HOST%.}:${PORT}"
done
}
host_it() {
${HOSTCMD} -t srv _radsec._tcp.${REALM} |
while read line ; do
set $line ; PORT=$7 ; HOST=$8
echo "\thost ${HOST%.}:${PORT}"
done
}
if test -x "${DIGCMD}" ; then
SERVERS=$(dig_it)
elif test -x "${HOSTCMD}" ; then
SERVERS=$(host_it)
else
echo "${0} requires either \"dig\" or \"host\" command."
exit 1
fi
if test -n "${SERVERS}" ; then
echo "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}"
exit 0
fi
exit 0
|