]>
git.proxmox.com Git - pmg-api.git/blob - src/PMG/CLI/pmgupgrade.pm
1 package PMG
::CLI
::pmgupgrade
;
8 use PVE
::Tools
qw(extract_param);
12 use PMG
::RESTEnvironment
;
15 use base
qw(PVE::CLIHandler);
17 sub setup_environment
{
18 PMG
::RESTEnvironment-
>setup_default_cli_env();
21 __PACKAGE__-
>register_method ({
25 description
=> "Upgrade Proxmox Mail Gateway",
27 additionalProperties
=> 0,
31 description
=> "Run an interactive shell after the update.",
37 returns
=> { type
=> 'null'},
41 my $nodename = PVE
::INotify
::nodename
();
43 my $st = File
::stat::stat("/var/cache/apt/pkgcache.bin");
44 if (!$st || (time() - $st->mtime) > (3*24*3600)) {
45 print "\nYour package database is out of date. " .
46 "Please update that first.\n\n";
50 my $cmdstr = 'apt-get dist-upgrade';
52 print "Starting system upgrade: apt-get dist-upgrade\n";
54 my $oldlist = PMG
::API2
::APT-
>list_updates({ node
=> $nodename});
56 system('apt-get', 'dist-upgrade');
58 my $pkglist = PMG
::API2
::APT-
>list_updates({ node
=> $nodename});
61 if (my $count = scalar(@$pkglist)) {
62 print "System not fully up to date (found $count new packages)\n\n";
64 print "Your System is up-to-date\n\n";
68 foreach my $p (@$oldlist) {
69 if (($p->{Package
} =~ m/^(?:pve|proxmox)-kernel/) &&
70 !grep { $_->{Package
} eq $p->{Package
} } @$pkglist) {
78 print "Seems you installed a kernel update - Please consider rebooting\n" .
79 "this node to activate the new kernel.\n\n";
82 if ($param->{shell
}) {
83 print "starting shell\n";
84 system('/bin/bash -l');
90 our $cmddef = [ __PACKAGE__
, 'pmgupgrade', []];