Commit abc4a675 authored by Dietmar Maurer's avatar Dietmar Maurer

new pveupgrade script

Used to display additional information to the user (reboot required? database
up to date? ...)
parent f9ece1aa
......@@ -617,7 +617,7 @@ __PACKAGE__->register_method ({
my $port = PVE::Tools::next_vnc_port();
my $remip;
if ($node ne PVE::INotify::nodename()) {
$remip = PVE::Cluster::remote_node_ip($node);
}
......@@ -631,7 +631,7 @@ __PACKAGE__->register_method ({
if ($user eq 'root@pam') {
if ($param->{upgrade}) {
$shcmd = [ '/bin/bash', '-l', '-c', 'apt-get dist-upgrade; /bin/bash' ];
$shcmd = [ '/bin/bash', '-c', '"pveupgrade --shell"' ];
} else {
$shcmd = [ '/bin/bash', '-l' ];
}
......
......@@ -15,6 +15,7 @@ SCRIPTS = \
pveversion \
pvesubscription \
pvemailforward.pl \
pveupgrade \
pveperf
MANS = \
......@@ -26,6 +27,7 @@ MANS = \
pveproxy.1 \
pveversion.1 \
pvesubscription.1 \
pveupgrade.1 \
pveperf.1
all: ${MANS} pvemailforward
......
#!/usr/bin/perl -w
use strict;
use File::stat ();
use Getopt::Long;
use PVE::Tools;
use PVE::Cluster;
use PVE::SafeSyslog;
use PVE::INotify;
use PVE::RPCEnvironment;
use PVE::API2::APT;
$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
initlog('pveupgrade');
die "please run as root\n" if $> != 0;
PVE::INotify::inotify_init();
my $nodename = PVE::INotify::nodename();
my $rpcenv = PVE::RPCEnvironment->init('cli');
$rpcenv->init_request();
$rpcenv->set_language($ENV{LANG});
$rpcenv->set_user('root@pam');
my $start_shell;
if (!GetOptions ("shell" => \$start_shell)) {
print "Usage: $0 [--shell]\n";
exit(-1);
}
my $st = File::stat::stat("/var/cache/apt/pkgcache.bin");
if (!$st || (time() - $st->mtime) > (3*24*3600)) {
print "\nYour package database is out of date. Please update that first.\n\n";
} else {
my $cmdstr = 'apt-get dist-upgrade';
print "Starting system upgrade: apt-get dist-upgrade\n";
my $oldlist = PVE::API2::APT->list_updates({ node => $nodename});
system('apt-get', 'dist-upgrade');
my $pkglist = PVE::API2::APT->list_updates({ node => $nodename});
print "\n";
if (my $count = scalar(@$pkglist)) {
print "System not fully up to date (found $count new packages)\n\n";
} else {
print "Your System is up-to-date\n\n";
}
my $newkernel;
foreach my $p (@$oldlist) {
if (($p->{Package} =~m /^pve-kernel/) &&
!grep { $_->{Package} eq $p->{Package} } @$pkglist) {
$newkernel = 1;
last;
}
}
if ($newkernel) {
print "\n";
print "Seems you installed a kernel update - Please consider rebooting\n" .
"this node to activate the new kernel.\n\n";
}
}
if ($start_shell) {
print "starting shell\n";
system('/bin/bash -l');
}
exit 0;
__END__
=head1 NAME
pveupgrade - wrapper arournd "apt-get dist-upgrade"
=head1 SYNOPSIS
pveupgrade [--shell]
=head1 DESCRIPTION
This is a small wrapper around "apt-get dist-upgrade". We use this to
print additional information (kernel restart required?), and
optionally run an interactive shell after the update (--shell)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment