4 # This script looks up radsec srv records in DNS for the one
5 # realm given as argument, and creates a server template based
6 # on that. It currently ignores weight markers, but does sort
7 # servers on priority marker, lowest number first.
8 # For host command this is column 5, for dig it is column 1.
11 echo "Usage: ${0} <realm>"
15 test -n "${1}" || usage
18 DIGCMD=$(command -v dig)
19 HOSTCMD=$(command -v host)
22 ${DIGCMD} +short srv $SRV_HOST | sort -n -k1 |
24 set $line ; PORT=$3 ; HOST=$4
25 echo -e "\thost ${HOST%.}:${PORT}"
30 ${DIGCMD} +short naptr ${REALM} | grep x-eduroam:radius.tls | sort -n -k1 |
32 set $line ; TYPE=$3 ; HOST=$6
33 if [ "$TYPE" = "\"s\"" ]; then
41 ${HOSTCMD} -t srv $SRV_HOST | sort -n -k5 |
43 set $line ; PORT=$7 ; HOST=$8
44 echo -e "\thost ${HOST%.}:${PORT}"
49 ${HOSTCMD} -t naptr ${REALM} | grep x-eduroam:radius.tls | sort -n -k5 |
51 set $line ; TYPE=$7 ; HOST=${10}
52 if [ "$TYPE" = "\"s\"" ]; then
59 if [ -x "${DIGCMD}" ]; then
60 SERVERS=$(dig_it_naptr)
61 elif [ -x "${HOSTCMD}" ]; then
62 SERVERS=$(host_it_naptr)
64 echo "${0} requires either \"dig\" or \"host\" command."
68 if [ -n "${SERVERS}" ]; then
69 echo -e "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}"
73 exit 10 # No server found.