summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Grennan <tgrennan@vyatta.com>2007-11-28 12:01:56 -0800
committerTom Grennan <tgrennan@vyatta.com>2007-11-28 12:01:56 -0800
commit4af6a3dd7a1f842afe18aac99a19832615b67539 (patch)
tree35504368d6bce1fcccc072d95003143e4069666f
parenta152d776031a0b5cb77b7c57c40d7c2753e2edaa (diff)
downloadvyatta-op-4af6a3dd7a1f842afe18aac99a19832615b67539.tar.gz
vyatta-op-4af6a3dd7a1f842afe18aac99a19832615b67539.zip
add utility function to return allowed hosts/addresses during completion and help
-rw-r--r--Makefile.am5
-rwxr-xr-xfunctions/allowed/hosts24
2 files changed, 28 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 88478f0..4f73305 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,10 @@ completion_DATA = etc/bash_completion.d/10vyatta-op
opdir = $(datadir)/vyatta-op/templates
funcdir = $(datadir)/vyatta-op/functions
-func_DATA = functions/tech-support
+func_DATA = functions/tech-support
+
+alloweddir = $(datadir)/vyatta-op/functions/allowed
+allowed_DATA = functions/allowed/hosts
bin_SCRIPTS = scripts/vyatta-show-interfaces
bin_SCRIPTS += scripts/vyatta-show-version
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=( '<HOSTNAME>' '<A.B.C.D>' '<X:X::X:X>' )
+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: