From 97219ae83258061d524a110e5bd9d70d2aa70733 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 19 Dec 2015 04:35:30 +0100 Subject: Remove referenced to Vyatta from 'show version' completion help. --- templates/show/version/added/node.def | 2 +- templates/show/version/all/node.def | 2 +- templates/show/version/deleted/node.def | 2 +- templates/show/version/downgraded/node.def | 2 +- templates/show/version/node.def | 2 +- templates/show/version/upgraded/node.def | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'templates/show/version') diff --git a/templates/show/version/added/node.def b/templates/show/version/added/node.def index b17ca68..2381b74 100644 --- a/templates/show/version/added/node.def +++ b/templates/show/version/added/node.def @@ -1,2 +1,2 @@ -help: Show Vyatta version information plus added packages +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 76fff72..5b60609 100644 --- a/templates/show/version/all/node.def +++ b/templates/show/version/all/node.def @@ -1,2 +1,2 @@ -help: Show Vyatta version information plus all packages changes +help: Show VyOS version information plus all packages changes run: ${vyatta_bindir}/vyatta-show-version all diff --git a/templates/show/version/deleted/node.def b/templates/show/version/deleted/node.def index 4567031..d328cf6 100644 --- a/templates/show/version/deleted/node.def +++ b/templates/show/version/deleted/node.def @@ -1,2 +1,2 @@ -help: Show Vyatta version information plus deleted packages +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 index 4948f1b..250b048 100644 --- a/templates/show/version/downgraded/node.def +++ b/templates/show/version/downgraded/node.def @@ -1,2 +1,2 @@ -help: Show Vyatta version information plus downgraded packages +help: Show VyOS version information plus downgraded packages run: ${vyatta_bindir}/vyatta-show-version downgraded diff --git a/templates/show/version/node.def b/templates/show/version/node.def index 272589e..4237e5d 100644 --- a/templates/show/version/node.def +++ b/templates/show/version/node.def @@ -1,2 +1,2 @@ -help: Show Vyatta version information +help: Show VyOS version information run: ${vyatta_bindir}/vyatta-show-version diff --git a/templates/show/version/upgraded/node.def b/templates/show/version/upgraded/node.def index 1826ceb..b693c23 100644 --- a/templates/show/version/upgraded/node.def +++ b/templates/show/version/upgraded/node.def @@ -1,2 +1,2 @@ -help: Show Vyatta version information plus upgraded packages +help: Show VyOS version information plus upgraded packages run: ${vyatta_bindir}/vyatta-show-version upgraded -- cgit v1.2.3 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. --- Makefile.am | 1 + scripts/limericks.py | 51 +++++++++++++++++++++++++++++++++++ templates/show/version/funny/node.def | 5 ++++ 3 files changed, 57 insertions(+) create mode 100644 scripts/limericks.py create mode 100644 templates/show/version/funny/node.def (limited to 'templates/show/version') diff --git a/Makefile.am b/Makefile.am index 410c419..e736419 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,7 @@ 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 sbin_SCRIPTS = scripts/dhcpv6-client-show-leases.pl sbin_SCRIPTS += scripts/vyatta-image-tools.pl 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) diff --git a/templates/show/version/funny/node.def b/templates/show/version/funny/node.def new file mode 100644 index 0000000..cb62c96 --- /dev/null +++ b/templates/show/version/funny/node.def @@ -0,0 +1,5 @@ +help: Show VyOS version information plus a funny poem +run: + ${vyatta_bindir}/vyatta-show-version + ${vyatta_bindir}/limericks.py + -- 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 'templates/show/version') 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 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 'templates/show/version') 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 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 'templates/show/version') 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