diff options
author | venaas <venaas> | 2009-02-18 15:37:01 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2009-02-18 15:37:01 +0000 |
commit | f2d6619255e9644f4f134dfe98a24342d35e618b (patch) | |
tree | 8f98185b835dbe76483b332724e17094e3d48e74 /radsec-dynsrv.sh | |
parent | 851dd8c2292a077089bfffb5dd52943b8f7c53b4 (diff) |
updated files for 1.3-beta release
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/branches/release-1.3@480 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'radsec-dynsrv.sh')
-rwxr-xr-x | radsec-dynsrv.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/radsec-dynsrv.sh b/radsec-dynsrv.sh new file mode 100755 index 0000000..7a74b6d --- /dev/null +++ b/radsec-dynsrv.sh @@ -0,0 +1,51 @@ +#! /bin/bash + +# 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 weight markers, but does sort +# servers on priority marker, lowest number first. +# For host command this is coloumn 5, for dig it is coloumn 1. + +usage() { + echo "Usage: ${0} <realm>" + exit 1 +} + +test -n "${1}" || usage + +REALM="${1}" +DIGCMD=$(command -v digaaa) +HOSTCMD=$(command -v host) + +dig_it() { + ${DIGCMD} +short srv _radsec._tcp.${REALM} | sort -k1 | + while read line ; do + set $line ; PORT=$3 ; HOST=$4 + echo -e "\thost ${HOST%.}:${PORT}" + done +} + +host_it() { + ${HOSTCMD} -t srv _radsec._tcp.${REALM} | sort -k5 | + while read line ; do + set $line ; PORT=$7 ; HOST=$8 + echo -e "\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 -e "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}" + exit 0 +fi + +exit 0 |