summaryrefslogtreecommitdiff
path: root/radsec-dynsrv.sh
diff options
context:
space:
mode:
authorkolla <kolla>2009-02-13 15:37:17 +0000
committerkolla <kolla@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2009-02-13 15:37:17 +0000
commit3243522b96d1ec374aeb56acf2974033a78ace1b (patch)
treeae0382fc1c4d8c2028d96d18ab07c924ee883136 /radsec-dynsrv.sh
parentf5642669e511539ab024aae430798e98a638c513 (diff)
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
Diffstat (limited to 'radsec-dynsrv.sh')
-rwxr-xr-xradsec-dynsrv.sh49
1 files changed, 49 insertions, 0 deletions
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} <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 radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}"
+ exit 0
+fi
+
+exit 0