From 3243522b96d1ec374aeb56acf2974033a78ace1b Mon Sep 17 00:00:00 2001 From: kolla Date: Fri, 13 Feb 2009 15:37:17 +0000 Subject: Script for oppslag i DNS etter radsec-tjenere for realm git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@469 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- radsec-dynsrv.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 radsec-dynsrv.sh diff --git a/radsec-dynsrv.sh b/radsec-dynsrv.sh new file mode 100755 index 0000000..c4c920c --- /dev/null +++ b/radsec-dynsrv.sh @@ -0,0 +1,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} " + 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 radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}" + exit 0 +fi + +exit 0 -- cgit v1.1