summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--debian/control5
-rw-r--r--etc/bash_completion.d/10vyatta-op107
-rw-r--r--functions/tech-support4
-rwxr-xr-xscripts/vyatta-show-dmesg4
-rw-r--r--templates/show/arp/node.def2
-rw-r--r--templates/show/bridge/node.def2
-rw-r--r--templates/show/bridge/node.tag/macs/node.def2
-rw-r--r--templates/show/bridge/node.tag/node.def5
-rw-r--r--templates/show/bridge/node.tag/spanning-tree/node.def2
-rw-r--r--templates/show/host/date/node.def2
-rw-r--r--templates/show/host/lookup/node.def1
-rw-r--r--templates/show/host/lookup/node.tag/node.def3
-rw-r--r--templates/show/host/name/node.def2
-rw-r--r--templates/show/host/node.def1
-rw-r--r--templates/show/host/os/node.def2
-rw-r--r--templates/show/system/boot-messages/all/node.def2
-rw-r--r--templates/show/system/boot-messages/node.def2
-rw-r--r--templates/show/users/node.def2
19 files changed, 145 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am
index fdde7e6..091e050 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,12 +12,13 @@ alloweddir = $(datadir)/vyatta-op/functions/allowed
allowed_DATA = functions/allowed/hosts
bin_SCRIPTS = scripts/vyatta-show-interfaces
-bin_SCRIPTS += scripts/vyatta-show-dmesg-all
bin_SCRIPTS += scripts/vyatta-show-version
bin_sudo_users_SCRIPTS = scripts/vyatta-show-log
bin_sudo_users_SCRIPTS += scripts/vyatta-show-log-all
bin_sudo_users_SCRIPTS += scripts/vyatta-show-log-file
+bin_sudo_users_SCRIPTS += scripts/vyatta-show-dmesg
+bin_sudo_users_SCRIPTS += scripts/vyatta-show-dmesg-all
sbin_PROGRAMS = src/render_xml
diff --git a/debian/control b/debian/control
index a5c9b9f..074e6e5 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,10 @@ Depends: bash (>= 3.1),
ethtool,
ntpdate,
procps (>= 1:3.2.7-3),
- coreutils (>= 5.97-5.3)
+ pciutils,
+ lsof,
+ coreutils (>= 5.97-5.3),
+ host
Suggests: util-linux (>= 2.13-5),
net-tools,
ncurses-bin (>= 5.5-5),
diff --git a/etc/bash_completion.d/10vyatta-op b/etc/bash_completion.d/10vyatta-op
index 5a672c3..6239302 100644
--- a/etc/bash_completion.d/10vyatta-op
+++ b/etc/bash_completion.d/10vyatta-op
@@ -31,6 +31,7 @@ test -z "$_vyatta_default_pager" && \
--squeeze-blank-lines\
--buffers=64\
--auto-buffers\
+ --no-init\
--no-lessopen"
declare -x VYATTA_PAGER=$_vyatta_default_pager
@@ -44,6 +45,7 @@ declare -r _vyatta_op_last_comp_init='>>>>>>LASTCOMP<<<<<<'
declare _vyatta_op_last_comp=${_vyatta_op_last_comp_init}
declare _vyatta_op_node_path
declare -a _vyatta_op_noncompletions _vyatta_op_completions
+declare -x -a _vyatta_pipe_noncompletions _vyatta_pipe_completions
# $1: label
# #2...: strings
@@ -214,6 +216,19 @@ _vyatta_op_expand ()
(( COMP_CWORD = ${#COMP_WORDS[@]} ))
fi
+ if _vyatta_pipe_completion "${COMP_WORDS[@]}"; then
+ if [ "${COMP_WORDS[*]}" == "$_vyatta_op_last_comp" ] ; then
+ _vyatta_do_pipe_help
+ COMPREPLY=( "" " " )
+ _vyatta_op_last_comp=${_vyatta_op_last_comp_init}
+ else
+ COMPREPLY=( "${_vyatta_pipe_completions[@]}" )
+ _vyatta_op_last_comp="${COMP_WORDS[*]}"
+ fi
+ eval "$restore_shopts"
+ return
+ fi
+
if [ "${COMP_WORDS[*]}" != "$_vyatta_op_last_comp" ] ; then
if ! _vyatta_op_set_node_path ; then
echo -e \\a
@@ -291,6 +306,96 @@ _vyatta_op_run ()
return $ret
}
+# "pipe" functions
+count ()
+{
+ wc -l
+}
+
+match ()
+{
+ grep -E -e "$1"
+}
+
+no-match ()
+{
+ grep -E -v -e "$1"
+}
+
+no-more ()
+{
+ cat
+}
+
+# pipe command help
+# $1: command
+_vyatta_pipe_help ()
+{
+ local help="No help text available"
+ case "$1" in
+ count) help="Count the number of lines in the output";;
+ match) help="Only output lines that match specified pattern";;
+ no-match) help="Only output lines that do not match specified pattern";;
+ more) help="Paginate the output";;
+ no-more) help="Do not paginate the output";;
+ '<pattern>') help="Pattern for matching";;
+ esac
+ echo -n "$help"
+}
+
+_vyatta_do_pipe_help ()
+{
+ local help=''
+ if (( ${#_vyatta_pipe_completions[@]} + ${#_vyatta_pipe_noncompletions[@]}
+ == 0 )); then
+ return
+ fi
+ echo -en "\nPossible completions:"
+ for comp in "${_vyatta_pipe_completions[@]}" \
+ "${_vyatta_pipe_noncompletions[@]}"; do
+ _vyatta_op_print_help "$comp" "$(_vyatta_pipe_help "$comp")"
+ done
+}
+
+# pipe completion
+# $@: words
+_vyatta_pipe_completion ()
+{
+ local -a pipe_cmd=()
+ local -a all_cmds=( 'count' 'match' 'no-match' 'more' 'no-more' )
+ local found=0
+ _vyatta_pipe_completions=()
+ _vyatta_pipe_noncompletions=()
+
+ for word in "$@"; do
+ if [ "$found" == "1" -o "$word" == "|" ]; then
+ pipe_cmd+=( "$word" )
+ found=1
+ fi
+ done
+ if (( found == 0 )); then
+ return 1
+ fi
+ if (( ${#pipe_cmd[@]} == 1 )); then
+ # "|" only
+ _vyatta_pipe_completions=( "${all_cmds[@]}" )
+ return 0
+ fi
+ if (( ${#pipe_cmd[@]} == 2 )); then
+ # "|<space, chars, or space+chars>"
+ _vyatta_pipe_completions=($(compgen -W "${all_cmds[*]}" -- ${pipe_cmd[1]}))
+ return 0
+ fi
+ if (( ${#pipe_cmd[@]} == 3 )); then
+ # "|<chars or space+chars><space or space+chars>"
+ case "${pipe_cmd[1]}" in
+ match|no-match) _vyatta_pipe_noncompletions=( '<pattern>' );;
+ esac
+ return 0
+ fi
+ return 0
+}
+
# don't initialize if we are in configure mode
if [ "$_OFR_CONFIGURE" == "ok" ]; then
return 0
@@ -304,8 +409,6 @@ done
eval $nullglob_save
unset nullglob_save
-alias no-more=cat
-
_vyatta_op_init $@
### Local Variables:
diff --git a/functions/tech-support b/functions/tech-support
index 46f5827..ba2f22d 100644
--- a/functions/tech-support
+++ b/functions/tech-support
@@ -158,8 +158,8 @@ sudo ${vyatta_bindir}/sudo-users/iptables -t raw -L -vn
header \''show ip route'\'
show ip route
-header /root/.bash_history
-cat /root/.bash_history
+header $HOME/.bash_history
+cat $HOME/.bash_history
header \''show vrrp'\'
show vrrp
diff --git a/scripts/vyatta-show-dmesg b/scripts/vyatta-show-dmesg
new file mode 100755
index 0000000..8a53a94
--- /dev/null
+++ b/scripts/vyatta-show-dmesg
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cat /var/log/dmes? /dev/null
+
diff --git a/templates/show/arp/node.def b/templates/show/arp/node.def
new file mode 100644
index 0000000..021f848
--- /dev/null
+++ b/templates/show/arp/node.def
@@ -0,0 +1,2 @@
+help: Show Address Resolution Protocol Information
+run: /usr/sbin/arp -e
diff --git a/templates/show/bridge/node.def b/templates/show/bridge/node.def
new file mode 100644
index 0000000..45761f1
--- /dev/null
+++ b/templates/show/bridge/node.def
@@ -0,0 +1,2 @@
+help: "Show bridging information"
+run: sudo brctl show
diff --git a/templates/show/bridge/node.tag/macs/node.def b/templates/show/bridge/node.tag/macs/node.def
new file mode 100644
index 0000000..4f44832
--- /dev/null
+++ b/templates/show/bridge/node.tag/macs/node.def
@@ -0,0 +1,2 @@
+help: Show bridge MAC table"
+run: sudo brctl showmacs $3
diff --git a/templates/show/bridge/node.tag/node.def b/templates/show/bridge/node.tag/node.def
new file mode 100644
index 0000000..d439a03
--- /dev/null
+++ b/templates/show/bridge/node.tag/node.def
@@ -0,0 +1,5 @@
+help: Show bridge information for a given bridge
+allowed: local -a array ;
+ array=( /sys/class/net/br* ) ;
+ echo -n ${array[@]##*/}
+run: sudo brctl show $3
diff --git a/templates/show/bridge/node.tag/spanning-tree/node.def b/templates/show/bridge/node.tag/spanning-tree/node.def
new file mode 100644
index 0000000..2da87a0
--- /dev/null
+++ b/templates/show/bridge/node.tag/spanning-tree/node.def
@@ -0,0 +1,2 @@
+help: Show bridge spanning tree information"
+run: sudo brctl showstp $3
diff --git a/templates/show/host/date/node.def b/templates/show/host/date/node.def
new file mode 100644
index 0000000..6ea4383
--- /dev/null
+++ b/templates/show/host/date/node.def
@@ -0,0 +1,2 @@
+help: Show host current date
+run: /bin/date
diff --git a/templates/show/host/lookup/node.def b/templates/show/host/lookup/node.def
new file mode 100644
index 0000000..d8368b6
--- /dev/null
+++ b/templates/show/host/lookup/node.def
@@ -0,0 +1 @@
+help: Lookup host info for host/ipaddress
diff --git a/templates/show/host/lookup/node.tag/node.def b/templates/show/host/lookup/node.tag/node.def
new file mode 100644
index 0000000..e0dd0df
--- /dev/null
+++ b/templates/show/host/lookup/node.tag/node.def
@@ -0,0 +1,3 @@
+help: Lookup host information for host/ipaddres
+allowed: vyatta-allowed-hosts
+run: /usr/bin/host $4
diff --git a/templates/show/host/name/node.def b/templates/show/host/name/node.def
new file mode 100644
index 0000000..0197d10
--- /dev/null
+++ b/templates/show/host/name/node.def
@@ -0,0 +1,2 @@
+help: Show host name
+run: /bin/hostname
diff --git a/templates/show/host/node.def b/templates/show/host/node.def
new file mode 100644
index 0000000..65a0694
--- /dev/null
+++ b/templates/show/host/node.def
@@ -0,0 +1 @@
+help: Show host information
diff --git a/templates/show/host/os/node.def b/templates/show/host/os/node.def
new file mode 100644
index 0000000..1cfe2ec
--- /dev/null
+++ b/templates/show/host/os/node.def
@@ -0,0 +1,2 @@
+help: Show host operating system details
+run: /bin/uname -a
diff --git a/templates/show/system/boot-messages/all/node.def b/templates/show/system/boot-messages/all/node.def
index b151fc2..df6795f 100644
--- a/templates/show/system/boot-messages/all/node.def
+++ b/templates/show/system/boot-messages/all/node.def
@@ -1,2 +1,2 @@
help: Show all kernel boot messages
-run: ${vyatta_bindir}/vyatta-show-dmesg-all
+run: sudo ${vyatta_bindir}/sudo-users/vyatta-show-dmesg-all
diff --git a/templates/show/system/boot-messages/node.def b/templates/show/system/boot-messages/node.def
index fb24eeb..b2c25e3 100644
--- a/templates/show/system/boot-messages/node.def
+++ b/templates/show/system/boot-messages/node.def
@@ -1,2 +1,2 @@
help: Show most recent kernel boot messages
-run: cat /var/log/dmes? /dev/null
+run: sudo ${vyatta_bindir}/sudo-users/vyatta-show-dmesg
diff --git a/templates/show/users/node.def b/templates/show/users/node.def
new file mode 100644
index 0000000..6a88319
--- /dev/null
+++ b/templates/show/users/node.def
@@ -0,0 +1,2 @@
+help: Show user information
+run: who