From 5b1bec7ba23c02c9e63b25c63b638bacc239ce56 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 19 Dec 2015 04:59:19 +0100 Subject: Easter egg: 'show version funny' command that displays limericks after version information. --- scripts/limericks.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 scripts/limericks.py (limited to 'scripts') diff --git a/scripts/limericks.py b/scripts/limericks.py new file mode 100644 index 0000000..acb1a74 --- /dev/null +++ b/scripts/limericks.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +import random + +limericks = [ + +""" +A programmer who's name was Searle +Once wrote a long program in Perl. +Despite very few quirks +No one got how it works, +Not even the interpreter. +""", + +""" +There was a young lady of Maine +Who set up IPsec VPN. +Problems didn't arise +'til other vendors' device +had to add she to that VPN. +""", + +""" +One day a programmer from York +started his own Vyatta fork. +Though he was a huge geek, +it still took him a week +to get the damn build scripts to work. +""", + +""" +A network admin from Hong Kong +knew MPPE cipher's not strong. +But he was behind NAT, +so he put up we that, +sad network admin from Hong Kong. +""", + +""" +A network admin named Drake +greeted friends with a three-way handshake +and refused to proceed +if they didn't complete it, +that standards-compliant guy Drake. +""" + +] + +l = limericks[random.randint(0, len(limericks) - 1)] + +print(l) -- cgit v1.2.3 From 75caf5c06cd8841db4aedd1ef6673f6dbcf74bb2 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Mon, 8 Feb 2016 07:45:00 -0500 Subject: Fix "show system image version" command. --- scripts/vyatta-boot-image.pl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index 52d5198..a4c0169 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -31,7 +31,7 @@ use File::Copy; # # Constants # -my $UNION_BOOT = '/live/image/boot'; +my $UNION_BOOT = '/lib/live/mount/persistence/boot'; my $UNION_GRUB_CFG = "$UNION_BOOT/grub/grub.cfg"; my $VER_FILE = '/opt/vyatta/etc/version'; my $OLD_IMG_VER_STR = 'Old-non-image-installation'; @@ -226,32 +226,31 @@ sub image_vyatta_version { my ($image_name) = @_; my $vers; - my $dpkg_path = "var/lib/dpkg"; my $image_path; if ($image_name eq $OLD_IMG_VER_STR) { $image_path = ""; } else { - $image_path = "/live/image/boot/$image_name/live-rw"; + $image_path = "/lib/live/mount/persistence/boot/$image_name/rw"; } - $image_path .= "/var/lib/dpkg"; + $image_path .= "/opt/vyatta/etc/version"; if ( -e $image_path ) { - $vers = `dpkg-query --admindir=$image_path --showformat='\${Version}' --show vyatta-version`; + $vers = `cat $image_path | awk '{print \$2}'`; return $vers; } else { if ($image_name eq $OLD_IMG_VER_STR) { return "unknown"; } - my @squash_files = glob("/live/image/boot/$image_name/*.squashfs"); + my @squash_files = glob("/lib/live/mount/persistence/boot/$image_name/*.squashfs"); foreach my $squash_file (@squash_files) { if (-e $squash_file) { system("sudo mkdir /tmp/squash_mount"); system("sudo mount -o loop,ro -t squashfs $squash_file /tmp/squash_mount"); - $image_path = "/tmp/squash_mount/var/lib/dpkg"; - my $vers = `dpkg-query --admindir=$image_path --showformat='\${Version}' --show vyatta-version`; + $image_path = "/tmp/squash_mount/opt/vyatta/etc/version"; + my $vers = `cat $image_path | awk '{print \$2}'`; system("sudo umount /tmp/squash_mount"); system("sudo rmdir /tmp/squash_mount"); return $vers; -- cgit v1.2.3 From 0c77160cd5e22714c2373e9554998c140b9c0bdd Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Mon, 8 Feb 2016 11:06:17 -0500 Subject: Update paths in del_non_image_files function. --- scripts/vyatta-boot-image.pl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index a4c0169..0a15bb0 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -431,15 +431,15 @@ sub del_non_image_files { system("echo Deleting disk-based system files at: `date` >> $logfile"); system("echo Run by: `whoami` >> $logfile"); - foreach my $entry (glob("/live/image/*")) { - if ($entry eq "/live/image/boot") { - print "Skipping $entry.\n"; - } else { - print "Deleting $entry..."; - system ("echo deleting $entry >> $logfile"); - system ("rm -rf $entry >> $logfile 2>&1"); - print "\n"; - } + foreach my $entry (glob("/lib/live/mount/persistence/*")) { + if ($entry eq "/lib/live/mount/persistence/boot") { + print "Skipping $entry.\n"; + } else { + print "Deleting $entry..."; + system ("echo deleting $entry >> $logfile"); + system ("rm -rf $entry >> $logfile 2>&1"); + print "\n"; + } } system ("echo done at: `date` >> $logfile"); } -- cgit v1.2.3 From fdf69619a8f27a3310235a9d320748d8dbb3f657 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Mon, 8 Feb 2016 11:21:47 -0500 Subject: Update location of LIVE_CD. --- scripts/vyatta-boot-image.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index 0a15bb0..e1d4a8c 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -38,7 +38,7 @@ my $OLD_IMG_VER_STR = 'Old-non-image-installation'; my $OLD_GRUB_CFG = '/boot/grub/grub.cfg'; my $DISK_BOOT = '/boot'; my $XEN_DEFAULT_IMAGE = "$UNION_BOOT/%%default_image"; -my $LIVE_CD = '/live/image/live'; +my $LIVE_CD = '/lib/live/mount/medium/live'; # # Globals -- cgit v1.2.3 From 59240c87059fd207b3ec38238851f6fe6982e48c Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Mon, 8 Feb 2016 12:27:08 -0500 Subject: Update debian live mountpoint directories. --- scripts/rename-image.pl | 6 +++--- scripts/show-image-storage.pl | 8 ++++---- scripts/vyatta-boot-image.pl | 2 +- scripts/vyatta-image-tools.pl | 10 +++++----- templates/add/raid/node.tag/member/node.tag/node.def | 2 +- templates/clone/system/config/node.tag/from/node.tag/node.def | 6 +++--- templates/clone/system/config/node.tag/node.def | 4 ++-- templates/show/log/image/node.tag/all/node.def | 2 +- templates/show/log/image/node.tag/authorization/node.def | 2 +- templates/show/log/image/node.tag/directory/node.def | 4 ++-- templates/show/log/image/node.tag/file/node.tag/node.def | 4 ++-- templates/show/log/image/node.tag/node.def | 6 +++--- templates/show/log/image/node.tag/tail/node.def | 2 +- templates/show/log/image/node.tag/tail/node.tag/node.def | 2 +- 14 files changed, 30 insertions(+), 30 deletions(-) (limited to 'scripts') diff --git a/scripts/rename-image.pl b/scripts/rename-image.pl index 2c77d70..591c29d 100644 --- a/scripts/rename-image.pl +++ b/scripts/rename-image.pl @@ -27,7 +27,7 @@ use File::Temp qw/ tempfile tempdir /; use File::Copy; use Sys::Syslog qw/:standard :macros/; -my $UNION_BOOT = '/live/image/boot'; +my $UNION_BOOT = '/lib/live/mount/persistence/boot'; my $XEN_DEFAULT_IMAGE = "$UNION_BOOT/%%default_image"; my $old_name; @@ -43,7 +43,7 @@ if (!defined($old_name) || !defined($new_name)) { exit 1; } -my $image_path = "/live/image/boot"; +my $image_path = "/lib/live/mount/persistence/boot"; if (! -e "$image_path") { # must be running on old non-image installed system @@ -80,7 +80,7 @@ if ($cur_name =~ s/BOOT_IMAGE=\/boot\///) { # On Xen/pygrub systems, we figure out the running version by # looking at the bind mount of /boot. $cur_name = `mount | awk '/on \\/boot / { print \$1 }'`; - $cur_name =~ s/\/live\/image\/boot\///; + $cur_name =~ s/\/lib\/live\/mount\/persistence\/boot\///; chomp($cur_name); } } diff --git a/scripts/show-image-storage.pl b/scripts/show-image-storage.pl index f8de35e..863b913 100644 --- a/scripts/show-image-storage.pl +++ b/scripts/show-image-storage.pl @@ -40,8 +40,8 @@ sub better_units { # # Figure out where the images live... -my $imagedir = "/live/image/boot"; -my $livecd = "/live/image/live"; +my $imagedir = "/lib/live/mount/persistence/boot"; +my $livecd = "/lib/live/mount/persistence/live"; if (! -e $imagedir) { if (-d $livecd) { die "System running on Live-CD\n"; @@ -73,11 +73,11 @@ foreach my $image (@bootlist_arr) { ($total, $garbage) = split(' ', $string); $total = better_units($total); - $string = `du -s -h $imagedir/$image --exclude live-rw`; + $string = `du -s -h $imagedir/$image --exclude rw`; ($read_only, $garbage) = split(' ', $string); $read_only = better_units($read_only); - $string = `du -s -h $imagedir/$image/live-rw`; + $string = `du -s -h $imagedir/$image/rw`; ($read_write, $garbage) = split(' ', $string); $read_write = better_units($read_write); diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index e1d4a8c..52b4769 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -409,7 +409,7 @@ sub curVer { # On Xen/pygrub systems, we figure out the running version by # looking at the bind mount of /boot. $vers = `mount | awk '/on \\/boot / { print \$1 }'`; - $vers =~ s/\/live\/image\/boot\///; + $vers =~ s/\/lib\/live\/mount\/persistence\/boot\///; chomp($vers); } diff --git a/scripts/vyatta-image-tools.pl b/scripts/vyatta-image-tools.pl index 6bcfd7d..2dd95df 100755 --- a/scripts/vyatta-image-tools.pl +++ b/scripts/vyatta-image-tools.pl @@ -50,7 +50,7 @@ sub conv_file { if ($topdir eq "running") { $file = "/$file"; } elsif (lc($topdir) eq 'disk-install') { - $file = "/live/image/$file"; + $file = "/lib/live/mount/persistence/$file"; } elsif (lc($topdir) eq 'tftp') { $file = $filein; $topdir = 'url'; @@ -64,11 +64,11 @@ sub conv_file { $file = $filein; $topdir = 'url'; } else { - if (!-d "/live/image/boot/$topdir/live-rw"){ + if (!-d "/lib/live/mount/persistence/boot/$topdir/rw"){ print "Image $topdir not found!\n"; exit 1; } - $file = "/live/image/boot/$topdir/live-rw/$file"; + $file = "/lib/live/mount/persistence/boot/$topdir/rw/$file"; } return ($topdir, $file); } @@ -78,9 +78,9 @@ sub conv_file_to_rel { if ($topdir eq "running"){ $filename =~ s?/?$topdir://?; } elsif ($topdir eq "disk-install") { - $filename =~ s?/live/image/?$topdir://?; + $filename =~ s?/lib/live/mount/persistence/?$topdir://?; } else { - $filename =~ s?/live/image/boot/$topdir/live-rw/?$topdir://?; + $filename =~ s?/lib/live/mount/persistence/boot/$topdir/rw/?$topdir://?; } return $filename; } diff --git a/templates/add/raid/node.tag/member/node.tag/node.def b/templates/add/raid/node.tag/member/node.tag/node.def index b526e1e..14ac911 100644 --- a/templates/add/raid/node.tag/member/node.tag/node.def +++ b/templates/add/raid/node.tag/member/node.tag/node.def @@ -40,7 +40,7 @@ run: mounted_on_root=0 mounted_on=`mount | grep "^/dev/${raid_set}" | awk '{ print $3 }'` for dir in $mounted_on ; do - if [ "$dir" = "/" -o "$dir" = "/live/image" ]; then + if [ "$dir" = "/" -o "$dir" = "/lib/live/mount/persistence" ]; then mounted_on_root=1 fi done diff --git a/templates/clone/system/config/node.tag/from/node.tag/node.def b/templates/clone/system/config/node.tag/from/node.tag/node.def index c244559..d883c8c 100644 --- a/templates/clone/system/config/node.tag/from/node.tag/node.def +++ b/templates/clone/system/config/node.tag/from/node.tag/node.def @@ -1,11 +1,11 @@ help: Image to update from -allowed: reply=( $(compgen -d /live/image/boot/ | grep -v grub) ) +allowed: reply=( $(compgen -d /lib/live/mount/persistence/boot/ | grep -v grub) ) for i in `seq 0 $[${#reply[@]}-1]`; do file=${reply[$i]} - reply[$i]=${file/#\/live\/image\/boot\//} + reply[$i]=${file/#\/lib\/live\/mount\/persistence\/boot\//} done reply+=( "running" ) - if [[ -d /live/image/config ]];then + if [[ -d /lib/live/mount/persistence/config ]];then reply+=( "disk-install" ) fi echo "${reply[*]}" diff --git a/templates/clone/system/config/node.tag/node.def b/templates/clone/system/config/node.tag/node.def index 6e6e340..ec82322 100644 --- a/templates/clone/system/config/node.tag/node.def +++ b/templates/clone/system/config/node.tag/node.def @@ -1,8 +1,8 @@ help: Image to update -allowed: reply=( $(compgen -d /live/image/boot/ | grep -v grub) ) +allowed: reply=( $(compgen -d /lib/live/mount/persistence/boot/ | grep -v grub) ) for i in `seq 0 $[${#reply[@]}-1]`; do file=${reply[$i]} - reply[$i]=${file/#\/live\/image\/boot\//} + reply[$i]=${file/#\/lib\/live\/mount\/persistence\/boot\//} done echo "${reply[*]}" run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; diff --git a/templates/show/log/image/node.tag/all/node.def b/templates/show/log/image/node.tag/all/node.def index eb3c87c..fd15df0 100644 --- a/templates/show/log/image/node.tag/all/node.def +++ b/templates/show/log/image/node.tag/all/node.def @@ -2,4 +2,4 @@ help: Show contents of all master log files for image run: eval $(lesspipe) less $_vyatta_less_options \ --prompt=".log?m, file %i of %m., page %dt of %D" \ - -- `printf "%s\n" /live/image/boot/$4/live-rw/var/log/messages* | sort -nr` + -- `printf "%s\n" /lib/live/mount/persistence/boot/$4/rw/var/log/messages* | sort -nr` diff --git a/templates/show/log/image/node.tag/authorization/node.def b/templates/show/log/image/node.tag/authorization/node.def index aec45cc..e7e3330 100644 --- a/templates/show/log/image/node.tag/authorization/node.def +++ b/templates/show/log/image/node.tag/authorization/node.def @@ -1,4 +1,4 @@ help: Show listing of authorization attempts for image run: less $_vyatta_less_options \ --prompt=".log, page %dt of %D" \ - -- /live/image/boot/$4/live-rw/var/log/auth.log + -- /lib/live/mount/persistence/boot/$4/rw/var/log/auth.log diff --git a/templates/show/log/image/node.tag/directory/node.def b/templates/show/log/image/node.tag/directory/node.def index d9cb9cb..6d813cf 100644 --- a/templates/show/log/image/node.tag/directory/node.def +++ b/templates/show/log/image/node.tag/directory/node.def @@ -1,4 +1,4 @@ help: Show listing of user-defined log files for image -run: if [ -d /live/image/boot/$4/live-rw/var/log/user ] - then ls /live/image/boot/$4/live-rw/var/log/user +run: if [ -d /lib/live/mount/persistence/boot/$4/rw/var/log/user ] + then ls /lib/live/mount/persistence/boot/$4/rw/var/log/user fi diff --git a/templates/show/log/image/node.tag/file/node.tag/node.def b/templates/show/log/image/node.tag/file/node.tag/node.def index f347a86..5f6bb18 100644 --- a/templates/show/log/image/node.tag/file/node.tag/node.def +++ b/templates/show/log/image/node.tag/file/node.tag/node.def @@ -1,7 +1,7 @@ help: Show contents of specified user-defined log file for image allowed: local -a array ; - array=( /live/image/boot/${COMP_WORDS[3]}/live-rw/var/log/user/* ) ; + array=( /lib/live/mount/persistence/boot/${COMP_WORDS[3]}/rw/var/log/user/* ) ; [ ${#array[@]} -gt 0 ] && echo -n ${array[@]##*/} || echo -n none run: less $_vyatta_less_options \ --prompt=".$4 log, page %dt of %D" \ - -- /live/image/boot/$4/live-rw/var/log/user/$6 + -- /lib/live/mount/persistence/boot/$4/rw/var/log/user/$6 diff --git a/templates/show/log/image/node.tag/node.def b/templates/show/log/image/node.tag/node.def index daeb44e..05e7d01 100644 --- a/templates/show/log/image/node.tag/node.def +++ b/templates/show/log/image/node.tag/node.def @@ -1,11 +1,11 @@ help: Show contents of master log file for image -allowed: reply=( $(compgen -f /live/image/boot/ | grep -v grub) ) +allowed: reply=( $(compgen -f /lib/live/mount/persistence/boot/ | grep -v grub) ) for i in `seq 0 $[${#reply[@]}-1]`; do file=${reply[$i]} - reply[$i]=${file/#\/live\/image\/boot\//} + reply[$i]=${file/#\/lib\/live\/mount\/persistence\/boot\//} done echo "${reply[*]}" run: less $_vyatta_less_options \ --prompt=".log, page %dt of %D" \ - -- /live/image/boot/$4/live-rw/var/log/messages + -- /lib/live/mount/persistence/boot/$4/rw/var/log/messages diff --git a/templates/show/log/image/node.tag/tail/node.def b/templates/show/log/image/node.tag/tail/node.def index c7f0190..090eae4 100644 --- a/templates/show/log/image/node.tag/tail/node.def +++ b/templates/show/log/image/node.tag/tail/node.def @@ -1,2 +1,2 @@ help: Show last lines of messages file -run: tail /live/image/boot/$4/live-rw/var/log/messages +run: tail /lib/live/mount/persistence/boot/$4/rw/var/log/messages diff --git a/templates/show/log/image/node.tag/tail/node.tag/node.def b/templates/show/log/image/node.tag/tail/node.tag/node.def index f0af559..2c3eb14 100644 --- a/templates/show/log/image/node.tag/tail/node.tag/node.def +++ b/templates/show/log/image/node.tag/tail/node.tag/node.def @@ -1,3 +1,3 @@ help: Show last changes to messages allowed: echo -n '' -run: tail -n "$6" /live/image/boot/$4/live-rw/var/log/messages | ${VYATTA_PAGER:-cat} +run: tail -n "$6" /lib/live/mount/persistence/boot/$4/rw/var/log/messages | ${VYATTA_PAGER:-cat} -- cgit v1.2.3 From 918b53841364a016eec0e2996640c471f738e93b Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Tue, 9 Feb 2016 04:17:49 -0500 Subject: Use dhcp instead of dhcp3. --- scripts/dhcpv6-client-show-leases.pl | 4 ++-- scripts/show-dhcp-leases.pl | 2 +- scripts/vyatta-show-dhclient.pl | 2 +- templates/release/dhcpv6/interface/node.tag/node.def | 4 ++-- templates/renew/dhcpv6/interface/node.tag/node.def | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/dhcpv6-client-show-leases.pl b/scripts/dhcpv6-client-show-leases.pl index 44be689..761a3e6 100644 --- a/scripts/dhcpv6-client-show-leases.pl +++ b/scripts/dhcpv6-client-show-leases.pl @@ -55,7 +55,7 @@ sub log_msg { # Main section. # -opendir (my $dir, "/var/lib/dhcp3"); +opendir (my $dir, "/var/lib/dhcp"); my @lease_files; while (my $f = readdir $dir) { if ($f =~ /^dhclient_v6_(\w+).leases$/) { @@ -74,7 +74,7 @@ my %ghash = (); foreach my $lease_filename (@lease_files) { my @lines=(); - open(my $f, '<', "/var/lib/dhcp3/$lease_filename") + open(my $f, '<', "/var/lib/dhcp/$lease_filename") or die "Can't open lease file for reading: $lease_filename\n"; @lines = <$f>; diff --git a/scripts/show-dhcp-leases.pl b/scripts/show-dhcp-leases.pl index a7a918a..431a13c 100755 --- a/scripts/show-dhcp-leases.pl +++ b/scripts/show-dhcp-leases.pl @@ -22,7 +22,7 @@ use strict; -opendir (my $dir, "/var/lib/dhcp3"); +opendir (my $dir, "/var/lib/dhcp"); my @leases; while (my $f = readdir $dir) { ($f =~ /^dhclient_([\w.]+)_lease$/) && push @leases, $1; diff --git a/scripts/vyatta-show-dhclient.pl b/scripts/vyatta-show-dhclient.pl index 5064c1c..40e284b 100755 --- a/scripts/vyatta-show-dhclient.pl +++ b/scripts/vyatta-show-dhclient.pl @@ -28,7 +28,7 @@ use POSIX; use strict; use warnings; -my $lease_dir = '/var/lib/dhcp3'; +my $lease_dir = '/var/lib/dhcp'; sub dhclient_get_lease_files { my ($intf) = @_; diff --git a/templates/release/dhcpv6/interface/node.tag/node.def b/templates/release/dhcpv6/interface/node.tag/node.def index 05f45c8..a8faa6c 100644 --- a/templates/release/dhcpv6/interface/node.tag/node.def +++ b/templates/release/dhcpv6/interface/node.tag/node.def @@ -2,8 +2,8 @@ help: Release DHCPv6 lease for interface allowed: local -a array - array=( /var/lib/dhcp3/dhclient_v6_*.conf ) - tail=${array[@]#/var/lib/dhcp3/dhclient_v6_} + array=( /var/lib/dhcp/dhclient_v6_*.conf ) + tail=${array[@]#/var/lib/dhcp/dhclient_v6_} ifnames=${tail[@]%.conf} echo -n ${ifnames[@]} diff --git a/templates/renew/dhcpv6/interface/node.tag/node.def b/templates/renew/dhcpv6/interface/node.tag/node.def index 2ef676d..9b5c191 100644 --- a/templates/renew/dhcpv6/interface/node.tag/node.def +++ b/templates/renew/dhcpv6/interface/node.tag/node.def @@ -2,8 +2,8 @@ help: Renew a DHCPv6 lease on an interface allowed: local -a array - array=( /var/lib/dhcp3/dhclient_v6_*.conf ) - tail=${array[@]#/var/lib/dhcp3/dhclient_v6_} + array=( /var/lib/dhcp/dhclient_v6_*.conf ) + tail=${array[@]#/var/lib/dhcp/dhclient_v6_} ifnames=${tail[@]%.conf} echo -n ${ifnames[@]} -- cgit v1.2.3 From c18b9618f4577fb80b07a0471f19a11ed2b3dfcb Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 Mar 2016 10:23:03 -0500 Subject: New implementation of the version display command (ref T6). --- Makefile.am | 2 +- debian/changelog | 6 + debian/control | 3 +- scripts/vyatta-show-version | 255 ----------------------------- scripts/vyos-show-version | 106 ++++++++++++ templates/show/version/added/node.def | 2 - templates/show/version/all/node.def | 5 +- templates/show/version/deleted/node.def | 2 - templates/show/version/downgraded/node.def | 2 - templates/show/version/funny/node.def | 2 +- templates/show/version/node.def | 2 +- templates/show/version/upgraded/node.def | 2 - 12 files changed, 121 insertions(+), 268 deletions(-) delete mode 100755 scripts/vyatta-show-version create mode 100644 scripts/vyos-show-version delete mode 100644 templates/show/version/added/node.def delete mode 100644 templates/show/version/deleted/node.def delete mode 100644 templates/show/version/downgraded/node.def delete mode 100644 templates/show/version/upgraded/node.def (limited to 'scripts') diff --git a/Makefile.am b/Makefile.am index e736419..8212b02 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ interp_DATA += functions/interpreter/vyatta-image-complete bin_SCRIPTS = scripts/vyatta-show-interfaces bin_SCRIPTS += scripts/vyatta-show-interfaces.pl -bin_SCRIPTS += scripts/vyatta-show-version +bin_SCRIPTS += scripts/vyos-show-version bin_SCRIPTS += scripts/vyatta-show-dhclient.pl bin_SCRIPTS += scripts/vyatta-show-dmi bin_SCRIPTS += scripts/vyatta-tshark-interface-port.pl diff --git a/debian/changelog b/debian/changelog index 5a896d3..8744266 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vyatta-op (0.14.0+vyos2+current2) unstable; urgency=medium + + * New implementation of "run show version" + + -- Thu, 03 Mar 2016 09:57:48 -0500 + vyatta-op (0.14.0+vyos2+current1) unstable; urgency=medium [ Thomas Jepp ] diff --git a/debian/control b/debian/control index 1046c54..6062453 100644 --- a/debian/control +++ b/debian/control @@ -32,7 +32,8 @@ Depends: sed (>= 4.1.5), libtimedate-perl, usbutils, lsscsi, - hvinfo + hvinfo, + python-pystache Suggests: util-linux (>= 2.13-5), ncurses-bin (>= 5.5-5), dialog diff --git a/scripts/vyatta-show-version b/scripts/vyatta-show-version deleted file mode 100755 index dd4f7bc..0000000 --- a/scripts/vyatta-show-version +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/perl -w -# -# Module: show_version -# -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2005-2013 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Rick Balocca -# Date: 2007 -# Description: -# -# **** End License **** -# -use strict; -use warnings; - -# -# Global hash of debians in the base install and now. -# -my $rHoH_base_debs; -my $rHoH_now_debs; - -my $base = '/opt/vyatta/etc'; -my $versionfile = "$base/version"; -my $buildfile = "$base/build.txt"; -my $debsfile = "$base/deb-versions.txt"; - -sub echo_file { - my ($file) = @_; - - my @lines = (); - if (!(-e $file)) { - return @lines; - } - - open(my $FH, '<', $file) or die "Unable to open [$file]\n"; - @lines=<$FH>; - close($FH); - return @lines; -} - -# This follows the chain from /boot/grub/menu.cfg which -# boots /boot/vmlinuz to find the version of kernel running -sub get_image_type { - my $kernel = readlink('/boot/vmlinuz'); - my $version; - - unless (defined($kernel)) { - warn "Can not read link /boot/vmlinuz: $!\n"; - return; - } - - unless ($kernel =~ /^vmlinuz-.*-([^-]*)-(vyatta|vyos)(.*)$/) { - warn "Unknown kernel version: $kernel\n"; - return; - } - - # XXX: Maybe just check 'uname -m' ? - if ($1 eq '586') { - $version = "x86 32-bit"; - } elsif ($1 eq "amd64") { - $version = "x86 64-bit"; - } else { - $version = $1; - } - - if ($3 eq '-virt') { - $version .= " Virtual" - } - - return $version; -} - -# -# convert the "dpkg -l" output have same format as deb-versions.txt -# -sub get_pkg_version { - my @lines = @_; - - my @new_lines = (); - foreach my $line (@lines) { - if ($line =~ /^[D\|\+]/) { - next; # skip header - } - my ($status, $pkg, $version) = split(/[ \t\n]+/, $line, 4); - if ($status =~ /^i/) { - push(@new_lines, "$pkg $version"); - } - } - return @new_lines; -} - -sub read_pkg_file { - my @pkgs_list = @_; - - my %HoH = (); - my ($name, $version); - foreach my $line (@pkgs_list) { - ($name, $version) = split(/[ \t\n]+/, $line, 3); - $HoH{$name}{'version'} = $version; - } - return \%HoH; -} - -sub show_added { - for my $name (sort keys %$rHoH_now_debs) { - if (!$rHoH_base_debs->{$name}) { - printf("Aii %-25s %-25s\n", - $name, $rHoH_now_debs->{$name}->{'version'}); - } - } -} - -sub show_deleted { - for my $name (sort keys %$rHoH_base_debs) { - if (!$rHoH_now_debs->{$name}) { - printf("X %-25s %-25s\n", - $name, $rHoH_base_debs->{$name}->{'version'}); - } - } -} - -sub show_upgraded_downgraded { - my ($up_down) = @_; - - my ($symbol, $op, $ver_base, $ver_now, $cmd); - if ($up_down eq "upgraded") { - $symbol = "U"; - $op = "lt"; - } else { - $symbol = "D"; - $op = "gt"; - } - for my $name (sort keys %$rHoH_base_debs) { - if ($rHoH_now_debs->{$name}) { - $ver_base = $rHoH_base_debs->{$name}{'version'}; - $ver_now = $rHoH_now_debs->{$name}{'version'}; - if ($ver_base ne $ver_now) { - $cmd = "dpkg --compare-versions \"$ver_base\" $op \"$ver_now\""; - if (!system($cmd)) { - printf("%sii %-25s %-20s (baseline: %s)\n", - $symbol, $name, $ver_now, $ver_base); - } - } - } - } -} - -sub show_upgraded { - show_upgraded_downgraded("upgraded"); -} - -sub show_downgraded { - show_upgraded_downgraded("downgraded"); -} - -sub show_all { - show_added(); - show_deleted(); - show_upgraded(); - show_downgraded(); -} - -my %options = ( - "added" => \&show_added, - "deleted", => \&show_deleted, - "upgraded" => \&show_upgraded, - "downgraded" => \&show_downgraded, - "all" => \&show_all, -); - -# -# main -# -my $hv = `hvinfo`; -if (defined($hv) && $hv ne "") { - $versionfile .= "-virt"; -} -print(&echo_file($versionfile)); -print(&echo_file($buildfile)); - -my $type = get_image_type(); -if ($type) { - print "System type: $type\n"; -} - -my $booted = `grep -e '^overlayfs.*/filesystem.squashfs' /proc/mounts`; -if (defined($booted) && $booted ne "") { - $booted="livecd"; -} else { - my $image_boot = `grep -e '^overlayfs /' /proc/mounts`; - if ($image_boot ne "") { - $booted="image"; - } else { - $booted="disk"; - } -} -print "Boot via: $booted\n"; - -if (defined($hv) && $hv ne "") { - chomp $hv; - print "Hypervisor: $hv\n"; -} - - -my $plat_model = `sudo /usr/sbin/dmidecode -s system-product-name`; -chomp $plat_model; -my $plat_sn = `sudo /usr/sbin/dmidecode -s system-serial-number`; -chomp $plat_sn; -my $plat_uuid = `sudo /usr/sbin/dmidecode -s system-uuid`; -chomp $plat_uuid; - -if (defined $plat_model && $plat_model ne "" && $plat_model ne " ") { - print "HW model: $plat_model\n" -} - -if (defined $plat_sn && $plat_sn ne "" && $plat_sn ne " ") { - print "HW S/N: $plat_sn\n" -} - -if (defined $plat_uuid && $plat_uuid ne "" && $plat_uuid ne " ") { - print "HW UUID: $plat_uuid\n" -} - -my $uptime = `uptime`; -if (defined $uptime && $uptime ne "") { - print "Uptime: $uptime\n"; -} - -if (!(-e $debsfile)) { - exit 0; -} -print "\n"; -$rHoH_base_debs = read_pkg_file(&echo_file($debsfile)); -$rHoH_now_debs = read_pkg_file(get_pkg_version(`dpkg -l 2> /dev/null`)); - -if ($#ARGV == 0) { - if ($options{$ARGV[0]}) { - $options{$ARGV[0]}->(); - } else { - print "Usage: showversion [added|deleted|upgraded|downgraded|all]\n"; - exit 1; - } -} diff --git a/scripts/vyos-show-version b/scripts/vyos-show-version new file mode 100644 index 0000000..a701b84 --- /dev/null +++ b/scripts/vyos-show-version @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# File: vyos-show-version +# Purpose: +# Displays image version and system information. +# Used by the "run show version" command. + + +import sys +import subprocess +import json + +import pystache + + +def read_file(name): + with open (name, "r") as f: + data = f.read() + return data.strip() + +version_file = '/opt/vyatta/etc/version.json' +version_data = None + +version_output_tmpl = """ +Version: VyOS {{version}} +Built by: {{built_by}} +Built on: {{built_on}} +Build ID: {{build_id}} + +Architecture: {{system_arch}} +Boot via: {{boot_via}} +System type: {{system_type}} + +Hardware vendor: {{hardware_vendor}} +Hardware model: {{hardware_model}} +Hardware S/N: {{hardware_serial}} +Hardware UUID: {{hardware_uuid}} + +Copyright: VyOS maintainers and contributors + +""" + +# Get and display image version data from the built-in version file +# This gives us image version, built on, build by, and build UUID +try: + with open(version_file, 'r') as f: + version_data = json.load(f) +except: + print("Unable to get VyOS version data") + sys.exit(1) + + +# Get system architecture (well, kernel architecture rather) +version_data['system_arch'] = subprocess.check_output('uname -m', shell=True).strip() + + +# Get hypervisor name, if any +system_type = "physical" +try: + hypervisor = subprocess.check_output('hvinfo', shell=True).strip() + system_type = "{0} guest".format(hypervisor) +except CalledProcessError: + # hvinfo returns 1 if it cannot detect any hypervisor + pass +version_data['system_type'] = system_type + + +# Get boot type, it can be livecd, installed image, or, possible, a system installed +# via legacy "install system" mechanism +# In installed images, the squashfs image file is named after its image version, +# while on livecd it's just "filesystem.squashfs", that's how we tell a livecd boot +# from an installed image +boot_via = "installed image" +if subprocess.call(""" grep -e '^overlay.*/filesystem.squashfs' /proc/mounts >/dev/null""", shell=True) == 0: + boot_via = "livecd" +elif subprocess.call(""" grep '^overlay /' /proc/mounts >/dev/null """, shell=True) != 0: + boot_via = "legacy non-image installation" +version_data['boot_via'] = boot_via + + +# Get hardware details from DMI +version_data['hardware_vendor'] = read_file('/sys/class/dmi/id/sys_vendor') +version_data['hardware_model'] = read_file('/sys/class/dmi/id/product_name') +# XXX: serial and uuid files are only readable for root, so we cannot just read them +# when script is ran by a normal user, hence this ugly fixup +version_data['hardware_serial'] = subprocess.check_output('sudo cat /sys/class/dmi/id/subsystem/id/product_serial', shell=True).strip() +version_data['hardware_uuid'] = subprocess.check_output('sudo cat /sys/class/dmi/id/subsystem/id/product_uuid', shell=True).strip() + + +output = pystache.render(version_output_tmpl, version_data).strip() +print(output) + diff --git a/templates/show/version/added/node.def b/templates/show/version/added/node.def deleted file mode 100644 index 2381b74..0000000 --- a/templates/show/version/added/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show VyOS version information plus added packages -run: ${vyatta_bindir}/vyatta-show-version added diff --git a/templates/show/version/all/node.def b/templates/show/version/all/node.def index 5b60609..8344124 100644 --- a/templates/show/version/all/node.def +++ b/templates/show/version/all/node.def @@ -1,2 +1,5 @@ help: Show VyOS version information plus all packages changes -run: ${vyatta_bindir}/vyatta-show-version all +run: ${vyatta_bindir}/vyos-show-version + echo "" + echo "Package versions:" + dpkg -l diff --git a/templates/show/version/deleted/node.def b/templates/show/version/deleted/node.def deleted file mode 100644 index d328cf6..0000000 --- a/templates/show/version/deleted/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show VyOS version information plus deleted packages -run: ${vyatta_bindir}/vyatta-show-version deleted diff --git a/templates/show/version/downgraded/node.def b/templates/show/version/downgraded/node.def deleted file mode 100644 index 250b048..0000000 --- a/templates/show/version/downgraded/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show VyOS version information plus downgraded packages -run: ${vyatta_bindir}/vyatta-show-version downgraded diff --git a/templates/show/version/funny/node.def b/templates/show/version/funny/node.def index cb62c96..e6544f9 100644 --- a/templates/show/version/funny/node.def +++ b/templates/show/version/funny/node.def @@ -1,5 +1,5 @@ help: Show VyOS version information plus a funny poem run: - ${vyatta_bindir}/vyatta-show-version + ${vyatta_bindir}/vyos-show-version ${vyatta_bindir}/limericks.py diff --git a/templates/show/version/node.def b/templates/show/version/node.def index 4237e5d..e2bfc1f 100644 --- a/templates/show/version/node.def +++ b/templates/show/version/node.def @@ -1,2 +1,2 @@ help: Show VyOS version information -run: ${vyatta_bindir}/vyatta-show-version +run: ${vyatta_bindir}/vyos-show-version diff --git a/templates/show/version/upgraded/node.def b/templates/show/version/upgraded/node.def deleted file mode 100644 index b693c23..0000000 --- a/templates/show/version/upgraded/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show VyOS version information plus upgraded packages -run: ${vyatta_bindir}/vyatta-show-version upgraded -- cgit v1.2.3 From bb2e1e9dbb7bdf153bf43056d64e82d749a3aa81 Mon Sep 17 00:00:00 2001 From: Kim Date: Sat, 16 Apr 2016 18:03:51 +0200 Subject: stop smartmatch warnings --- scripts/ping | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/ping b/scripts/ping index c0fae36..b72ea54 100755 --- a/scripts/ping +++ b/scripts/ping @@ -40,6 +40,7 @@ use strict; use warnings; use NetAddr::IP; use feature ":5.10"; +use experimental 'smartmatch'; sub get_options { my ($opt, $args) = @_; -- cgit v1.2.3 From a34e4f13c9b387c184b4f55d53477b0b33610bd7 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Thu, 15 Sep 2016 12:28:12 +0200 Subject: fix error message "NameError: name 'CalledProcessError' is not defined" when doing a 'show version' on a non virtual machine --- scripts/vyos-show-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyos-show-version b/scripts/vyos-show-version index a701b84..c0609ca 100644 --- a/scripts/vyos-show-version +++ b/scripts/vyos-show-version @@ -73,7 +73,7 @@ system_type = "physical" try: hypervisor = subprocess.check_output('hvinfo', shell=True).strip() system_type = "{0} guest".format(hypervisor) -except CalledProcessError: +except subprocess.CalledProcessError: # hvinfo returns 1 if it cannot detect any hypervisor pass version_data['system_type'] = system_type -- cgit v1.2.3 From 7487f99240d3815cf70d1a016415e2c44ef2a8d3 Mon Sep 17 00:00:00 2001 From: Geoff Adams Date: Tue, 20 Sep 2016 18:25:56 -0700 Subject: Correctly identify ttyS1 as a serial console, as well (issue T146). --- scripts/vyatta-boot-image.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index 52b4769..6d03865 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -102,7 +102,7 @@ sub parseGrubCfg { # old install $ehash{'ver'} = $OLD_IMG_VER_STR; } - if (/console=tty0.*console=ttyS0/) { + if (/console=tty0.*console=ttyS[01]/) { $ehash{'term'} = 'serial'; } else { $ehash{'term'} = 'kvm'; -- cgit v1.2.3 From 55915987f745d48fa4b1319888c1edb86963c6ba Mon Sep 17 00:00:00 2001 From: Geoff Adams Date: Mon, 26 Sep 2016 22:18:16 -0700 Subject: Support serial console on any ttyS#. Well, any of the first 10. --- scripts/vyatta-boot-image.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-boot-image.pl b/scripts/vyatta-boot-image.pl index 6d03865..d3ca5e8 100755 --- a/scripts/vyatta-boot-image.pl +++ b/scripts/vyatta-boot-image.pl @@ -102,7 +102,7 @@ sub parseGrubCfg { # old install $ehash{'ver'} = $OLD_IMG_VER_STR; } - if (/console=tty0.*console=ttyS[01]/) { + if (/console=tty0.*console=ttyS[0-9]/) { $ehash{'term'} = 'serial'; } else { $ehash{'term'} = 'kvm'; -- cgit v1.2.3 From ece88fcafb45dd683a0cad3801c79537cd411d44 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 21 Dec 2016 23:08:44 +0100 Subject: T156: return "Unknown" for /sys/class/dmi/* files that don't exist. --- scripts/vyos-show-version | 19 ++++++++++++------- templates/show/version/all/node.def | 2 +- templates/show/version/funny/node.def | 2 +- templates/show/version/node.def | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/vyos-show-version b/scripts/vyos-show-version index c0609ca..438f365 100644 --- a/scripts/vyos-show-version +++ b/scripts/vyos-show-version @@ -28,9 +28,14 @@ import pystache def read_file(name): - with open (name, "r") as f: - data = f.read() - return data.strip() + try: + with open (name, "r") as f: + data = f.read() + return data.strip() + except: + # This works since we only read /sys/class/* stuff + # with this function + return "Unknown" version_file = '/opt/vyatta/etc/version.json' version_data = None @@ -95,10 +100,10 @@ version_data['boot_via'] = boot_via # Get hardware details from DMI version_data['hardware_vendor'] = read_file('/sys/class/dmi/id/sys_vendor') version_data['hardware_model'] = read_file('/sys/class/dmi/id/product_name') -# XXX: serial and uuid files are only readable for root, so we cannot just read them -# when script is ran by a normal user, hence this ugly fixup -version_data['hardware_serial'] = subprocess.check_output('sudo cat /sys/class/dmi/id/subsystem/id/product_serial', shell=True).strip() -version_data['hardware_uuid'] = subprocess.check_output('sudo cat /sys/class/dmi/id/subsystem/id/product_uuid', shell=True).strip() + +# These two assume script is run as root, normal users can't access those files +version_data['hardware_serial'] = read_file('/sys/class/dmi/id/subsystem/id/product_serial') +version_data['hardware_uuid'] = read_file('/sys/class/dmi/id/subsystem/id/product_uuid') output = pystache.render(version_output_tmpl, version_data).strip() diff --git a/templates/show/version/all/node.def b/templates/show/version/all/node.def index 8344124..e98a16d 100644 --- a/templates/show/version/all/node.def +++ b/templates/show/version/all/node.def @@ -1,5 +1,5 @@ help: Show VyOS version information plus all packages changes -run: ${vyatta_bindir}/vyos-show-version +run: sudo ${vyatta_bindir}/vyos-show-version echo "" echo "Package versions:" dpkg -l diff --git a/templates/show/version/funny/node.def b/templates/show/version/funny/node.def index e6544f9..cb1b6b0 100644 --- a/templates/show/version/funny/node.def +++ b/templates/show/version/funny/node.def @@ -1,5 +1,5 @@ help: Show VyOS version information plus a funny poem run: - ${vyatta_bindir}/vyos-show-version + sudo ${vyatta_bindir}/vyos-show-version ${vyatta_bindir}/limericks.py diff --git a/templates/show/version/node.def b/templates/show/version/node.def index e2bfc1f..a3fd8af 100644 --- a/templates/show/version/node.def +++ b/templates/show/version/node.def @@ -1,2 +1,2 @@ help: Show VyOS version information -run: ${vyatta_bindir}/vyos-show-version +run: sudo ${vyatta_bindir}/vyos-show-version -- cgit v1.2.3 From 40d5341bd0f4e5ceb10c82ab8e6794c08f509f62 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 17 Feb 2017 03:39:07 -0500 Subject: T272: Add scripts and templates for generating remote side OpenVPN configs (just for VyOS for now, raw openvpn config support will come later). --- Makefile.am | 1 + scripts/vyos-openvpn-remoteconfig.pl | 122 +++++++++++++++++++++ templates/show/remote-config/node.def | 1 + templates/show/remote-config/openvpn/node.def | 1 + .../show/remote-config/openvpn/node.tag/node.def | 5 + .../openvpn/node.tag/remote-platform/node.def | 1 + .../node.tag/remote-platform/node.tag/node.def | 9 ++ 7 files changed, 140 insertions(+) create mode 100644 scripts/vyos-openvpn-remoteconfig.pl create mode 100644 templates/show/remote-config/node.def create mode 100644 templates/show/remote-config/openvpn/node.def create mode 100644 templates/show/remote-config/openvpn/node.tag/node.def create mode 100644 templates/show/remote-config/openvpn/node.tag/remote-platform/node.def create mode 100644 templates/show/remote-config/openvpn/node.tag/remote-platform/node.tag/node.def (limited to 'scripts') diff --git a/Makefile.am b/Makefile.am index 8212b02..2554bb3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,7 @@ bin_SCRIPTS += scripts/limericks.py sbin_SCRIPTS = scripts/dhcpv6-client-show-leases.pl sbin_SCRIPTS += scripts/vyatta-image-tools.pl sbin_SCRIPTS += scripts/vyatta-regen-unpriv-commands.sh +sbin_SCRIPTS += scripts/vyos-openvpn-remoteconfig.pl bin_sudo_users_SCRIPTS = scripts/vyatta-identify-interface.pl bin_sudo_users_SCRIPTS += scripts/vyatta-delete-log-file.sh diff --git a/scripts/vyos-openvpn-remoteconfig.pl b/scripts/vyos-openvpn-remoteconfig.pl new file mode 100644 index 0000000..1777d08 --- /dev/null +++ b/scripts/vyos-openvpn-remoteconfig.pl @@ -0,0 +1,122 @@ +#!/usr/bin/perl +# +# Copyright (C) 2017 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use lib "/opt/vyatta/share/perl5/"; +use Vyatta::Config; + +use warnings; +use strict; + +sub auth_warning +{ + print("NOTE: authentication options are deliberately left out,\n"); + print("since we cannot know file paths on a remote system\n\n"); +} + +my $config = new Vyatta::Config; + +my $intf = $ARGV[0]; +if(!defined($intf)) +{ + print("OpenVPN interface is not specified!\n"); + exit(1); +} + +my $remote = $ARGV[1]; +if(!defined($remote)) +{ + print("Remote side platform is not specified!\n"); + exit(1); +} + +if(!$config->exists("interfaces openvpn $intf")) +{ + print("OpenVPN interface $intf does not exist!\n"); + exit(1); +} + +$config->setLevel("interfaces openvpn $intf"); + +my $mode = $config->returnValue('mode'); + +my $localhost = $config->returnValue("local-host"); +my $localport = $config->returnValue("local-port"); +my $remotehost = $config->returnValue("remote-host"); +my $remoteaddr = $config->returnValue("remote-address"); +my $remoteport = $config->returnValue("remote-port"); +my $cipher = $config->returnValue("encryption"); +my $hash = $config->returnValue("hash"); +my $protocol = $config->returnValue("protocol"); +my $persist = $config->exists("persistent-tunnel"); +my $tlsrole = $config->returnValue("tls role"); +my $devtype = $config->returnValue("device-type"); +my @options = $config->returnValues("openvpn-option"); + +# local-addr is a tag node... +# Let's limit it to only the first address for now, +# since remote-address is limited to only one address anyway! +my @localaddrs = $config->listNodes('local-address'); +my $localaddr = undef; +if(@localaddrs) { + $localaddr = $localaddrs[0]; +} + +if($mode eq 'client') +{ + print("It is impossible to produce a complete server config from a client config!\n"); + exit(1); +} +elsif($mode eq 'site-to-site') +{ + if($remote eq 'vyos') + { + auth_warning; + + print("edit interfaces openvpn $intf\n"); + print("set mode site-to-site\n"); + print("set device-type $devtype\n") if defined($devtype); + print("set remote-host $localhost\n") if defined($localhost); + print("set remote-address $localaddr\n") if defined($localaddr); + print("set remote-port $localport\n") if defined($localport); + print("set local-host $remotehost\n") if defined($remotehost); + print("set local-address $remoteaddr\n") if defined($remoteaddr); + print("set local-port $remoteport\n") if defined($remoteport); + print("set protocol $protocol\n") if defined($protocol); + print("set encryption $cipher\n") if defined($cipher); + print("set hash $hash\n") if defined($hash); + + for my $o (@options) { print("set openvpn-option \"$o\"\n"); } + + print "tls role passive\n" if (defined($tlsrole) && ($tlsrole eq 'active')); + print "tls role active\n" if (defined($tlsrole) && ($tlsrole eq 'passive')); + print("top\n"); + } +} +elsif($mode eq 'server') +{ + if($remote eq 'vyos') + { + auth_warning; + + print("edit interfaces openvpn $intf\n"); + print("set mode client"); + print("set device-type $devtype\n") if defined($devtype); + print("set remote-host $localhost\n") if defined($localhost); + print("set remote-port $localport\n") if defined($localport); + print("set protocol $protocol\n") if defined($protocol); + print("top\n"); + } +} diff --git a/templates/show/remote-config/node.def b/templates/show/remote-config/node.def new file mode 100644 index 0000000..1675abd --- /dev/null +++ b/templates/show/remote-config/node.def @@ -0,0 +1 @@ +help: Show remote side config diff --git a/templates/show/remote-config/openvpn/node.def b/templates/show/remote-config/openvpn/node.def new file mode 100644 index 0000000..d417cb6 --- /dev/null +++ b/templates/show/remote-config/openvpn/node.def @@ -0,0 +1 @@ +help: Show remote side config for OpenVPN diff --git a/templates/show/remote-config/openvpn/node.tag/node.def b/templates/show/remote-config/openvpn/node.tag/node.def new file mode 100644 index 0000000..afb8cfb --- /dev/null +++ b/templates/show/remote-config/openvpn/node.tag/node.def @@ -0,0 +1,5 @@ +help: Show remote side OpenVPN config + +allowed: local -a array ; + eval "array=( $(cli-shell-api listEffectiveNodes interfaces openvpn) )" ; + echo -n '' ${array[@]##*/} diff --git a/templates/show/remote-config/openvpn/node.tag/remote-platform/node.def b/templates/show/remote-config/openvpn/node.tag/remote-platform/node.def new file mode 100644 index 0000000..15502c9 --- /dev/null +++ b/templates/show/remote-config/openvpn/node.tag/remote-platform/node.def @@ -0,0 +1 @@ +help: Show remote side OpenVPN config for specified platform diff --git a/templates/show/remote-config/openvpn/node.tag/remote-platform/node.tag/node.def b/templates/show/remote-config/openvpn/node.tag/remote-platform/node.tag/node.def new file mode 100644 index 0000000..66f334c --- /dev/null +++ b/templates/show/remote-config/openvpn/node.tag/remote-platform/node.tag/node.def @@ -0,0 +1,9 @@ +help: Show remote side OpenVPN config for specified platform +allowed: echo -n "vyos openvpn" + +run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; + then + sudo ${vyatta_sbindir}/vyos-openvpn-remoteconfig.pl $4 $6 + else + echo Must be an admin user to run this command. + fi -- cgit v1.2.3 From 59a22f722a98a66f94ee5ff65f10a8e20d79181c Mon Sep 17 00:00:00 2001 From: Chris Freas Date: Fri, 3 Mar 2017 10:51:30 -0500 Subject: T283: add CLI command to regenerate SSH server host keys --- scripts/ssh-server-key | 15 +++++++++++++++ templates/generate/ssh-server-key/node.def | 2 ++ 2 files changed, 17 insertions(+) create mode 100755 scripts/ssh-server-key create mode 100644 templates/generate/ssh-server-key/node.def (limited to 'scripts') diff --git a/scripts/ssh-server-key b/scripts/ssh-server-key new file mode 100755 index 0000000..9712393 --- /dev/null +++ b/scripts/ssh-server-key @@ -0,0 +1,15 @@ +regen_host_keys () +{ + sudo /bin/rm -v /etc/ssh/ssh_host_* + sudo dpkg-reconfigure openssh-server + sudo /etc/init.d/ssh restart +} + +while true; do + read -p "Do you really want to remove the existing SSH host keys? " yn + case $yn in + [Yy]* ) regen_host_keys; break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done diff --git a/templates/generate/ssh-server-key/node.def b/templates/generate/ssh-server-key/node.def new file mode 100644 index 0000000..a31a734 --- /dev/null +++ b/templates/generate/ssh-server-key/node.def @@ -0,0 +1,2 @@ +help: Regenerate the host SSH keys and restart the SSH server +run: ${vyatta_bindir}/ssh-server-key -- cgit v1.2.3 From 970ff0cfe393ccfa63d1f875483f3df7543d6c62 Mon Sep 17 00:00:00 2001 From: Chris Freas Date: Sun, 5 Mar 2017 11:40:59 -0500 Subject: Fix the 'ssh-server-key' script to use the 'yesno' script as per dmbaturin's request. --- scripts/ssh-server-key | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/ssh-server-key b/scripts/ssh-server-key index 9712393..949d314 100755 --- a/scripts/ssh-server-key +++ b/scripts/ssh-server-key @@ -5,11 +5,10 @@ regen_host_keys () sudo /etc/init.d/ssh restart } -while true; do - read -p "Do you really want to remove the existing SSH host keys? " yn - case $yn in - [Yy]* ) regen_host_keys; break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done +echo "Do you really want to remove the existing SSH host keys? " +${vyatta_bindir}/yesno + +if [ $? -eq 0 ] +then + regen_host_keys +fi -- cgit v1.2.3 From 7586d7f0b6fb9f24ba2d406941d963cf5b0068e8 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 21 Jan 2018 17:12:58 +0100 Subject: T523: Use new location for dnsmasq config files --- debian/changelog | 6 ++++++ scripts/vyatta-op-dns-forwarding.pl | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/debian/changelog b/debian/changelog index 8d8625e..14f8078 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vyatta-op (0.14.0+vyos2+current4) unstable; urgency=medium + + * T523: Use new location for dnsmasq config files + + -- Christian Poessinger Sun, 21 Jan 2018 17:10:30 +0100 + vyatta-op (0.14.0+vyos2+current3) unstable; urgency=medium * Changed 'show tech-support' implementation to a redacted output, private diff --git a/scripts/vyatta-op-dns-forwarding.pl b/scripts/vyatta-op-dns-forwarding.pl index 5f94c15..ae72b37 100755 --- a/scripts/vyatta-op-dns-forwarding.pl +++ b/scripts/vyatta-op-dns-forwarding.pl @@ -122,7 +122,7 @@ sub get_dns_nameservers { my @use_dhcp_nameservers = $vyatta_config->returnOrigValues("dhcp"); my @use_nameservers = $vyatta_config->returnOrigValues("name-server"); my @resolv_conf_nameservers = `grep "^nameserver" /etc/resolv.conf`; - my @dnsmasq_conf_nameservers = `grep "server=" /etc/dnsmasq.conf`; + my @dnsmasq_conf_nameservers = `grep "server=" /etc/dnsmasq.d/vyos.conf`; my @dnsmasq_running = `ps ax | grep dnsmasq | grep -v grep`; if (!(defined $use_system_nameservers) && (@use_dhcp_nameservers == 0) && (@use_nameservers == 0)) { -- cgit v1.2.3 From 18c58a419dd2e89b5f092baef5e4cccbbe1408dc Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 3 May 2018 16:47:55 +0200 Subject: T618: supress stderr of hvinfo in the show version script. Also convert the script to python3. --- debian/control | 2 +- scripts/vyos-show-version | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/debian/control b/debian/control index 733e9eb..bd17cf4 100644 --- a/debian/control +++ b/debian/control @@ -33,7 +33,7 @@ Depends: sed (>= 4.1.5), usbutils, lsscsi, hvinfo, - python-pystache + python3-pystache Suggests: util-linux (>= 2.13-5), ncurses-bin (>= 5.5-5), dialog diff --git a/scripts/vyos-show-version b/scripts/vyos-show-version index 438f365..be86b73 100644 --- a/scripts/vyos-show-version +++ b/scripts/vyos-show-version @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2016 VyOS maintainers and contributors # @@ -74,9 +74,9 @@ version_data['system_arch'] = subprocess.check_output('uname -m', shell=True).st # Get hypervisor name, if any -system_type = "physical" +system_type = "bare metal" try: - hypervisor = subprocess.check_output('hvinfo', shell=True).strip() + hypervisor = subprocess.check_output('hvinfo 2>/dev/null', shell=True).decode().strip() system_type = "{0} guest".format(hypervisor) except subprocess.CalledProcessError: # hvinfo returns 1 if it cannot detect any hypervisor -- cgit v1.2.3 From 9e37894920aa9ee8f31220eea81ddbc534e7dec7 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 14 May 2018 05:19:20 +0200 Subject: Remove the show version command from this package: moving to vyos-1x. --- Makefile.am | 2 - scripts/limericks.py | 51 ---------------- scripts/vyos-show-version | 111 ---------------------------------- templates/show/version/all/node.def | 5 -- templates/show/version/funny/node.def | 5 -- templates/show/version/node.def | 2 - 6 files changed, 176 deletions(-) delete mode 100644 scripts/limericks.py delete mode 100644 scripts/vyos-show-version delete mode 100644 templates/show/version/all/node.def delete mode 100644 templates/show/version/funny/node.def delete mode 100644 templates/show/version/node.def (limited to 'scripts') diff --git a/Makefile.am b/Makefile.am index c79a629..ea115cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,6 @@ interp_DATA += functions/interpreter/vyatta-image-complete bin_SCRIPTS = scripts/vyatta-show-interfaces bin_SCRIPTS += scripts/vyatta-show-interfaces.pl -bin_SCRIPTS += scripts/vyos-show-version bin_SCRIPTS += scripts/vyatta-show-dhclient.pl bin_SCRIPTS += scripts/vyatta-show-dmi bin_SCRIPTS += scripts/vyatta-tshark-interface-port.pl @@ -52,7 +51,6 @@ bin_SCRIPTS += scripts/vyatta-monitor-check-rule-log bin_SCRIPTS += scripts/vyos-show-ram.sh bin_SCRIPTS += scripts/vyos-strip-config.pl bin_SCRIPTS += scripts/maya-date.py -bin_SCRIPTS += scripts/limericks.py bin_SCRIPTS += scripts/ssh-server-key sbin_SCRIPTS = scripts/dhcpv6-client-show-leases.pl diff --git a/scripts/limericks.py b/scripts/limericks.py deleted file mode 100644 index acb1a74..0000000 --- a/scripts/limericks.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -import random - -limericks = [ - -""" -A programmer who's name was Searle -Once wrote a long program in Perl. -Despite very few quirks -No one got how it works, -Not even the interpreter. -""", - -""" -There was a young lady of Maine -Who set up IPsec VPN. -Problems didn't arise -'til other vendors' device -had to add she to that VPN. -""", - -""" -One day a programmer from York -started his own Vyatta fork. -Though he was a huge geek, -it still took him a week -to get the damn build scripts to work. -""", - -""" -A network admin from Hong Kong -knew MPPE cipher's not strong. -But he was behind NAT, -so he put up we that, -sad network admin from Hong Kong. -""", - -""" -A network admin named Drake -greeted friends with a three-way handshake -and refused to proceed -if they didn't complete it, -that standards-compliant guy Drake. -""" - -] - -l = limericks[random.randint(0, len(limericks) - 1)] - -print(l) diff --git a/scripts/vyos-show-version b/scripts/vyos-show-version deleted file mode 100644 index be86b73..0000000 --- a/scripts/vyos-show-version +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# File: vyos-show-version -# Purpose: -# Displays image version and system information. -# Used by the "run show version" command. - - -import sys -import subprocess -import json - -import pystache - - -def read_file(name): - try: - with open (name, "r") as f: - data = f.read() - return data.strip() - except: - # This works since we only read /sys/class/* stuff - # with this function - return "Unknown" - -version_file = '/opt/vyatta/etc/version.json' -version_data = None - -version_output_tmpl = """ -Version: VyOS {{version}} -Built by: {{built_by}} -Built on: {{built_on}} -Build ID: {{build_id}} - -Architecture: {{system_arch}} -Boot via: {{boot_via}} -System type: {{system_type}} - -Hardware vendor: {{hardware_vendor}} -Hardware model: {{hardware_model}} -Hardware S/N: {{hardware_serial}} -Hardware UUID: {{hardware_uuid}} - -Copyright: VyOS maintainers and contributors - -""" - -# Get and display image version data from the built-in version file -# This gives us image version, built on, build by, and build UUID -try: - with open(version_file, 'r') as f: - version_data = json.load(f) -except: - print("Unable to get VyOS version data") - sys.exit(1) - - -# Get system architecture (well, kernel architecture rather) -version_data['system_arch'] = subprocess.check_output('uname -m', shell=True).strip() - - -# Get hypervisor name, if any -system_type = "bare metal" -try: - hypervisor = subprocess.check_output('hvinfo 2>/dev/null', shell=True).decode().strip() - system_type = "{0} guest".format(hypervisor) -except subprocess.CalledProcessError: - # hvinfo returns 1 if it cannot detect any hypervisor - pass -version_data['system_type'] = system_type - - -# Get boot type, it can be livecd, installed image, or, possible, a system installed -# via legacy "install system" mechanism -# In installed images, the squashfs image file is named after its image version, -# while on livecd it's just "filesystem.squashfs", that's how we tell a livecd boot -# from an installed image -boot_via = "installed image" -if subprocess.call(""" grep -e '^overlay.*/filesystem.squashfs' /proc/mounts >/dev/null""", shell=True) == 0: - boot_via = "livecd" -elif subprocess.call(""" grep '^overlay /' /proc/mounts >/dev/null """, shell=True) != 0: - boot_via = "legacy non-image installation" -version_data['boot_via'] = boot_via - - -# Get hardware details from DMI -version_data['hardware_vendor'] = read_file('/sys/class/dmi/id/sys_vendor') -version_data['hardware_model'] = read_file('/sys/class/dmi/id/product_name') - -# These two assume script is run as root, normal users can't access those files -version_data['hardware_serial'] = read_file('/sys/class/dmi/id/subsystem/id/product_serial') -version_data['hardware_uuid'] = read_file('/sys/class/dmi/id/subsystem/id/product_uuid') - - -output = pystache.render(version_output_tmpl, version_data).strip() -print(output) - diff --git a/templates/show/version/all/node.def b/templates/show/version/all/node.def deleted file mode 100644 index e98a16d..0000000 --- a/templates/show/version/all/node.def +++ /dev/null @@ -1,5 +0,0 @@ -help: Show VyOS version information plus all packages changes -run: sudo ${vyatta_bindir}/vyos-show-version - echo "" - echo "Package versions:" - dpkg -l diff --git a/templates/show/version/funny/node.def b/templates/show/version/funny/node.def deleted file mode 100644 index cb1b6b0..0000000 --- a/templates/show/version/funny/node.def +++ /dev/null @@ -1,5 +0,0 @@ -help: Show VyOS version information plus a funny poem -run: - sudo ${vyatta_bindir}/vyos-show-version - ${vyatta_bindir}/limericks.py - diff --git a/templates/show/version/node.def b/templates/show/version/node.def deleted file mode 100644 index a3fd8af..0000000 --- a/templates/show/version/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show VyOS version information -run: sudo ${vyatta_bindir}/vyos-show-version -- cgit v1.2.3 From 685eac2fbf06f194fcfb4e3ea50f59efa5bda4f8 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 15 May 2018 00:51:52 +0200 Subject: T637: remove the old 'monitor interfaces ... traffic' implementation. --- gen-monitor-interface-templates.sh | 119 ------------------------- gen-monitor-vif-interface-templates.sh | 102 ---------------------- scripts/vyatta-tshark-interface-port.pl | 92 -------------------- scripts/vyatta-tshark.pl | 150 -------------------------------- 4 files changed, 463 deletions(-) delete mode 100755 gen-monitor-interface-templates.sh delete mode 100755 gen-monitor-vif-interface-templates.sh delete mode 100755 scripts/vyatta-tshark-interface-port.pl delete mode 100755 scripts/vyatta-tshark.pl (limited to 'scripts') diff --git a/gen-monitor-interface-templates.sh b/gen-monitor-interface-templates.sh deleted file mode 100755 index 2170e71..0000000 --- a/gen-monitor-interface-templates.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -#monitor interfaces [type] [name] traffic -#monitor interfaces [type] [name] traffic flow -#monitor interfaces [type] [name] traffic save [filename] -#monitor interfaces [type] [name] traffic save [filename] size [number] -#monitor interfaces [type] [name] traffic save [filename] size [number] files [number] -#monitor interfaces [type] [name] traffic detail -#monitor interfaces [type] [name] traffic detail filter -#monitor interfaces [type] [name] traffic detail unlimited -#monitor interfaces [type] [name] traffic detail unlimited filter -#monitor interfaces [type] [name] traffic filter -#monitor interfaces [type] [name] traffic unlimited -#monitor interfaces [type] [name] traffic unlimited filter - -declare -a types=( - "bonding" \ - "bridge" \ - "ethernet" \ - "loopback" \ - "pseudo-ethernet" \ - "tunnel" \ - "vrrp" \ - "vti" \ - "dummy" \ - "l2tpv3" -) - -TEMPLATE_DIR=generated-templates/monitor/interfaces -mkdir -p $TEMPLATE_DIR -cd $TEMPLATE_DIR - -for type in "${types[@]}"; do - mkdir -p $type/node.tag/flow - mkdir -p $type/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag - mkdir -p $type/node.tag/traffic/detail/filter/node.tag - mkdir -p $type/node.tag/traffic/detail/unlimited/filter/node.tag - mkdir -p $type/node.tag/traffic/filter/node.tag - mkdir -p $type/node.tag/traffic/unlimited/filter/node.tag - - # node.tag - echo "help: Monitor specified $type interface" >| $type/node.tag/node.def - echo "allowed: \${vyatta_sbindir}/vyatta-interfaces.pl --show $type" >> $type/node.tag/node.def - echo 'run: bmon -p $4' >> $type/node.tag/node.def - - # flow - echo 'help: Monitor flows on specified interface' >| $type/node.tag/flow/node.def - echo 'run: sudo /usr/sbin/iftop -i $4' >> $type/node.tag/flow/node.def - - # traffic - echo "help: Montior captured traffic on specified $type interface" >| $type/node.tag/traffic/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4' >> $type/node.tag/traffic/node.def - - # traffic save - echo 'help: Save monitored traffic to a file' >| $type/node.tag/traffic/save/node.def - echo 'help: Save monitored traffic to the specified file' >| $type/node.tag/traffic/save/node.tag/node.def - echo "allowed: echo -e '.pcap'" >> $type/node.tag/traffic/save/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}"' >> $type/node.tag/traffic/save/node.tag/node.def - - # traffic save size - echo 'help: Save monitored traffic to a file with max size' >| $type/node.tag/traffic/save/node.tag/size/node.def - echo "help: Maximum file size (e.g., 1 = 1 KiB, 1M = 1 MiB)" >| $type/node.tag/traffic/save/node.tag/size/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/traffic/save/node.tag/size/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" --size "${@:9}"' >> $type/node.tag/traffic/save/node.tag/size/node.tag/node.def - - # traffic save size files - echo 'help: Save monitored traffic to a set of rotated file' >| $type/node.tag/traffic/save/node.tag/size/node.tag/files/node.def - echo 'help: Number of files to rotate stored traffic through' >| $type/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" --size "${@:9}" --files "${@:11}"' >> $type/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag/node.def - - # traffic detail - echo -e "help: Monitor detailed traffic for the specified $type interface" >| $type/node.tag/traffic/detail/node.def - echo -e 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --detail' >> $type/node.tag/traffic/detail/node.def - - # traffic detail filter - echo "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/traffic/detail/filter/node.def - echo -e "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/traffic/detail/filter/node.tag/node.def - echo -e "allowed: echo -e ''" >> $type/node.tag/traffic/detail/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --detail --filter "${@:8}"' >> $type/node.tag/traffic/detail/filter/node.tag/node.def - - # traffic detail unlimited - echo -e "help: Monitor detailed traffic for the specified $type interface" >| $type/node.tag/traffic/detail/unlimited/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --detail --unlimited' >> $type/node.tag/traffic/detail/unlimited/node.def - - # traffic detail unlimited filter - echo "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/traffic/detail/unlimited/filter/node.def - echo "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/traffic/detail/unlimited/filter/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/traffic/detail/unlimited/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --detail --unlimited --filter "${@:9}"' >> $type/node.tag/traffic/detail/unlimited/filter/node.tag/node.def - - # traffic filter - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/traffic/filter/node.def - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/traffic/filter/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/traffic/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --filter "${@:7}"' >> $type/node.tag/traffic/filter/node.tag/node.def - - # traffic unlimited - echo "help: Monitor traffic for the specified $type interface" >| $type/node.tag/traffic/unlimited/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --unlimited' >> $type/node.tag/traffic/unlimited/node.def - - # traffic unlimited filter - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/traffic/unlimited/filter/node.def - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/traffic/unlimited/filter/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/traffic/unlimited/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --unlimited --filter "${@:8}"' >> $type/node.tag/traffic/unlimited/filter/node.tag/node.def - -done - -# Overrides -# This is where specific tweaks to the above can be made - -# loopback -sed -i -e 's;run: bmon -p $4;;' loopback/node.tag/node.def - -# vti -rm -rf vti/node.tag/flow - -# VRRP -sed -i -e 's;allowed: ${vyatta_sbindir}/vyatta-interfaces.pl --show vrrp;allowed: ${vyatta_bindir}/vyatta-show-interfaces.pl --vrrp --action=allowed;' vrrp/node.tag/node.def diff --git a/gen-monitor-vif-interface-templates.sh b/gen-monitor-vif-interface-templates.sh deleted file mode 100755 index ac128e8..0000000 --- a/gen-monitor-vif-interface-templates.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -#monitor interfaces [type] [name] vif flow -#monitor interfaces [type] [name] vif traffic -#monitor interfaces [type] [name] vif traffic save [filename] -#monitor interfaces [type] [name] vif traffic detail -#monitor interfaces [type] [name] vif traffic detail filter -#monitor interfaces [type] [name] vif traffic detail unlimited -#monitor interfaces [type] [name] vif traffic detail unlimited filter -#monitor interfaces [type] [name] vif traffic filter -#monitor interfaces [type] [name] vif traffic unlimited -#monitor interfaces [type] [name] vif traffic unlimited filter - -declare -a types=( - "bonding" \ - "ethernet" \ -) - -TEMPLATE_DIR=generated-templates/monitor/interfaces -mkdir -p $TEMPLATE_DIR -cd $TEMPLATE_DIR - -for type in "${types[@]}"; do - mkdir -p $type/node.tag/vif/node.tag/flow - mkdir -p $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag - mkdir -p $type/node.tag/vif/node.tag/traffic/detail/filter/node.tag - mkdir -p $type/node.tag/vif/node.tag/traffic/detail/unlimited/filter/node.tag - mkdir -p $type/node.tag/vif/node.tag/traffic/filter/node.tag - mkdir -p $type/node.tag/vif/node.tag/traffic/unlimited/filter/node.tag - - # node.tag - echo "help: Monitor specified $type interface" >| $type/node.tag/vif/node.tag/node.def - echo "allowed: \${vyatta_sbindir}/vyatta-interfaces.pl --show $type --vif \${COMP_WORDS[COMP_CWORD-2]}" >> $type/node.tag/vif/node.tag/node.def - echo 'run: bmon -p $4.$6' >> $type/node.tag/vif/node.tag/node.def - - # flow - echo 'help: Monitor flows on specified interface' >| $type/node.tag/vif/node.tag/flow/node.def - echo 'run: sudo /usr/sbin/iftop -i $4.$6' >> $type/node.tag/vif/node.tag/flow/node.def - - # node.tag - echo "help: Monitor specified $type interface" > $type/node.tag/vif/node.tag/node.def - echo "allowed: \${vyatta_sbindir}/vyatta-interfaces.pl --show $type --vif \${COMP_WORDS[COMP_CWORD-2]}" >> $type/node.tag/vif/node.tag/node.def - echo 'run: bmon -p $4.$6' >> $type/node.tag/vif/node.tag/node.def - - # traffic - echo "help: Montior captured traffic on specified $type interface" >| $type/node.tag/vif/node.tag/traffic/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6' >> $type/node.tag/vif/node.tag/traffic/node.def - - # traffic save - echo 'help: Save monitored traffic to a file' >| $type/node.tag/vif/node.tag/traffic/save/node.def - echo 'help: Save monitored traffic to the specified file' >| $type/node.tag/vif/node.tag/traffic/save/node.tag/node.def - echo "allowed: echo -e '.pcap'" >> $type/node.tag/vif/node.tag/traffic/save/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --save "${@:9}"' >> $type/node.tag/vif/node.tag/traffic/save/node.tag/node.def - - # traffic save size - echo 'help: Save monitored traffic to a file with max size' >| $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.def - echo "help: Maximum file size (e.g., 1 = 1 KiB, 1M = 1 MiB)" >| $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" --size "${@:9}"' >> $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/node.def - - # traffic save size files - echo 'help: Save monitored traffic to a set of rotated files' >| $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/files/node.def - echo 'help: Number of files to rotate stored traffic through' >| $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4 --save "${@:7}" --size "${@:9}" --files "${@:11}"' >> $type/node.tag/vif/node.tag/traffic/save/node.tag/size/node.tag/files/node.tag/node.def - - # traffic detail - echo -e "help: Monitor detailed traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/detail/node.def - echo -e 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --detail' >> $type/node.tag/vif/node.tag/traffic/detail/node.def - - # traffic detail filter - echo "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/detail/filter/node.def - echo -e "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/detail/filter/node.tag/node.def - echo -e "allowed: echo -e ''" >> $type/node.tag/vif/node.tag/traffic/detail/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --detail --filter "${@:10}"' >> $type/node.tag/vif/node.tag/traffic/detail/filter/node.tag/node.def - - # traffic detail unlimited - echo -e "help: Monitor detailed traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/detail/unlimited/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --detail --unlimited' >> $type/node.tag/vif/node.tag/traffic/detail/unlimited/node.def - - # traffic detail unlimited filter - echo "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/detail/unlimited/filter/node.def - echo "help: Monitor detailed filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/detail/unlimited/filter/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/vif/node.tag/traffic/detail/unlimited/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --detail --unlimited --filter "${@:11}"' >> $type/node.tag/vif/node.tag/traffic/detail/unlimited/filter/node.tag/node.def - - # traffic filter - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/filter/node.def - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/filter/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/vif/node.tag/traffic/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --filter "${@:9}"' >> $type/node.tag/vif/node.tag/traffic/filter/node.tag/node.def - - # traffic unlimited - echo "help: Monitor traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/unlimited/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --unlimited' >> $type/node.tag/vif/node.tag/traffic/unlimited/node.def - - # traffic unlimited filter - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/unlimited/filter/node.def - echo "help: Monitor filtered traffic for the specified $type interface" >| $type/node.tag/vif/node.tag/traffic/unlimited/filter/node.tag/node.def - echo "allowed: echo -e ''" >> $type/node.tag/vif/node.tag/traffic/unlimited/filter/node.tag/node.def - echo 'run: ${vyatta_bindir}/vyatta-tshark.pl --intf $4.$6 --unlimited --filter "${@:10}"' >> $type/node.tag/vif/node.tag/traffic/unlimited/filter/node.tag/node.def - -done diff --git a/scripts/vyatta-tshark-interface-port.pl b/scripts/vyatta-tshark-interface-port.pl deleted file mode 100755 index aa750e5..0000000 --- a/scripts/vyatta-tshark-interface-port.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/perl -# -# Module: vyatta-tshark-interface-port.pl -# -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Mohit Mehta -# Date: April 2008 -# Description: tshark on a given port for a given interface from vyatta cli -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; - -use strict; -use warnings; - -sub check_if_interface_is_tsharkable { - my $interface = shift; - - my @grep_tshark_interfaces = `sudo /usr/bin/tshark -D | grep $interface`; - my $any_interface; - - for my $count (0 .. $#grep_tshark_interfaces) { - my @temp = split(/ /,$grep_tshark_interfaces[$count]); - chomp $temp[1]; - $grep_tshark_interfaces[$count] = $temp[1]; - } - - my $exact_match = 0; - for my $count (0 .. $#grep_tshark_interfaces) { - if ($grep_tshark_interfaces[$count] eq $interface) { - $exact_match = 1; - $any_interface = $grep_tshark_interfaces[$count]; - } - } - if ($exact_match == 0 || $any_interface eq 'any') { - print "Unable to capture traffic on $interface\n"; - exit 1; - } -} - -# -# main -# - -my $intf = $ARGV[0]; - -check_if_interface_is_tsharkable($intf); - -if ($#ARGV > 0){ - my $port = $ARGV[1]; - my $not_port = $ARGV[2]; - if ($port =~ /[a-zA-Z]/){ - print "Port number has to be numeric. Allowed values: <1-65535>\n"; - exit 1; - } else { - if (($port > 0) and ($port < 65536)){ - if ($not_port == 0){ - print "Capturing traffic on $intf port $port ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf port $port 2> /dev/null"; - } else { - print "Capturing traffic on $intf excluding port $port ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf not port $port 2> /dev/null"; - } - } else { - print "Invalid port number. Allowed values: <1-65535>\n"; - exit 1; - } - - } -} else { - print "Capturing traffic on $intf ...\n"; - exec "sudo /usr/bin/tshark -n -i $intf 2> /dev/null"; -} - -exit 0; - -#end of file diff --git a/scripts/vyatta-tshark.pl b/scripts/vyatta-tshark.pl deleted file mode 100755 index 5423cfc..0000000 --- a/scripts/vyatta-tshark.pl +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/perl -# -# Module: vyatta-tshark-interface-port.pl -# -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: John Southworth -# Date: Sept. 2011 -# Description: run tshark on a given interface with options -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; - -use strict; -use warnings; -use Getopt::Long; - -sub check_if_interface_is_tsharkable { - my $interface = shift; - - my @grep_tshark_interfaces = `/usr/bin/tshark -D | grep $interface`; - my $any_interface; - - for my $count (0 .. $#grep_tshark_interfaces) { - my @temp = split(/ /,$grep_tshark_interfaces[$count]); - chomp $temp[1]; - $grep_tshark_interfaces[$count] = $temp[1]; - } - - my $exact_match = 0; - for my $count (0 .. $#grep_tshark_interfaces) { - if ($grep_tshark_interfaces[$count] eq $interface) { - $exact_match = 1; - $any_interface = $grep_tshark_interfaces[$count]; - } - } - if ($exact_match == 0 || $any_interface eq 'any') { - print "Unable to capture traffic on $interface\n"; - exit 1; - } -} - -my ($detail,$filter,$intf,$unlimited,$save,$files,$size); - -# -# The size parameter can have one of the following -# unit suffixes: -# -# - [kK] KiB (1024 bytes) -# - [mM] MiB (1048576 bytes) -# - [gG] GiB (1073741824 bytes) -# - [tT] TiB (109951162778 bytes) -# -# Note: tshark's default size unit is KiB -sub parse_size { - my ( $name, $parm ) = @_; - my %mult = ('T' => 1073741824, 't' => 1073741824, - 'G' => 1048576, 'g' => 1048576, - 'M' => 1024, 'm' => 1024, - 'K' => 1, 'k' => 1); - - die "Invalid parameter: $name" if ($name ne "size"); - my ( $value, $unit ) = $parm =~ m/^([0-9]+)([kKmMgGtT])?$/; - die "Invalid size specified" unless $value; - $unit = "K" unless $unit; - $size = $value * $mult{$unit}; -} - -# -# main -# - -my $result = GetOptions("detail!" => \$detail, - "filter=s" => \$filter, - "save=s" => \$save, - "intf=s" => \$intf, - "unlimited!" => \$unlimited, - "files=i" => \$files, - "size=s" => \&parse_size); - -if (! $result) { - print "Invalid option specifications\n"; - exit 1; -} - -check_if_interface_is_tsharkable($intf); - -if (defined($save)){ - if (!($save =~ /.*\.pcap/)) { - print("Please name your file .pcap\n"); - exit 1; - } - my $options = ""; - - # the CLI will make sure that files is not defined w/o size also - $options .= " -a filesize:$size" if defined($size); - $options .= " -b files:$files" if defined($files); - exec "/usr/bin/tshark -i $intf -w '$save' $options"; - exit 0; -} - -if (defined($filter)) { - if (defined($detail)) { - if (defined($unlimited)){ - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf -V $filter 2> /dev/null"; - } else { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf -c 1000 -V $filter 2> /dev/null"; - } - } elsif (defined($unlimited)) { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf $filter 2> /dev/null"; - } else { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf -c 1000 $filter 2> /dev/null"; - } -} elsif (defined($detail)) { - if (defined($unlimited)) { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf -V 2> /dev/null"; - } else { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf -c 1000 -V 2> /dev/null"; - } -} elsif (defined($unlimited)) { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf 2> /dev/null"; -} else { - print "Capturing traffic on $intf ...\n"; - exec "/usr/bin/tshark -n -i $intf -c 1000 2> /dev/null"; -} - -exit 0; - -#end of file -- cgit v1.2.3 From 83234bc6a31775c0c750e2d90176673dd8b5f3c8 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sun, 10 Jun 2018 22:03:01 +0200 Subject: T588: remove the old DNS forwarding op mode script. --- scripts/vyatta-op-dns-forwarding.pl | 350 ------------------------------------ 1 file changed, 350 deletions(-) delete mode 100755 scripts/vyatta-op-dns-forwarding.pl (limited to 'scripts') diff --git a/scripts/vyatta-op-dns-forwarding.pl b/scripts/vyatta-op-dns-forwarding.pl deleted file mode 100755 index ae72b37..0000000 --- a/scripts/vyatta-op-dns-forwarding.pl +++ /dev/null @@ -1,350 +0,0 @@ -#!/usr/bin/perl -# -# Module: vyatta-op-dns-forwarding.pl -# -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Mohit Mehta -# Date: August 2008 -# Description: Script to execute op-mode commands for DNS forwarding -# -# **** End License **** -# - -use lib "/opt/vyatta/share/perl5/"; -use Getopt::Long; -use Vyatta::Config; -use strict; -use warnings; - -my $show_stats_output=""; -my $show_nameservers_output=""; -my $dnsmasq_log='/var/log/dnsmasq.log'; - -sub get_cache_stats { - my ($cache_size, $queries_forwarded, $queries_answered_locally, $entries_inserted, $entries_removed); - - my $grepped_line = `grep 'cache size' $dnsmasq_log`; - my @split_line = split(/\s+/, $grepped_line); - my @temp_split = split(/,/, $split_line[6]); - $cache_size = $temp_split[0]; - @temp_split = split(/\//, $split_line[7]); - $entries_removed = $temp_split[0]; - $entries_inserted = $temp_split[1]; - - $grepped_line = `grep 'queries forwarded' $dnsmasq_log`; - @split_line = split(/\s+/, $grepped_line); - @temp_split = split(/,/, $split_line[6]); - $queries_forwarded = $temp_split[0]; - $queries_answered_locally = $split_line[10]; - - $show_stats_output .= "----------------\n"; - $show_stats_output .= "Cache statistics\n"; - $show_stats_output .= "----------------\n"; - $show_stats_output .= "Cache size: $cache_size\n"; - $show_stats_output .= "Queries forwarded: $queries_forwarded\n"; - $show_stats_output .= "Queries answered locally: $queries_answered_locally\n"; - $show_stats_output .= "Total DNS entries inserted into cache: $entries_inserted\n"; - $show_stats_output .= "DNS entries removed from cache before expiry: $entries_removed\n"; - -} - -sub get_nameserver_stats { - - $show_stats_output .= "\n---------------------\n"; - $show_stats_output .= "Nameserver statistics\n"; - $show_stats_output .= "---------------------\n"; - - #To show overridden domain servers seperately, we need to compare IPs - #configured for the domain overrides in the config with the stats. - - my $vyatta_config = new Vyatta::Config; - $vyatta_config->setLevel("service dns forwarding"); - - my @domains = $vyatta_config->listOrigNodes("domain"); - my @domain_servers_list; - - #build a list of servers that are overriding global nameservers - if (@domains) { - foreach my $domain (@domains) { - push(@domain_servers_list, $vyatta_config->returnOrigValue("domain $domain server")); - } - } - my $found_overrides = 0; - my $show_stats_overrides; - my @grepped_lines = `grep ': server' $dnsmasq_log`; - foreach my $lines (@grepped_lines) { - my @each_line = split(/\s+/, $lines); - my $nameserver_word = $each_line[5]; - my @nameserver_split = split(/#/, $nameserver_word); - my $nameserver = $nameserver_split[0]; - my $queries_sent_word = $each_line[8]; - my @queries_sent_split = split(/,/, $queries_sent_word); - my $queries_sent = $queries_sent_split[0]; - my $queries_retried_failed = $each_line[12]; - - if (grep {$_ eq $nameserver}@domain_servers_list) { - if (!$found_overrides) { - $found_overrides = 1; - $show_stats_overrides .= "\nDomain Override Servers\n\n"; - } - $show_stats_overrides .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n"; - } else { - $show_stats_output .= "Server: $nameserver\nQueries sent: $queries_sent\nQueries retried or failed: $queries_retried_failed\n\n"; - } - } - if (defined($show_stats_overrides)) { - $show_stats_output .= $show_stats_overrides; - } -} - -sub print_stats { - print $show_stats_output; -} - -sub get_dns_nameservers { - my $vyatta_config = new Vyatta::Config; - - $vyatta_config->setLevel("service dns forwarding"); - my $use_system_nameservers = $vyatta_config->existsOrig("system"); - my @use_dhcp_nameservers = $vyatta_config->returnOrigValues("dhcp"); - my @use_nameservers = $vyatta_config->returnOrigValues("name-server"); - my @resolv_conf_nameservers = `grep "^nameserver" /etc/resolv.conf`; - my @dnsmasq_conf_nameservers = `grep "server=" /etc/dnsmasq.d/vyos.conf`; - my @dnsmasq_running = `ps ax | grep dnsmasq | grep -v grep`; - - if (!(defined $use_system_nameservers) && (@use_dhcp_nameservers == 0) && (@use_nameservers == 0)) { - - # no specific nameservers specified under DNS forwarding, so dnsmasq is getting nameservers from /etc/resolv.conf - - if (! @resolv_conf_nameservers > 0){ - $show_nameservers_output .= "No DNS servers present to forward queries to.\n"; - if (! @dnsmasq_running > 0){ - $show_nameservers_output .= "DNS forwarding has not been configured either.\n"; - } - } else { - if (! @dnsmasq_running > 0){ - $show_nameservers_output .= "\n**DNS forwarding has not been configured**\n\n"; - } - $show_nameservers_output .= "-----------------------------------------------\n"; - if ( @dnsmasq_running > 0){ - $show_nameservers_output .= " Nameservers configured for DNS forwarding\n"; - } else { - $show_nameservers_output .= " Nameservers NOT configured for DNS forwarding\n"; - } - $show_nameservers_output .= "-----------------------------------------------\n"; - foreach my $line (@resolv_conf_nameservers) { - my @split_line = split(/\s+/, $line); - my $nameserver = $split_line[1]; - my $nameserver_via = "system"; - if (@split_line > 2) { - my @dhclient_resolv_files = `ls /etc/resolv.conf.dhclient-new-* 2>/dev/null`; - foreach my $each_dhcp_resolv_conf (@dhclient_resolv_files) { - my @ns_dhclient_resolv=`grep "$nameserver\$" $each_dhcp_resolv_conf`; - if ( @ns_dhclient_resolv > 0) { - my @dhclient_file_array = split(/-/, $each_dhcp_resolv_conf); - $nameserver_via = $dhclient_file_array[2]; - chomp $nameserver_via; - $nameserver_via = 'dhcp ' . $nameserver_via; - } - } - # check here if nameserver_via is still system, if yes then search /etc/ppp/resolv-interface.conf - if ($nameserver_via eq "system") { - my @ppp_resolv_files = `ls /etc/ppp/resolv-*conf 2>/dev/null`; - foreach my $each_ppp_resolv_conf (@ppp_resolv_files) { - my @ns_ppp_resolv=`grep "$nameserver\$" $each_ppp_resolv_conf`; - if ( @ns_ppp_resolv > 0) { - my @ppp_file_array = split(/-/, $each_ppp_resolv_conf); - @ppp_file_array = split(/\./, $ppp_file_array[1]); - $nameserver_via = $ppp_file_array[0]; - chomp $nameserver_via; - $nameserver_via = 'ppp ' . $nameserver_via; - } - } - } - } - $show_nameservers_output .= "$nameserver available via '$nameserver_via'\n"; - } - } - $show_nameservers_output .= "\n"; - } else { - - # nameservers specified under DNS forwarding, so dnsmasq getting nameservers from /etc/dnsmasq.conf - - my @active_nameservers; - my $active_nameserver_count = 0; - $show_nameservers_output .= "-----------------------------------------------\n"; - $show_nameservers_output .= " Nameservers configured for DNS forwarding\n"; - $show_nameservers_output .= "-----------------------------------------------\n"; - my $show_nameservers_output_dhcp; - my $show_nameservers_output_domain; - my $show_nameservers_output_nameserver; - - my $line_flag; - ## server=/test.com/1.1.1.1 - foreach my $line (@dnsmasq_conf_nameservers) { - my @split_line = split(/=/, $line); - my @nameserver_array = split(/\s+/, $split_line[1]); - my $nameserver = $nameserver_array[0]; - my $domain; - my @domain_tokens; - - if ($nameserver_array[2] eq "domain-override") - { - #$nameserver has /test.com/1.1.1.1, seperate it. - @domain_tokens = split(/\//, $nameserver); - if (!defined($line_flag)) { - $line_flag = 1; - $show_nameservers_output_domain .= "\n"; - $show_nameservers_output_domain .= "Domain Overrides:\n"; - $show_nameservers_output_domain .= "\n"; - } - } - $active_nameservers[$active_nameserver_count] = $nameserver; - $active_nameserver_count++; - my $nameserver_via = $nameserver_array[2]; - if (@nameserver_array > 3){ - my $dhcp_interface = $nameserver_array[3]; - $show_nameservers_output_dhcp .= "$nameserver available via '$nameserver_via $dhcp_interface'\n"; - } elsif (@domain_tokens) { - $show_nameservers_output_domain .= "$domain_tokens[1] uses $domain_tokens[2]\n"; - } else { - $show_nameservers_output_nameserver .= "$nameserver available via '$nameserver_via'\n"; - } - } - if (defined ($show_nameservers_output_nameserver)) { - $show_nameservers_output .= $show_nameservers_output_nameserver; - } - if (defined ($show_nameservers_output_dhcp)) { - $show_nameservers_output .= $show_nameservers_output_dhcp; - } - if (defined ($show_nameservers_output_domain)) { - $show_nameservers_output .= $show_nameservers_output_domain ; - } - - # then you need to get nameservers from /etc/resolv.conf that are not in dnsmasq.conf to show them as inactive - - my $active_dnsmasq_nameserver; - my $output_inactive_nameservers = 0; - foreach my $resolv_conf_line (@resolv_conf_nameservers) { - my @resolv_conf_split_line = split(/\s+/, $resolv_conf_line); - my $resolv_conf_nameserver = $resolv_conf_split_line[1]; - $active_dnsmasq_nameserver = 0; - my $resolv_nameserver_via = "system"; - foreach my $dnsmasq_nameserver (@active_nameservers) { - if ($dnsmasq_nameserver eq $resolv_conf_nameserver) { - $active_dnsmasq_nameserver = 1; - } - } - if ($active_dnsmasq_nameserver == 0) { - if ($output_inactive_nameservers == 0){ - $output_inactive_nameservers = 1; - $show_nameservers_output .= "\n-----------------------------------------------\n"; - $show_nameservers_output .= " Nameservers NOT configured for DNS forwarding\n"; - $show_nameservers_output .= "-----------------------------------------------\n"; - } - if (@resolv_conf_split_line > 2) { - my @dhclient_resolv_files = `ls /etc/resolv.conf.dhclient-new-* 2>/dev/null`; - foreach my $each_dhcp_resolv_conf (@dhclient_resolv_files) { - chomp $each_dhcp_resolv_conf; - my @ns_dhclient_resolv=`grep "$resolv_conf_nameserver\$" $each_dhcp_resolv_conf`; - if ( @ns_dhclient_resolv > 0) { - my @dhclient_file_array = split(/-/, $each_dhcp_resolv_conf); - $resolv_nameserver_via = $dhclient_file_array[2]; - chomp $resolv_nameserver_via; - $resolv_nameserver_via = 'dhcp ' . $resolv_nameserver_via; - } - } - # check here if resolv_nameserver_via is still system, if yes then search /etc/ppp/resolv-interface.conf - if ($resolv_nameserver_via eq "system") { - my @ppp_resolv_files = `ls /etc/ppp/resolv-*conf 2>/dev/null`; - foreach my $each_ppp_resolv_conf (@ppp_resolv_files) { - my @ns_ppp_resolv=`grep "$resolv_conf_nameserver\$" $each_ppp_resolv_conf`; - if ( @ns_ppp_resolv > 0) { - my @ppp_file_array = split(/-/, $each_ppp_resolv_conf); - @ppp_file_array = split(/\./, $ppp_file_array[1]); - $resolv_nameserver_via = $ppp_file_array[0]; - chomp $resolv_nameserver_via; - $resolv_nameserver_via = 'ppp ' . $resolv_nameserver_via; - } - } - } - } - - $show_nameservers_output .= "$resolv_conf_nameserver available via '$resolv_nameserver_via'\n"; - } - } - $show_nameservers_output .= "\n"; - } -} - -sub print_nameservers { - print $show_nameservers_output; -} - -sub wait_for_write { - - my $last_size = (stat($dnsmasq_log))[7]; - my $cnt=0; - while(1) { - system("usleep 10000"); # sleep for 0.01 second - my $curr_size = (stat($dnsmasq_log))[7]; - if( $curr_size == $last_size ) { - # Not modified - $cnt++; - last if($cnt > 1); - } else { - # Modified\n - $cnt=0; - } - $last_size = $curr_size; - } - -} - -# -# main -# -my ($clear_cache, $clear_all, $show_statistics, $show_nameservers); - -GetOptions("clear-cache!" => \$clear_cache, - "clear-all!" => \$clear_all, - "show-statistics!" => \$show_statistics, - "show-nameservers!" => \$show_nameservers); - -if (defined $clear_cache) { - system("kill -1 `pidof dnsmasq`"); -} - -if (defined $clear_all) { - system("/etc/init.d/dnsmasq restart >&/dev/null"); -} - -if (defined $show_statistics) { - system("echo > $dnsmasq_log; kill -10 `pidof dnsmasq`"); - wait_for_write; - get_cache_stats; - get_nameserver_stats; - print_stats; -} - -if (defined $show_nameservers) { - get_dns_nameservers; - print_nameservers; -} - -exit 0; - -# end of file -- cgit v1.2.3 From e711d30377c4681e75d91f7e7202497b9ba18132 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 13 Jun 2018 13:01:53 +0200 Subject: T689: remove files no longer needed after merging PR#14 into vyos-1x. --- Makefile.am | 2 - scripts/maya-date.py | 214 --------------------- templates/poweroff/at/node.def | 1 - templates/poweroff/at/node.tag/node.def | 3 - templates/poweroff/cancel/node.def | 2 - templates/poweroff/node.def | 2 - templates/poweroff/now/node.def | 2 - templates/reboot/at/node.def | 1 - templates/reboot/at/node.tag/node.def | 3 - templates/reboot/cancel/node.def | 2 - templates/reboot/node.def | 2 - templates/reboot/now/node.def | 2 - templates/show/arp/node.def | 2 - templates/show/arp/node.tag/node.def | 7 - templates/show/bridge/node.def | 2 - templates/show/bridge/node.tag/macs/node.def | 2 - templates/show/bridge/node.tag/node.def | 5 - .../show/bridge/node.tag/spanning-tree/node.def | 2 - templates/show/configuration/all/node.def | 8 - templates/show/configuration/commands/node.def | 7 - templates/show/configuration/files/node.def | 11 -- templates/show/configuration/node.def | 7 - templates/show/date/node.def | 2 - templates/show/date/utc/maya/node.def | 2 - templates/show/date/utc/node.def | 2 - templates/show/disk/node.def | 1 - templates/show/disk/node.tag/format/node.def | 7 - templates/show/disk/node.tag/node.def | 4 - templates/show/hardware/cpu/detail/node.def | 4 - templates/show/hardware/cpu/node.def | 2 - templates/show/hardware/cpu/summary/node.def | 2 - templates/show/hardware/dmi/node.def | 2 - templates/show/hardware/mem/node.def | 4 - templates/show/hardware/node.def | 1 - templates/show/hardware/pci/detailed/node.def | 2 - templates/show/hardware/pci/node.def | 2 - templates/show/hardware/scsi/detail/node.def | 2 - templates/show/hardware/scsi/node.def | 2 - templates/show/hardware/usb/detail/node.def | 3 - templates/show/hardware/usb/node.def | 2 - templates/show/raid/node.def | 2 - templates/show/raid/node.tag/node.def | 23 --- templates/show/users/node.def | 2 - templates/show/users/recent/node.def | 2 - templates/show/users/recent/node.tag/node.def | 3 - 45 files changed, 367 deletions(-) delete mode 100644 scripts/maya-date.py delete mode 100644 templates/poweroff/at/node.def delete mode 100644 templates/poweroff/at/node.tag/node.def delete mode 100644 templates/poweroff/cancel/node.def delete mode 100644 templates/poweroff/node.def delete mode 100644 templates/poweroff/now/node.def delete mode 100644 templates/reboot/at/node.def delete mode 100644 templates/reboot/at/node.tag/node.def delete mode 100644 templates/reboot/cancel/node.def delete mode 100644 templates/reboot/node.def delete mode 100644 templates/reboot/now/node.def delete mode 100644 templates/show/arp/node.def delete mode 100644 templates/show/arp/node.tag/node.def delete mode 100644 templates/show/bridge/node.def delete mode 100644 templates/show/bridge/node.tag/macs/node.def delete mode 100644 templates/show/bridge/node.tag/node.def delete mode 100644 templates/show/bridge/node.tag/spanning-tree/node.def delete mode 100644 templates/show/configuration/all/node.def delete mode 100644 templates/show/configuration/commands/node.def delete mode 100644 templates/show/configuration/files/node.def delete mode 100644 templates/show/configuration/node.def delete mode 100644 templates/show/date/node.def delete mode 100644 templates/show/date/utc/maya/node.def delete mode 100644 templates/show/date/utc/node.def delete mode 100644 templates/show/disk/node.def delete mode 100644 templates/show/disk/node.tag/format/node.def delete mode 100644 templates/show/disk/node.tag/node.def delete mode 100644 templates/show/hardware/cpu/detail/node.def delete mode 100644 templates/show/hardware/cpu/node.def delete mode 100644 templates/show/hardware/cpu/summary/node.def delete mode 100644 templates/show/hardware/dmi/node.def delete mode 100644 templates/show/hardware/mem/node.def delete mode 100644 templates/show/hardware/node.def delete mode 100644 templates/show/hardware/pci/detailed/node.def delete mode 100644 templates/show/hardware/pci/node.def delete mode 100644 templates/show/hardware/scsi/detail/node.def delete mode 100644 templates/show/hardware/scsi/node.def delete mode 100644 templates/show/hardware/usb/detail/node.def delete mode 100644 templates/show/hardware/usb/node.def delete mode 100644 templates/show/raid/node.def delete mode 100644 templates/show/raid/node.tag/node.def delete mode 100644 templates/show/users/node.def delete mode 100644 templates/show/users/recent/node.def delete mode 100644 templates/show/users/recent/node.tag/node.def (limited to 'scripts') diff --git a/Makefile.am b/Makefile.am index 2ecd735..ad9c01a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,7 +48,6 @@ bin_SCRIPTS += scripts/vyatta-monitor-background-stop bin_SCRIPTS += scripts/vyatta-monitor-check-rule-log bin_SCRIPTS += scripts/vyos-show-ram.sh bin_SCRIPTS += scripts/vyos-strip-config.pl -bin_SCRIPTS += scripts/maya-date.py bin_SCRIPTS += scripts/ssh-server-key sbin_SCRIPTS = scripts/dhcpv6-client-show-leases.pl @@ -60,7 +59,6 @@ bin_sudo_users_SCRIPTS = scripts/vyatta-identify-interface.pl bin_sudo_users_SCRIPTS += scripts/vyatta-delete-log-file.sh bin_sudo_users_SCRIPTS += scripts/vyatta-reboot.pl bin_sudo_users_SCRIPTS += scripts/vyatta-poweroff.pl -bin_sudo_users_SCRIPTS += scripts/vyatta-op-dns-forwarding.pl bin_sudo_users_SCRIPTS += scripts/vyatta-op-dynamic-dns.pl bin_sudo_users_SCRIPTS += scripts/vyatta-clear-conntrack diff --git a/scripts/maya-date.py b/scripts/maya-date.py deleted file mode 100644 index 6f0918c..0000000 --- a/scripts/maya-date.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2013 Daniil Baturin -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -import sys - -class MayaDate(object): - """ Converts number of days since UNIX epoch - to the Maya calendar date. - - Ancient Maya people used three independent calendars for - different purposes. - - Long count calendar is for recording historical events. - It and represents the number of days passed - since some date in the past the Maya believed is the day - our world was created. - - Tzolkin calendar is for religious purposes, it has - two independent cycles of 13 and 20 days, where 13 day - cycle days are numbered, and 20 day cycle days are named. - - Haab calendar is for agriculture and daily life, it's a - 365 day calendar with 18 months 20 days each, and 5 - nameless days. - - The smallest unit of long count calendar is one day (kin) - - """ - - """ The long count calendar uses five different base 18 or base 20 - cycles. Long-count date is writtin in dot separated format - from longest to shortest cycle, - .... - for example, "13.0.0.9.2". - - Classic version actually used by the ancient Maya wraps around - every 13th baktun, but modern researchers often use longer cycles - such as piktun = 20 baktun. - - """ - kin = 1 - winal = 20 # 20 kin - tun = 360 # 18 winal - katun = 7200 # 20 tun - baktun = 144000 # 20 katun - - """ Tzolk'in date is composed of two independent cycles. - Dates repeat every 260 days, 13 Ajaw is considered the end - of tzolk'in. - - Every day of the 20 day cycle has unique name, we number - them from zero so it's easier to map remainder to day: - """ - tzolkin_days = { 0: "Imix'", - 1: "Ik'", - 2: "Ak'b'al", - 3: "K'an", - 4: "Chikchan", - 5: "Kimi", - 6: "Manik'", - 7: "Lamat", - 8: "Muluk", - 9: "Ok", - 10: "Chuwen", - 11: "Eb'", - 12: "B'en", - 13: "Ix", - 14: "Men", - 15: "Kib'", - 16: "Kab'an", - 17: "Etz'nab'", - 18: "Kawak", - 19: "Ajaw" } - - """ As said above, haab (year) has 19 months. Only 18 are - true months of 20 days each, the remaining 5 days called "wayeb" - do not really belong to any month, but we think of them as a pseudo-month - for convenience. - - Also, note that days of the month are actually numbered from 0, not from 1, - it's not for technical reasons. - """ - haab_months = { 0: "Pop", - 1: "Wo'", - 2: "Sip", - 3: "Sotz'", - 4: "Sek", - 5: "Xul", - 6: "Yaxk'in'", - 7: "Mol", - 8: "Ch'en", - 9: "Yax", - 10: "Sak'", - 11: "Keh", - 12: "Mak", - 13: "K'ank'in", - 14: "Muwan'", - 15: "Pax", - 16: "K'ayab", - 17: "Kumk'u", - 18: "Wayeb'" } - - """ Now we need to map the beginning of UNIX epoch - (Jan 1 1970 00:00 UTC) to the beginning of the long count - calendar (0.0.0.0.0, 4 Ajaw, 8 Kumk'u). - - The problem with mapping the long count calendar to - any other is that its start date is not known exactly. - - The most widely accepted hypothesis suggests it was - August 11, 3114 BC gregorian date. In this case UNIX epoch - starts on 12.17.16.7.5, 13 Chikchan, 3 K'ank'in - - It's known as Goodman-Martinez-Thompson (GMT) correlation - constant. - """ - start_days = 1856305 - - """ Seconds in day, for conversion from timestamp """ - seconds_in_day = 60 * 60 * 24 - - def __init__(self, timestamp): - if timestamp is None: - self.days = self.start_days - else: - self.days = self.start_days + (int(timestamp) // self.seconds_in_day) - - def long_count_date(self): - """ Returns long count date string """ - days = self.days - - cur_baktun = days // self.baktun - days = days % self.baktun - - cur_katun = days // self.katun - days = days % self.katun - - cur_tun = days // self.tun - days = days % self.tun - - cur_winal = days // self.winal - days = days % self.winal - - cur_kin = days - - longcount_string = "{0}.{1}.{2}.{3}.{4}".format( cur_baktun, - cur_katun, - cur_tun, - cur_winal, - cur_kin ) - return(longcount_string) - - def tzolkin_date(self): - """ Returns tzolkin date string """ - days = self.days - - """ The start date is not the beginning of both cycles, - it's 4 Ajaw. So we need to add 4 to the 13 days cycle day, - and substract 1 from the 20 day cycle to get correct result. - """ - tzolkin_13 = (days + 4) % 13 - tzolkin_20 = (days - 1) % 20 - - tzolkin_string = "{0} {1}".format(tzolkin_13, self.tzolkin_days[tzolkin_20]) - - return(tzolkin_string) - - def haab_date(self): - """ Returns haab date string. - - The time start on 8 Kumk'u rather than 0 Pop, which is - 17 days before the new haab, so we need to substract 17 - from the current date to get correct result. - """ - days = self.days - - haab_day = (days - 17) % 365 - haab_month = haab_day // 20 - haab_day_of_month = haab_day % 20 - - haab_string = "{0} {1}".format(haab_day_of_month, self.haab_months[haab_month]) - - return(haab_string) - - def date(self): - return("{0}, {1}, {2}".format( self.long_count_date(), self.tzolkin_date(), self.haab_date() )) - -try: - timestamp = sys.argv[1] -except: - print("Please specify timestamp in the argument") - sys.exit(1) - -maya_date = MayaDate(timestamp) -print(maya_date.date()) diff --git a/templates/poweroff/at/node.def b/templates/poweroff/at/node.def deleted file mode 100644 index 537bfff..0000000 --- a/templates/poweroff/at/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Poweroff at a specific time diff --git a/templates/poweroff/at/node.tag/node.def b/templates/poweroff/at/node.tag/node.def deleted file mode 100644 index 932e04b..0000000 --- a/templates/poweroff/at/node.tag/node.def +++ /dev/null @@ -1,3 +0,0 @@ -help: Poweroff the system at a future time -allowed: echo -n '' '' '' '' -run: sudo /opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff_at --at_time "$3" diff --git a/templates/poweroff/cancel/node.def b/templates/poweroff/cancel/node.def deleted file mode 100644 index c45f17a..0000000 --- a/templates/poweroff/cancel/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Cancel a pending poweroff -run: sudo /opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff_cancel diff --git a/templates/poweroff/node.def b/templates/poweroff/node.def deleted file mode 100644 index ccb7338..0000000 --- a/templates/poweroff/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Poweroff the system -run: sudo /opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff diff --git a/templates/poweroff/now/node.def b/templates/poweroff/now/node.def deleted file mode 100644 index 6b67572..0000000 --- a/templates/poweroff/now/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Poweroff the system without confirmation -run: sudo /opt/vyatta/bin/sudo-users/vyatta-poweroff.pl --action poweroff --now diff --git a/templates/reboot/at/node.def b/templates/reboot/at/node.def deleted file mode 100644 index 9944ff7..0000000 --- a/templates/reboot/at/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Reboot at a specific time diff --git a/templates/reboot/at/node.tag/node.def b/templates/reboot/at/node.tag/node.def deleted file mode 100644 index 62f39f9..0000000 --- a/templates/reboot/at/node.tag/node.def +++ /dev/null @@ -1,3 +0,0 @@ -help: Reboot the system at a future time -allowed: echo -n '' '' '' '' -run: sudo /opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot_at --at_time "$3" diff --git a/templates/reboot/cancel/node.def b/templates/reboot/cancel/node.def deleted file mode 100644 index 110f595..0000000 --- a/templates/reboot/cancel/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Cancel a pending reboot -run: sudo /opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot_cancel diff --git a/templates/reboot/node.def b/templates/reboot/node.def deleted file mode 100644 index e65917d..0000000 --- a/templates/reboot/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Reboot the system -run: sudo /opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot diff --git a/templates/reboot/now/node.def b/templates/reboot/now/node.def deleted file mode 100644 index 2171b45..0000000 --- a/templates/reboot/now/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Reboot the system without confirmation -run: sudo /opt/vyatta/bin/sudo-users/vyatta-reboot.pl --action reboot --now diff --git a/templates/show/arp/node.def b/templates/show/arp/node.def deleted file mode 100644 index 013e016..0000000 --- a/templates/show/arp/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show Address Resolution Protocol (ARP) information -run: /usr/sbin/arp -e -n diff --git a/templates/show/arp/node.tag/node.def b/templates/show/arp/node.tag/node.def deleted file mode 100644 index 648797b..0000000 --- a/templates/show/arp/node.tag/node.def +++ /dev/null @@ -1,7 +0,0 @@ -help: Show Address Resolution Protocol (ARP) cache for specified interface -allowed: local -a vals; - vals=($(${vyatta_sbindir}/vyatta-interfaces.pl --show ethernet)); - vals+=($(${vyatta_sbindir}/vyatta-interfaces.pl --show bridge)); - vals+=($(${vyatta_sbindir}/vyatta-interfaces.pl --show bonding)); - echo ${vals[@]}; -run: /usr/sbin/arp -e -n -i "$3" diff --git a/templates/show/bridge/node.def b/templates/show/bridge/node.def deleted file mode 100644 index 86d0193..0000000 --- a/templates/show/bridge/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show bridging information -run: /sbin/brctl show diff --git a/templates/show/bridge/node.tag/macs/node.def b/templates/show/bridge/node.tag/macs/node.def deleted file mode 100644 index e985437..0000000 --- a/templates/show/bridge/node.tag/macs/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show bridge Media Access Control (MAC) address table -run: /sbin/brctl showmacs "$3" diff --git a/templates/show/bridge/node.tag/node.def b/templates/show/bridge/node.tag/node.def deleted file mode 100644 index 0ae82f1..0000000 --- a/templates/show/bridge/node.tag/node.def +++ /dev/null @@ -1,5 +0,0 @@ -help: Show bridge information for a given bridge interface -allowed: local -a array ; - array=( /sys/class/net/br* ) ; - echo -n '' ${array[@]##*/} -run: /sbin/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 deleted file mode 100644 index 360d15a..0000000 --- a/templates/show/bridge/node.tag/spanning-tree/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show bridge spanning tree information -run: /sbin/brctl showstp "$3" diff --git a/templates/show/configuration/all/node.def b/templates/show/configuration/all/node.def deleted file mode 100644 index 3f93f48..0000000 --- a/templates/show/configuration/all/node.def +++ /dev/null @@ -1,8 +0,0 @@ -help: Show running configuration (including default values) -run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; - then - cli-shell-api showCfg --show-show-defaults --show-active-only \ - --show-hide-secrets - else - echo Must be an admin user to run this command. - fi diff --git a/templates/show/configuration/commands/node.def b/templates/show/configuration/commands/node.def deleted file mode 100644 index f2e047e..0000000 --- a/templates/show/configuration/commands/node.def +++ /dev/null @@ -1,7 +0,0 @@ -help: Show running configuration as set commands -run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; - then - cli-shell-api showCfg --show-active-only | vyos-config-to-commands - else - echo Must be an admin user to run this command. - fi diff --git a/templates/show/configuration/files/node.def b/templates/show/configuration/files/node.def deleted file mode 100644 index 698ba14..0000000 --- a/templates/show/configuration/files/node.def +++ /dev/null @@ -1,11 +0,0 @@ -help: Show available saved configurations -run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; - then - find ${vyatta_sysconfdir}/config/ -type f -not -name ".*" -not -name "config.boot.*" -printf "%f\t(%Tc)\t%T@\n" | sort -r -k3 | awk -F"\t" '{printf ("%-20s\t%s\n", $1,$2) ;}' - else - echo Must be an admin user to run this command. - fi - - - - diff --git a/templates/show/configuration/node.def b/templates/show/configuration/node.def deleted file mode 100644 index 34813a4..0000000 --- a/templates/show/configuration/node.def +++ /dev/null @@ -1,7 +0,0 @@ -help: Show running configuration -run: if [ "$VYATTA_USER_LEVEL_DIR" == "/opt/vyatta/etc/shell/level/admin" ]; - then - cli-shell-api showCfg --show-active-only --show-hide-secrets - else - echo Must be an admin user to run this command. - fi diff --git a/templates/show/date/node.def b/templates/show/date/node.def deleted file mode 100644 index eb5adf9..0000000 --- a/templates/show/date/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show system date and time -run: /bin/date diff --git a/templates/show/date/utc/maya/node.def b/templates/show/date/utc/maya/node.def deleted file mode 100644 index ddc82c7..0000000 --- a/templates/show/date/utc/maya/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show UTC date in Maya calendar format -run: ${vyatta_bindir}/maya-date.py $(date +%s) diff --git a/templates/show/date/utc/node.def b/templates/show/date/utc/node.def deleted file mode 100644 index cb12d00..0000000 --- a/templates/show/date/utc/node.def +++ /dev/null @@ -1,2 +0,0 @@ -help: Show system date and time as Coordinated Universal Time -run: /bin/date -u diff --git a/templates/show/disk/node.def b/templates/show/disk/node.def deleted file mode 100644 index 8572a9f..0000000 --- a/templates/show/disk/node.def +++ /dev/null @@ -1 +0,0 @@ -help: Show status of disk device diff --git a/templates/show/disk/node.tag/format/node.def b/templates/show/disk/node.tag/format/node.def deleted file mode 100644 index ad87cfc..0000000 --- a/templates/show/disk/node.tag/format/node.def +++ /dev/null @@ -1,7 +0,0 @@ -help: Show disk drive formatting -run: disk_dev="/dev/$3" - if [ ! -b "$disk_dev" ] - then echo "$3 is not a disk device" - exit 1 - fi - sudo /sbin/fdisk -l "$disk_dev" diff --git a/templates/show/disk/node.tag/node.def b/templates/show/disk/node.tag/node.def deleted file mode 100644 index 8690008..0000000 --- a/templates/show/disk/node.tag/node.def +++ /dev/null @@ -1,4 +0,0 @@ -help: Disk device name -allowed: awk 'NR > 2 && $4 !~ /[0-9]$/ { print $4 }' ' -run: last -aF -n $4 | sed -e "s/^wtmp begins/Displaying logins since/" -- cgit v1.2.3 From 418c6cfefcdf13cf6b96dd628bcd1d75046f179b Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 14 Jun 2018 21:17:51 +0200 Subject: T683: remove old Perl scripts for 'show snmp' --- Makefile.am | 3 - scripts/vyatta-show-snmp-ifmib | 138 --------------------------------- scripts/vyatta-show-snmp-v3.pl | 168 ----------------------------------------- scripts/vyatta-show-snmp.pl | 123 ------------------------------ 4 files changed, 432 deletions(-) delete mode 100644 scripts/vyatta-show-snmp-ifmib delete mode 100644 scripts/vyatta-show-snmp-v3.pl delete mode 100755 scripts/vyatta-show-snmp.pl (limited to 'scripts') diff --git a/Makefile.am b/Makefile.am index ad9c01a..0a1f89b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,9 +29,6 @@ bin_SCRIPTS += scripts/show-users.pl bin_SCRIPTS += scripts/show-dhcp-leases.pl bin_SCRIPTS += scripts/vyatta-boot-image.pl bin_SCRIPTS += scripts/vyatta-sudo -bin_SCRIPTS += scripts/vyatta-show-snmp.pl -bin_SCRIPTS += scripts/vyatta-show-snmp-ifmib -bin_SCRIPTS += scripts/vyatta-show-snmp-v3.pl bin_SCRIPTS += scripts/rename-image.pl bin_SCRIPTS += scripts/show-image-storage.pl bin_SCRIPTS += scripts/vyatta-remote-copy.pl diff --git a/scripts/vyatta-show-snmp-ifmib b/scripts/vyatta-show-snmp-ifmib deleted file mode 100644 index 8fb1004..0000000 --- a/scripts/vyatta-show-snmp-ifmib +++ /dev/null @@ -1,138 +0,0 @@ -#! /usr/bin/perl - -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Stephen Hemminger -# Date: Novemember 2010 -# Description: Script for show snmp ifmib -# -# **** End License **** - -use strict; -use warnings; -use Getopt::Long; -use POSIX qw(strtol); - -# This is used to show values corresponding to to results IF-MIB. -my %interfaces; - -sub show_ifindex { - foreach my $ifname (@_) { - my $info = $interfaces{$ifname}; - my $ifindex = $info->{'ifIndex'}; - printf "%s: ifIndex = %d\n", $ifname, $ifindex; - } -} - -sub show_ifalias { - foreach my $ifname (@_) { - my $info = $interfaces{$ifname}; - my $ifalias = $info->{'ifAlias'}; - printf "%s: ifAlias = %s\n", $ifname, - defined($ifalias) ? $ifalias : $ifname; - } -} - -sub read_sysfs { - my $filename = shift; - - open( my $f, '<', $filename ) - or return; # not a PCI device - - my $val = <$f>; - close $f; - - return strtol($val); -} - -# Imitate code in net-snmp to lookup PC -# TODO - move to common code extension (and handle USB?) -sub pci_info { - my $ifname = shift; - my $vendor_id = read_sysfs("/sys/class/net/$ifname/device/vendor"); - my $device_id = read_sysfs("/sys/class/net/$ifname/device/device"); - - return unless ( defined($vendor_id) && defined($device_id) ); - - my $cmd = sprintf("lspci -m -d %04x:%04x", $vendor_id, $device_id); - open( my $pci, '-|', $cmd ) - or die "Can't run $cmd"; - my $info = <$pci>; - close $pci; - - return unless $info; - - # extract vendor and device description from output - $info =~ /^\S+ "[^"]*" "([^"]*)" "([^"]*)"/; - - return "$1 $2"; -} - -sub show_ifdescr { - foreach my $ifname (@_) { - my $ifdescr = pci_info($ifname); - - printf "%s: ifDescr = %s\n", $ifname, - defined($ifdescr) ? $ifdescr : $ifname; - } -} - -sub show_all { - foreach my $ifname (@_) { - my $info = $interfaces{$ifname}; - my $ifindex = $info->{'ifIndex'}; - my $ifalias = $info->{'ifAlias'}; - my $ifdescr = pci_info($ifname); - - printf "%s: ifIndex = %d\n", $ifname, $ifindex; - - my $pad = sprintf( "%-*s", length($ifname) + 1, " " ); - printf "%s ifAlias = %s\n", $pad, $ifalias if ($ifalias); - printf "%s ifDescr = %s\n", $pad, $ifdescr if ($ifdescr); - } -} - -my $show = \&show_all; - -GetOptions( - "ifindex" => sub { $show = \&show_ifindex }, - "ifalias" => sub { $show = \&show_ifalias }, - "ifdescr" => sub { $show = \&show_ifdescr }, -) or die "Unknown option\n"; - -# List of all interfaces that currently exist on system -# includes interfaces that may be outside Vyatta CLI because -# they still show up in SNMP -open( my $ip, '-|', 'ip li' ) - or die "Can't run ip command\n"; - -my $ifname; -while (<$ip>) { - if (/^(\d+): ([^:]*): /) { - $ifname = $2; - $interfaces{$ifname} = { 'ifIndex' => $1 }; - } - elsif (/^ +alias (.*)$/) { - $interfaces{$ifname}->{'ifAlias'} = $1; - } -} -close $ip; - -if (@ARGV) { - $show->(@ARGV); -} -else { - $show->( sort keys %interfaces ); -} diff --git a/scripts/vyatta-show-snmp-v3.pl b/scripts/vyatta-show-snmp-v3.pl deleted file mode 100644 index dc81623..0000000 --- a/scripts/vyatta-show-snmp-v3.pl +++ /dev/null @@ -1,168 +0,0 @@ -#! /usr/bin/perl - -use Getopt::Long; - -sub show_view() { - print <= 20 ) { - print "$group\n $view($mode)\n"; - } - else { - $~ = "GROUP_FORMAT"; - format GROUP_FORMAT = -@<<<<<<<<<<<<<<<<<< @*(@*) -$group $view $mode -. - write; - } - } - print "\n"; -} - -sub show_user() { - print <= 20 ) { - print "$user\n $auth $priv $mode $group\n"; - } - else { - $~ = "USER_FORMAT"; - format USER_FORMAT = -@<<<<<<<<<<<<<<<<<< @<<< @<<< @<<< @* -$user $auth $priv $mode $group -. - write; - } - } - print "\n"; -} - -sub show_trap() { - print <= 30 ) { - $~ = "TRAP_BIG_FORMAT"; - format TRAP_BIG_FORMAT = -^* -$trap - @<<<<< @<<<<<<< @<<< @<<< @<<<<< @<<<<<<<<<<<<<<<<<<<<... @* -$port $protocol $auth $priv $type $engineid $user -. - write; - } - else { - $~ = "TRAP_FORMAT"; - format TRAP_FORMAT = -@<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<< @<<<<<<< @<<< @<<< @<<<<< @<<<<<<<<<<<<<<<<<<<<... @* -$trap $port $protocol $auth $priv $type $engineid $user -. - write; - } - } - print "\n"; -} - -sub show_all() { - show_user(); - show_group(); - show_view(); - show_trap(); -} - -sub listNodes { - my $path = shift; - my @nodes = - split( ' ', `cli-shell-api listActiveNodes service snmp v3 $path` ); - return map { substr $_, 1, -1 } @nodes; -} - -sub returnValue { - my $path = shift; - my $value = `cli-shell-api returnActiveValue service snmp v3 $path`; - return $value; -} - -sub isExists { - my $path = shift; - system("cli-shell-api existsActive service snmp v3 $path"); - return !$?; -} - -my $all; -my $view; -my $group; -my $user; -my $trap; - -GetOptions( - "all!" => \$all, - "view!" => \$view, - "group!" => \$group, - "user!" => \$user, - "trap!" => \$trap, -); - -show_all() if ($all); -show_view() if ($view); -show_group() if ($group); -show_user() if ($user); -show_trap() if ($trap); diff --git a/scripts/vyatta-show-snmp.pl b/scripts/vyatta-show-snmp.pl deleted file mode 100755 index 634b3cc..0000000 --- a/scripts/vyatta-show-snmp.pl +++ /dev/null @@ -1,123 +0,0 @@ -#! /usr/bin/perl - -# **** License **** -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# This code was originally developed by Vyatta, Inc. -# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Stephen Hemminger -# Date: January 2010 -# Description: Script to display SNMP information -# -# **** End License **** -# -use strict; -use warnings; -use Getopt::Long; -use NetAddr::IP; - -my $SNMPDCFG = '/etc/snmp/snmpd.conf'; -my $SNMPSTATUS = '/usr/bin/snmpstatus'; -my $password_file = '/config/snmp/superuser_pass'; - -# generate list of communities in configuration file -sub read_config { - my %community; - - die "Service SNMP does not configured.\n" if (! -e $SNMPDCFG); - - open( my $cfg, '<', $SNMPDCFG ) - or die "Can't open $SNMPDCFG : $!\n"; - - while (<$cfg>) { - chomp; - s/#.*$//; - my @cols = split; - next - unless ( $#cols > 0 - && ( $cols[0] eq 'rocommunity' || $cols[0] eq 'rwcommunity' ) ); - - my $addr = ( $#cols > 1 ) ? $cols[2] : "0.0.0.0/0"; - $community{ $cols[1] } = NetAddr::IP->new($addr); - } - close $cfg; - - return \%community; -} - -# expand list of available communities for allowed: tag -sub show_all { - my $community = read_config(); - - print join( ' ', keys( %{$community} ) ), "\n"; - exit 0; -} - -# check status of any accessible community on localhost -sub status_any { - my $cref = read_config(); - my %community = %{$cref}; - my $localhost = new NetAddr::IP('localhost'); - - if (scalar(%community)) { - foreach my $c ( keys %community ) { - my $addr = $community{$c}; - status( $c, $localhost->addr() ) if ( $addr->contains($localhost) ); - } - } - status_v3(); - -} - -sub status_v3 { - open (my $file, '<' , $password_file) or die "Couldn't open $password_file - $!"; - my $superuser_pass = do { local $/; <$file> }; - close $file; - open ($file, '<', $SNMPDCFG) or die "Couldn't open $SNMPDCFG - $!"; - my $superuser_login = ''; - while (my $line = <$file>) { - if ($line =~ /^iquerySecName (.*)$/) { - $superuser_login = $1; - } - } - close $file; - exec $SNMPSTATUS, '-v3', '-l', 'authNoPriv', '-u', $superuser_login, '-A', $superuser_pass, 'localhost'; -} - -# check status of one community -sub status { - my ( $community, $host ) = @_; - $host = 'localhost' unless defined($host); - - print "Status of SNMP community $community on $host\n"; - exec $SNMPSTATUS, '-v1', '-c', $community, $host; - die "Can't exec $SNMPSTATUS : $!"; -} - -sub usage { - print "usage: $0 [--community=name [--host=hostname]]\n"; - print " $0 --allowed\n"; - exit 1; -} - -my ( $host, $community, $allowed ); - -GetOptions( - "host=s" => \$host, - "community=s" => \$community, - "allowed" => \$allowed, -) or usage(); - -show_all() if ($allowed); -status( $community, $host ) if ( defined($community) ); -status_any(); - -- cgit v1.2.3