]> git.proxmox.com Git - pve-manager.git/blame - bin/pveupgrade
update shipped appliance info index
[pve-manager.git] / bin / pveupgrade
CommitLineData
776de3bc 1#!/usr/bin/perl
b179a622
DM
2
3use strict;
776de3bc
SP
4use warnings;
5
b179a622
DM
6use File::stat ();
7use Getopt::Long;
8
9use PVE::Tools;
10use PVE::Cluster;
11use PVE::SafeSyslog;
12use PVE::INotify;
13use PVE::RPCEnvironment;
14use PVE::API2::APT;
15
16$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
17
18initlog('pveupgrade');
19
20die "please run as root\n" if $> != 0;
21
22PVE::INotify::inotify_init();
23my $nodename = PVE::INotify::nodename();
24
25my $rpcenv = PVE::RPCEnvironment->init('cli');
26
27$rpcenv->init_request();
28$rpcenv->set_language($ENV{LANG});
29$rpcenv->set_user('root@pam');
30
31my $start_shell;
32
33if (!GetOptions ("shell" => \$start_shell)) {
34 print "Usage: $0 [--shell]\n";
35 exit(-1);
36}
37
38my $st = File::stat::stat("/var/cache/apt/pkgcache.bin");
39if (!$st || (time() - $st->mtime) > (3*24*3600)) {
40
41 print "\nYour package database is out of date. Please update that first.\n\n";
42
43} else {
44
ecddd2e2 45 my $cmdstr = 'apt-get dist-upgrade';
b179a622 46
ecddd2e2 47 print "Starting system upgrade: apt-get dist-upgrade\n";
b179a622
DM
48
49 my $oldlist = PVE::API2::APT->list_updates({ node => $nodename});
50
ecddd2e2 51 system('apt-get', 'dist-upgrade');
b179a622
DM
52
53 my $pkglist = PVE::API2::APT->list_updates({ node => $nodename});
54
55 print "\n";
56 if (my $count = scalar(@$pkglist)) {
57 print "System not fully up to date (found $count new packages)\n\n";
58 } else {
59 print "Your System is up-to-date\n\n";
60 }
61
62 my $newkernel;
63 foreach my $p (@$oldlist) {
3fc687f5 64 if (($p->{Package} =~ m/^(?:pve|proxmox)-kernel/) &&
b179a622
DM
65 !grep { $_->{Package} eq $p->{Package} } @$pkglist) {
66 $newkernel = 1;
67 last;
68 }
69 }
70
71 if ($newkernel) {
72 print "\n";
73 print "Seems you installed a kernel update - Please consider rebooting\n" .
74 "this node to activate the new kernel.\n\n";
75 }
76}
77
78
79if ($start_shell) {
80 print "starting shell\n";
81 system('/bin/bash -l');
82}
83
84exit 0;
85
86
87__END__
88
89=head1 NAME
90
ecddd2e2 91pveupgrade - wrapper arournd "apt-get dist-upgrade"
b179a622
DM
92
93=head1 SYNOPSIS
94
95 pveupgrade [--shell]
96
97=head1 DESCRIPTION
98
ecddd2e2 99This is a small wrapper around "apt-get dist-upgrade". We use this to
b179a622
DM
100print additional information (kernel restart required?), and
101optionally run an interactive shell after the update (--shell)