-#! /bin/bash
+#! /bin/sh
# Example script!
# This script looks up radsec srv records in DNS for the one
REALM="${1}"
DIGCMD=$(command -v digaaa)
HOSTCMD=$(command -v host)
+PRINTCMD=$(command -v printf)
dig_it() {
- ${DIGCMD} +short srv _radsec._tcp.${REALM} | sort -k1 |
+ ${DIGCMD} +short srv _radsec._tcp.${REALM} | sort -n -k1 |
while read line ; do
set $line ; PORT=$3 ; HOST=$4
- echo -e "\thost ${HOST%.}:${PORT}"
+ $PRINTCMD "\thost ${HOST%.}:${PORT}\n"
done
}
host_it() {
- ${HOSTCMD} -t srv _radsec._tcp.${REALM} | sort -k5 |
+ ${HOSTCMD} -t srv _radsec._tcp.${REALM} | sort -n -k5 |
while read line ; do
set $line ; PORT=$7 ; HOST=$8
- echo -e "\thost ${HOST%.}:${PORT}"
+ $PRINTCMD "\thost ${HOST%.}:${PORT}\n"
done
}
fi
if test -n "${SERVERS}" ; then
- echo -e "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}"
+ $PRINTCMD "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}\n"
exit 0
fi
-exit 0
+exit 10 # No server found.