Commit 05ba0daf authored by Dietmar Maurer's avatar Dietmar Maurer

use interactive vnc shell to run system upgrade

System upgrade almost always requires user input.
parent 03d19bdc
...@@ -60,7 +60,6 @@ __PACKAGE__->register_method({ ...@@ -60,7 +60,6 @@ __PACKAGE__->register_method({
my $res = [ my $res = [
{ id => 'update' }, { id => 'update' },
{ id => 'upgrade' },
{ id => 'changelog' }, { id => 'changelog' },
]; ];
...@@ -254,56 +253,6 @@ __PACKAGE__->register_method({ ...@@ -254,56 +253,6 @@ __PACKAGE__->register_method({
}}); }});
__PACKAGE__->register_method({
name => 'upgrade',
path => 'upgrade',
method => 'POST',
description => "Install the newest versions of all packages (apt-get dist-upgrade).",
permissions => {
check => ['perm', '/nodes/{node}', [ 'Sys.Modify' ]],
},
protected => 1,
proxyto => 'node',
parameters => {
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
},
returns => {
type => 'string',
},
code => sub {
my ($param) = @_;
my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();
my $realcmd = sub {
my $upid = shift;
my $cmd = ['apt-get', 'dist-upgrade', '--assume-yes'];
push @$cmd, '-o', 'Dpkg::Options::=--force-confdef';
push @$cmd, '-o', 'Dpkg::Options::=--force-confold';
print "starting apt-get dist-upgrade\n";
$ENV{DEBIAN_FRONTEND} = 'noninteractive';
PVE::Tools::run_command($cmd);
&$update_pve_pkgstatus();
return;
};
return $rpcenv->fork_worker('aptupgrade', undef, $authuser, $realcmd);
}});
__PACKAGE__->register_method({ __PACKAGE__->register_method({
name => 'changelog', name => 'changelog',
path => 'changelog', path => 'changelog',
......
...@@ -576,6 +576,12 @@ __PACKAGE__->register_method ({ ...@@ -576,6 +576,12 @@ __PACKAGE__->register_method ({
additionalProperties => 0, additionalProperties => 0,
properties => { properties => {
node => get_standard_option('pve-node'), node => get_standard_option('pve-node'),
upgrade => {
type => 'boolean',
description => "Run 'apt-get dist-upgrade' instead of normal shell.",
optional => 1,
default => 0,
},
}, },
}, },
returns => { returns => {
...@@ -597,6 +603,8 @@ __PACKAGE__->register_method ({ ...@@ -597,6 +603,8 @@ __PACKAGE__->register_method ({
raise_perm_exc("realm != pam") if $realm ne 'pam'; raise_perm_exc("realm != pam") if $realm ne 'pam';
raise_perm_exc('user != root@pam') if $param->{upgrade} && $user ne 'root@pam';
my $node = $param->{node}; my $node = $param->{node};
my $authpath = "/nodes/$node"; my $authpath = "/nodes/$node";
...@@ -619,7 +627,17 @@ __PACKAGE__->register_method ({ ...@@ -619,7 +627,17 @@ __PACKAGE__->register_method ({
my $remcmd = $remip ? my $remcmd = $remip ?
['/usr/bin/ssh', '-t', $remip] : []; ['/usr/bin/ssh', '-t', $remip] : [];
my $shcmd = $user eq 'root@pam' ? [ "/bin/bash", "-l" ] : [ "/bin/login" ]; my $shcmd;
if ($user eq 'root@pam') {
if ($param->{upgrade}) {
$shcmd = [ '/bin/bash', '-l', '-c', 'apt-get dist-upgrade; /bin/bash' ];
} else {
$shcmd = [ '/bin/bash', '-l' ];
}
} else {
$shcmd = [ '/bin/login' ];
}
my $timeout = 10; my $timeout = 10;
......
...@@ -503,7 +503,6 @@ Ext.define('PVE.Utils', { statics: { ...@@ -503,7 +503,6 @@ Ext.define('PVE.Utils', { statics: {
download: ['', gettext('Download') ], download: ['', gettext('Download') ],
vzdump: ['', gettext('Backup') ], vzdump: ['', gettext('Backup') ],
aptupdate: ['', gettext('Update package database') ], aptupdate: ['', gettext('Update package database') ],
aptupgrade: ['', gettext('System upgrade') ],
startall: [ '', gettext('Start all VMs and Containers') ], startall: [ '', gettext('Start all VMs and Containers') ],
stopall: [ '', gettext('Stop all VMs and Containers') ] stopall: [ '', gettext('Stop all VMs and Containers') ]
}, },
......
...@@ -417,6 +417,8 @@ Ext.define('PVE.Shell', { ...@@ -417,6 +417,8 @@ Ext.define('PVE.Shell', {
extend: 'PVE.VNCConsole', extend: 'PVE.VNCConsole',
alias: ['widget.pveShell'], alias: ['widget.pveShell'],
ugradeSystem: false, // set to true to run "apt-get dist-upgrade"
initComponent : function() { initComponent : function() {
var me = this; var me = this;
...@@ -432,24 +434,37 @@ Ext.define('PVE.Shell', { ...@@ -432,24 +434,37 @@ Ext.define('PVE.Shell', {
var applet = Ext.getDom(me.appletID); var applet = Ext.getDom(me.appletID);
applet.sendRefreshRequest(); applet.sendRefreshRequest();
} }
}, }
{ ];
text: gettext('Reload'),
handler: function () { me.reloadApplet(); } if (!me.ugradeSystem) {
}, // we dont want to restart the upgrade script
tbar.push([
{
text: gettext('Reload'),
handler: function () { me.reloadApplet(); }
}]);
}
tbar.push([
{ {
text: gettext('Shell'), text: gettext('Shell'),
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('shell', undefined, me.nodename); PVE.Utils.openConoleWindow('shell', undefined, me.nodename);
} }
} }
]; ]);
Ext.apply(me, { Ext.apply(me, {
tbar: tbar, tbar: tbar,
url: "/nodes/" + me.nodename + "/vncshell" url: "/nodes/" + me.nodename + "/vncshell"
}); });
if (me.ugradeSystem) {
me.params = { upgrade: 1 };
}
me.callParent(); me.callParent();
} }
}); });
...@@ -141,12 +141,20 @@ Ext.define('PVE.ConsoleWorkspace', { ...@@ -141,12 +141,20 @@ Ext.define('PVE.ConsoleWorkspace', {
toplevel: true toplevel: true
}; };
} else if (consoleType === 'shell') { } else if (consoleType === 'shell') {
me.title = "node '" + param.node; me.title = "node '" + param.node + "'";
content = { content = {
xtype: 'pveShell', xtype: 'pveShell',
nodename: param.node, nodename: param.node,
toplevel: true toplevel: true
}; };
} else if (consoleType === 'upgrade') {
me.title = Ext.String.format(gettext('System upgrade on node {0}'), "'" + param.node + "'");
content = {
xtype: 'pveShell',
nodename: param.node,
ugradeSystem: true,
toplevel: true
};
} else { } else {
content = { content = {
border: false, border: false,
......
...@@ -80,14 +80,20 @@ Ext.define('PVE.node.APT', { ...@@ -80,14 +80,20 @@ Ext.define('PVE.node.APT', {
var upgrade_btn = new PVE.button.Button({ var upgrade_btn = new PVE.button.Button({
text: gettext('Upgrade'), text: gettext('Upgrade'),
dangerous: true, disabled: !(PVE.UserName && PVE.UserName === 'root@pam'),
confirmMsg: function(rec) { handler: function() {
return gettext('Are you sure you want to upgrade this node?'); PVE.Utils.checked_command(function() {
}, var url = Ext.urlEncode({
handler: function(){ console: 'upgrade',
PVE.Utils.checked_command(function() { apt_command('upgrade'); }); node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
});
} }
}); });
var show_changelog = function(rec) { var show_changelog = function(rec) {
if (!rec || !rec.data || !(rec.data.ChangeLogUrl && rec.data.Package)) { if (!rec || !rec.data || !(rec.data.ChangeLogUrl && rec.data.Package)) {
......
...@@ -144,14 +144,17 @@ Ext.define('PVE.node.Config', { ...@@ -144,14 +144,17 @@ Ext.define('PVE.node.Config', {
itemId: 'support', itemId: 'support',
xtype: 'pveNodeSubscription', xtype: 'pveNodeSubscription',
nodename: nodename nodename: nodename
}, }
{ ]);
if (caps.nodes['Sys.Console']) {
me.items.push([{
title: gettext('Updates'), title: gettext('Updates'),
itemId: 'apt', itemId: 'apt',
xtype: 'pveNodeAPT', xtype: 'pveNodeAPT',
nodename: nodename nodename: nodename
} }]);
]); }
me.callParent(); me.callParent();
......
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