From 4af6a3dd7a1f842afe18aac99a19832615b67539 Mon Sep 17 00:00:00 2001 From: Tom Grennan Date: Wed, 28 Nov 2007 12:01:56 -0800 Subject: add utility function to return allowed hosts/addresses during completion and help --- functions/allowed/hosts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 functions/allowed/hosts (limited to 'functions') diff --git a/functions/allowed/hosts b/functions/allowed/hosts new file mode 100755 index 0000000..d608361 --- /dev/null +++ b/functions/allowed/hosts @@ -0,0 +1,24 @@ +# +# utility function used by node.tag/node.def to list "allowed" +# or expanded hosts/address +# +declare -a _vyatta_hosts +declare -a _vyatta_symbolic_hosts=( '' '' '' ) +declare -i _vyatta_hostfile_lastmod=0 +declare _vyatta_hostfile_sed='s/#.*//; ; s/^[^ \t]\+[ \t]\+//; s/[ \t]\+/\n/g; /^$/d' + +function vyatta-allowed-hosts () +{ + : ${HOSTFILE:=/etc/hosts} + local -i curmod=$(stat --printf %Y $HOSTFILE) + + if [ $curmod -ne $_vyatta_hostfile_lastmod ] ; then + _vyatta_hosts=( $(sed "$_vyatta_hostfile_sed" $HOSTFILE) ) + _vyatta_hostfile_lastmod=$curmod + fi + printf "%s\n" ${_vyatta_symbolic_hosts[@]} ${_vyatta_hosts[@]} $* +} + +### Local Variables: +### mode: shell-script +### End: -- cgit v1.2.3