diff options
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | debian/control | 1 | ||||
-rwxr-xr-x | debian/rules | 19 | ||||
-rw-r--r-- | etc/bash_completion.d/10vyatta-op | 34 | ||||
-rwxr-xr-x | scripts/vyatta-show-dmesg | 4 | ||||
-rwxr-xr-x | scripts/vyatta-show-dmesg-all | 9 | ||||
-rw-r--r-- | scripts/vyatta-show-interfaces.pl | 35 | ||||
-rwxr-xr-x | scripts/vyatta-show-log | 4 | ||||
-rwxr-xr-x | scripts/vyatta-show-log-all | 9 | ||||
-rwxr-xr-x | scripts/vyatta-show-log-file | 13 | ||||
-rw-r--r-- | templates/show/hardware/cpu/node.def | 4 | ||||
-rw-r--r-- | templates/show/hardware/mem/node.def | 4 | ||||
-rw-r--r-- | templates/show/license/node.def | 4 | ||||
-rw-r--r-- | templates/show/log/all/node.def | 4 | ||||
-rw-r--r-- | templates/show/log/file/node.tag/node.def | 6 | ||||
-rw-r--r-- | templates/show/log/node.def | 4 | ||||
-rw-r--r-- | templates/show/system/boot-messages/all/node.def | 4 | ||||
-rw-r--r-- | templates/show/system/boot-messages/node.def | 4 | ||||
-rw-r--r-- | templates/show/vrrp/summary/node.def | 3 | ||||
-rw-r--r-- | templates/traceroute/node.tag/node.def | 7 |
21 files changed, 88 insertions, 103 deletions
diff --git a/Makefile.am b/Makefile.am index 5d973f9..a09f4d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,11 +15,6 @@ bin_SCRIPTS = scripts/vyatta-show-interfaces bin_SCRIPTS += scripts/vyatta-show-interfaces.pl bin_SCRIPTS += scripts/vyatta-show-version bin_SCRIPTS += scripts/vyatta-show-dhclient.pl -bin_SCRIPTS += scripts/vyatta-show-log -bin_SCRIPTS += scripts/vyatta-show-log-all -bin_SCRIPTS += scripts/vyatta-show-log-file -bin_SCRIPTS += scripts/vyatta-show-dmesg -bin_SCRIPTS += scripts/vyatta-show-dmesg-all bin_SCRIPTS += scripts/vyatta-show-dmi bin_sudo_users_SCRIPTS = scripts/vyatta-identify-interface.pl diff --git a/configure.ac b/configure.ac index 015d730..bb44cfc 100644 --- a/configure.ac +++ b/configure.ac @@ -15,24 +15,10 @@ AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([gnu no-dist-gzip dist-bzip2 subdir-objects]) AC_PREFIX_DEFAULT([/opt/vyatta]) -AC_PROG_CC -AM_PROG_AS -AM_PROG_CC_C_O -AC_PROG_LIBTOOL -AC_PROG_LEX -AC_PROG_YACC - -AC_ARG_ENABLE([nostrip], - AC_HELP_STRING([--enable-nostrip], - [include -nostrip option during packaging]), - [NOSTRIP=-nostrip], [NOSTRIP=]) - AC_CONFIG_FILES( [Makefile] [etc/default/vyatta] [debian/vyatta-op.postinst]) -AC_SUBST(NOSTRIP) - AC_OUTPUT diff --git a/debian/control b/debian/control index c124dfa..757332b 100644 --- a/debian/control +++ b/debian/control @@ -9,6 +9,7 @@ Package: vyatta-op Architecture: all Depends: sed (>= 4.1.5), ethtool, + traceroute, ntpdate, procps (>= 1:3.2.7-3), pciutils, diff --git a/debian/rules b/debian/rules index f2e5c13..4db6686 100755 --- a/debian/rules +++ b/debian/rules @@ -9,30 +9,13 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) PACKAGE=vyatta-op PKGDIR=$(CURDIR)/debian/$(PACKAGE) -CFLAGS = -Wall -g - configure = ./configure -configure += --host=$(DEB_HOST_GNU_TYPE) -configure += --build=$(DEB_BUILD_GNU_TYPE) configure += --prefix=/opt/vyatta configure += --mandir=\$${prefix}/share/man configure += --infodir=\$${prefix}/share/info -configure += CFLAGS="$(CFLAGS)" -configure += LDFLAGS="-Wl,-z,defs" - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif configure: configure.ac Makefile.am chmod +x debian/autogen.sh @@ -84,8 +67,6 @@ binary-indep: build install dh_installdocs dh_install dh_installdebconf - dh_link - dh_strip dh_compress dh_fixperms dh_installdeb diff --git a/etc/bash_completion.d/10vyatta-op b/etc/bash_completion.d/10vyatta-op index ebff99f..8ccb7ee 100644 --- a/etc/bash_completion.d/10vyatta-op +++ b/etc/bash_completion.d/10vyatta-op @@ -19,17 +19,19 @@ # # **** End License **** -test -z "$_vyatta_default_pager" && \ - declare -r _vyatta_default_pager="less\ +test -z "$_vyatta_less_options" && \ + declare -r _vyatta_less_options="\ --QUIT-AT-EOF\ --quit-if-one-screen\ - --LONG-PROMPT\ --RAW-CONTROL-CHARS\ --squeeze-blank-lines\ + --no-init" +test -z "$_vyatta_default_pager" && \ + declare -r _vyatta_default_pager="less \ --buffers=64\ --auto-buffers\ - --no-init\ - --no-lessopen" + --no-lessopen\ + $_vyatta_less_options" declare -x VYATTA_PAGER=$_vyatta_default_pager _vyatta_op_do_key_bindings () @@ -318,7 +320,8 @@ _vyatta_op_run () local run_cmd=$(_vyatta_op_get_node_def_field $tpath/node.def run) local ret=0 if [ -n "$run_cmd" ]; then - if [[ -t 1 && "$1" == "show" ]] ; then + if [[ -t 1 && "$1" == "show" && \ + ! $run_cmd =~ ^\(LESSOPEN=\|less\|pager\|tail\).* ]] ; then eval "($run_cmd) | ${VYATTA_PAGER:-cat}" else eval "$run_cmd" @@ -421,16 +424,15 @@ _vyatta_pipe_completion () return 0 } -vtysh () -{ - if [ -S /var/run/vyatta/quagga/zebra.vty ] ; then - vyatta-vtysh "$@" - elif [ ! -S /var/run/quagga/zebra.vty ] ; then - /usr/bin/vtysh "$@" - else - echo "Can't connect with zebra daemon" - fi -} +if [ -S /var/run/vyatta/quagga/zebra.vty ] ; then + declare -x -r _vyatta_vtysh=vyatta-vtysh +elif [ ! -S /var/run/quagga/zebra.vty ] ; then + declare -x -r _vyatta_vtysh=/usr/bin/vtysh +else + declare -x -r _vyatta_vtysh="echo \"Can't connect with zebra daemon to run: vtysh \"" +fi + +alias vtysh=$_vyatta_vtysh # don't initialize if we are in configure mode if [ "$_OFR_CONFIGURE" == "ok" ]; then diff --git a/scripts/vyatta-show-dmesg b/scripts/vyatta-show-dmesg deleted file mode 100755 index 8a53a94..0000000 --- a/scripts/vyatta-show-dmesg +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cat /var/log/dmes? /dev/null - diff --git a/scripts/vyatta-show-dmesg-all b/scripts/vyatta-show-dmesg-all deleted file mode 100755 index d511ea0..0000000 --- a/scripts/vyatta-show-dmesg-all +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -shopt -s extglob nullglob - -declare -a zipped_files=($( printf "%s\n" /var/log/dmesg*.gz | sort -r )) -declare -a plain_files=($( printf "%s\n" /var/log/dmesg!(*.gz) | sort -r )) - -[ ${#zipped_files[@]} -gt 0 ] && gunzip --stdout ${zipped_files[@]} -[ ${#plain_files[@]} -gt 0 ] && cat ${plain_files[@]} diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl index 092f147..0ec5d3e 100644 --- a/scripts/vyatta-show-interfaces.pl +++ b/scripts/vyatta-show-interfaces.pl @@ -335,6 +335,39 @@ sub run_reset_intf { } } +sub alphanum_split { + my ($str) = @_; + my @list = split m/(?=(?<=\D)\d|(?<=\d)\D)/, $str; + return @list; +} + +sub natural_order { + my ($a, $b) = @_; + my @a = alphanum_split($a); + my @b = alphanum_split($b); + + while (@a && @b) { + my $a_seg = shift @a; + my $b_seg = shift @b; + my $val; + if (($a_seg =~ /\d/) && ($b_seg =~ /\d/)) { + $val = $a_seg <=> $b_seg; + } else { + $val = $a_seg cmp $b_seg; + } + if ($val != 0) { + return $val; + } + } + return @a <=> @b; +} + +sub intf_sort { + my @a = @_; + my @new_a = sort { natural_order($a,$b) } @a; + return @new_a; +} + # # main @@ -369,6 +402,8 @@ if (! defined $action) { $action = 'show'; } +@intf_list = intf_sort(@intf_list); + my $func; if (defined $action_hash{$action}) { $func = $action_hash{$action}; diff --git a/scripts/vyatta-show-log b/scripts/vyatta-show-log deleted file mode 100755 index 10e46e5..0000000 --- a/scripts/vyatta-show-log +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cat /var/log/messages - diff --git a/scripts/vyatta-show-log-all b/scripts/vyatta-show-log-all deleted file mode 100755 index 126b7fc..0000000 --- a/scripts/vyatta-show-log-all +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -shopt -s extglob nullglob - -declare -a zipped_files=($( printf "%s\n" /var/log/messages*.gz | sort -r )) -declare -a plain_files=($( printf "%s\n" /var/log/messages!(*.gz) | sort -r )) - -[ ${#zipped_files[@]} -gt 0 ] && gunzip --stdout ${zipped_files[@]} -[ ${#plain_files[@]} -gt 0 ] && cat ${plain_files[@]} diff --git a/scripts/vyatta-show-log-file b/scripts/vyatta-show-log-file deleted file mode 100755 index caf8ac9..0000000 --- a/scripts/vyatta-show-log-file +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -if [[ "$1" == */* ]]; then - echo "Invalid log file name" - exit 1 -fi - -if [ -f "/var/log/user/$1" ]; then - cat /var/log/user/$1 -else - echo "No such log file" -fi - diff --git a/templates/show/hardware/cpu/node.def b/templates/show/hardware/cpu/node.def index 4339af2..2e3c616 100644 --- a/templates/show/hardware/cpu/node.def +++ b/templates/show/hardware/cpu/node.def @@ -1,2 +1,4 @@ help: Show system CPU details -run: cat /proc/cpuinfo +run: less $_vyatta_less_options \ + --prompt=".cpu info" \ + -- /proc/cpuinfo diff --git a/templates/show/hardware/mem/node.def b/templates/show/hardware/mem/node.def index 7a54e52..acf1109 100644 --- a/templates/show/hardware/mem/node.def +++ b/templates/show/hardware/mem/node.def @@ -1,2 +1,4 @@ help: Show system RAM details -run: cat /proc/meminfo +run: less $_vyatta_less_options \ + --prompt=".mem info" \ + -- /proc/meminfo diff --git a/templates/show/license/node.def b/templates/show/license/node.def index eadfbbf..2108f30 100644 --- a/templates/show/license/node.def +++ b/templates/show/license/node.def @@ -1,2 +1,4 @@ help: Show Vyatta license information -run: cat ${vyatta_sysconfdir}/LICENSE +run: less $_vyatta_less_options \ + --prompt=".license, page %dt of %D" \ + -- ${vyatta_sysconfdir}/LICENSE diff --git a/templates/show/log/all/node.def b/templates/show/log/all/node.def index 87e959b..069d1d4 100644 --- a/templates/show/log/all/node.def +++ b/templates/show/log/all/node.def @@ -1,2 +1,4 @@ help: Show contents of all master log files -run: ${vyatta_bindir}/vyatta-show-log-all +run: less $_vyatta_less_options \ + --prompt=".log?m, file %i of %m., page %dt of %D" \ + -- `printf "%s\n" /var/log/messages* | sort -nr` diff --git a/templates/show/log/file/node.tag/node.def b/templates/show/log/file/node.tag/node.def index a5a1c9d..f62a334 100644 --- a/templates/show/log/file/node.tag/node.def +++ b/templates/show/log/file/node.tag/node.def @@ -1,5 +1,7 @@ help: Show contents of user-defined log file allowed: local -a array ; array=( /var/log/user/* ) ; - echo -n ${array[@]##*/} -run: ${vyatta_bindir}/vyatta-show-log-file "$4" + [ ${#array[@]} -gt 0 ] && echo -n ${array[@]##*/} || echo -n none +run: less $_vyatta_less_options \ + --prompt=".$4 log, page %dt of %D" \ + -- /var/log/user/$4 diff --git a/templates/show/log/node.def b/templates/show/log/node.def index 5f61e1d..3d37d84 100644 --- a/templates/show/log/node.def +++ b/templates/show/log/node.def @@ -1,2 +1,4 @@ help: Show contents of current master log file -run: ${vyatta_bindir}/vyatta-show-log +run: less $_vyatta_less_options \ + --prompt=".log, page %dt of %D" \ + -- /var/log/messages diff --git a/templates/show/system/boot-messages/all/node.def b/templates/show/system/boot-messages/all/node.def index b151fc2..e414987 100644 --- a/templates/show/system/boot-messages/all/node.def +++ b/templates/show/system/boot-messages/all/node.def @@ -1,2 +1,4 @@ help: Show all kernel boot messages -run: ${vyatta_bindir}/vyatta-show-dmesg-all +run: less $_vyatta_less_options \ + --prompt=".boot-messages?m, file %i of %m., page %dt of %D" \ + -- `printf "%s\n" /var/log/dmesg* | sort -nr` diff --git a/templates/show/system/boot-messages/node.def b/templates/show/system/boot-messages/node.def index 7cfe5d3..97bbb61 100644 --- a/templates/show/system/boot-messages/node.def +++ b/templates/show/system/boot-messages/node.def @@ -1,2 +1,4 @@ help: Show most recent kernel boot messages -run: ${vyatta_bindir}/vyatta-show-dmesg +run: less $_vyatta_less_options \ + --prompt=".boot-messages, page %dt of %D" \ + -- /var/log/dmesg diff --git a/templates/show/vrrp/summary/node.def b/templates/show/vrrp/summary/node.def new file mode 100644 index 0000000..33333c4 --- /dev/null +++ b/templates/show/vrrp/summary/node.def @@ -0,0 +1,3 @@ +help: Show VRRP summary +run: /opt/vyatta/sbin/vyatta-show-vrrp.pl "$3" + diff --git a/templates/traceroute/node.tag/node.def b/templates/traceroute/node.tag/node.def index 87d9c32..f183741 100644 --- a/templates/traceroute/node.tag/node.def +++ b/templates/traceroute/node.tag/node.def @@ -5,4 +5,9 @@ allowed: vyatta-allowed-hosts -run: /usr/sbin/traceroute $2 +run: if /usr/bin/host $2 &>/dev/null + then + /usr/bin/traceroute $2 + else + echo Cannot identify $2 + fi |