summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rwxr-xr-xetc/bash_completion.d/20vyatta-cfg8
-rwxr-xr-xlib/Vyatta/Config.pm2
-rwxr-xr-xscripts/enumeration/existing-interfaces4
4 files changed, 17 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 4bb3630..0dcc8bf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,7 @@ initddir = /etc/init.d
defaultdir = /etc/default
etc_shell_leveldir = $(sysconfdir)/shell/level
dhcphookdir = /etc/dhcp3/dhclient-exit-hooks.d
+enumdir = $(datadir)/enumeration
AM_CFLAGS = -I src -Wall -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include
AM_YFLAGS = -d --name-prefix=yy_`basename $* .y`_
@@ -68,6 +69,8 @@ share_perl5_DATA += lib/Vyatta/ConfigLoad.pm
share_perl5_DATA += lib/Vyatta/Keepalived.pm
share_perl5_DATA += lib/Vyatta/Zone.pm
+enum_SCRIPTS = scripts/enumeration/existing-interfaces
+
default_DATA = etc/default/vyatta-cfg
cpiop = find . ! -regex '\(.*~\|.*\.bak\|.*\.swp\|.*\#.*\#\)' -print0 | \
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index 62a5440..03f0bb2 100755
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -643,6 +643,7 @@ vyatta_parse_tmpl ()
# $1: tmpl
vyatta_cfg_help=""
vyatta_cfg_type=""
+ vyatta_cfg_enum=''
vyatta_cfg_tag=0
vyatta_cfg_multi=0
vyatta_cfg_allowed=()
@@ -659,11 +660,18 @@ vyatta_parse_tmpl ()
s/^tag:.*/vyatta_cfg_tag=1/p
s/^multi:.*/vyatta_cfg_multi=1/p
s/^type:[ ]\+\([^ ;]\+\)\(;.*\)\?/vyatta_cfg_type=\1/p
+ s/^enumeration:[ ]\+\([^ ]\+\)/vyatta_cfg_enum=\1/p
' $1`
vyatta_cfg_help=$(vyatta_parse_tmpl_comp_fields $1 "help")
local acmd=$(vyatta_parse_tmpl_comp_fields $1 "allowed")
+ if [ -n "$vyatta_cfg_enum" ]; then
+ local enum_script="/opt/vyatta/share/enumeration/$vyatta_cfg_enum"
+ if [ -f "$enum_script" ] && [ -e "$enum_script" ]; then
+ acmd="$enum_script"
+ fi
+ fi
vyatta_cfg_comp_help=$(vyatta_parse_tmpl_comp_fields $1 "comp_help")
if (( ${#vyatta_cfg_allowed[@]} == 0 )); then
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm
index c0c8494..e4d74bb 100755
--- a/lib/Vyatta/Config.pm
+++ b/lib/Vyatta/Config.pm
@@ -829,6 +829,8 @@ sub parseTmplAll {
}
} elsif (/^help:\s+(\S.*)$/) {
$ret{help} = $1;
+ } elsif (/^enumeration:\s+(\S+)$/) {
+ $ret{enum} = $1;
}
}
close($tmpl);
diff --git a/scripts/enumeration/existing-interfaces b/scripts/enumeration/existing-interfaces
new file mode 100755
index 0000000..1defc22
--- /dev/null
+++ b/scripts/enumeration/existing-interfaces
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+ls /sys/class/net 2>/dev/null
+