pveversion 2.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#!/usr/bin/perl -w

use strict;
use Getopt::Long;
use PVE::pvecfg;

sub read_pkglist {

    my $pkglist = {};

    open (TMP, "dpkg-query --show -f '\${PACKAGE} \${VERSION} \${STATUS}\n'|") ||
	die "cant exec dpkg-query\n";

    while (defined (my $line = <TMP>)) {
	if ($line =~ m/^(\S+)\s+(\S+)\s+install\s+ok\s+installed$/) {
	    my ($pkg, $version) = ($1, $2);
	    $pkglist->{$pkg} = $version;
	}
    }
    
    return $pkglist;
}

my $pkglist = read_pkglist();

sub print_status {
    my ($pkg, $repoid) = @_;

    my $version = "not correctly installed";
    if ($pkglist->{$pkg}) {
	$version = $pkglist->{$pkg};
    }

    if ($repoid) {
	print "$pkg: $version ($repoid)\n";
    } else {
	print "$pkg: $version\n";
    }
}

sub print_usage {
    my $msg = shift;

    print STDERR "ERROR: $msg\n" if $msg;
    print STDERR "USAGE: pveversion [--verbose]\n";

}

my $opt_verbose;

if (!GetOptions ('verbose' => \$opt_verbose)) {
    print_usage ();
    exit (-1);
} 

if (scalar (@ARGV) != 0) {
    print_usage ();
    exit (-1);
}

my $ver =  PVE::pvecfg::package();
$ver .= '/';
$ver .= PVE::pvecfg::version();
$ver .= '/';
$ver .= PVE::pvecfg::repoid();

my $kver = `uname -r`;
chomp $kver;

if (!$opt_verbose) {
    print "$ver\n";
    exit (0);
}

print_status ("pve-manager", $ver);
print "running kernel: $kver\n";

78
my @list = qw(lvm2 clvm corosync-pve openais-pve libqb0 redhat-cluster-pve resource-agents-pve fence-agents-pve pve-cluster qemu-server pve-firmware libpve-common-perl libpve-access-control libpve-storage-perl vncterm vzctl vzprocps vzquota);
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

my $pkg = 'proxmox-ve-2.6.18';
if (my $v = $pkglist->{$pkg}) {
    print "$pkg: $v\n";
    push @list, 'pve-qemu-kvm-2.6.18';
    
}
$pkg = 'proxmox-ve-2.6.24';
if (my $v = $pkglist->{$pkg}) {
    print "$pkg: $v\n";
    push @list, 'pve-qemu-kvm';
}
$pkg = 'proxmox-ve-2.6.32';
if (my $v = $pkglist->{$pkg}) {
    print "$pkg: $v\n";
    push @list, 'pve-qemu-kvm';
    push @list, 'ksm-control-daemon';
}

foreach $pkg (grep { m/^pve-kernel-/ } keys %$pkglist) {
    print "$pkg: $pkglist->{$pkg}\n";    
}
 
foreach my $p (@list) {
    print_status ($p);
}

exit 0;

__END__

=head1 NAME

pveversion - Proxmox  VE version info

=head1 SYNOPSIS

pveversion [--verbose]

=head1 DESCRIPTION

Print version information for Proxmox VE packages.