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({
my $res = [
{ id => 'update' },
{ id => 'upgrade' },
{ id => 'changelog' },
];
......@@ -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({
name => 'changelog',
path => 'changelog',
......
......@@ -576,6 +576,12 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
upgrade => {
type => 'boolean',
description => "Run 'apt-get dist-upgrade' instead of normal shell.",
optional => 1,
default => 0,
},
},
},
returns => {
......@@ -597,6 +603,8 @@ __PACKAGE__->register_method ({
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 $authpath = "/nodes/$node";
......@@ -619,7 +627,17 @@ __PACKAGE__->register_method ({
my $remcmd = $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;
......
......@@ -503,7 +503,6 @@ Ext.define('PVE.Utils', { statics: {
download: ['', gettext('Download') ],
vzdump: ['', gettext('Backup') ],
aptupdate: ['', gettext('Update package database') ],
aptupgrade: ['', gettext('System upgrade') ],
startall: [ '', gettext('Start all VMs and Containers') ],
stopall: [ '', gettext('Stop all VMs and Containers') ]
},
......
......@@ -417,6 +417,8 @@ Ext.define('PVE.Shell', {
extend: 'PVE.VNCConsole',
alias: ['widget.pveShell'],
ugradeSystem: false, // set to true to run "apt-get dist-upgrade"
initComponent : function() {
var me = this;
......@@ -432,24 +434,37 @@ Ext.define('PVE.Shell', {
var applet = Ext.getDom(me.appletID);
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'),
handler: function() {
PVE.Utils.openConoleWindow('shell', undefined, me.nodename);
}
}
];
]);
Ext.apply(me, {
tbar: tbar,
url: "/nodes/" + me.nodename + "/vncshell"
});
if (me.ugradeSystem) {
me.params = { upgrade: 1 };
}
me.callParent();
}
});
......@@ -141,12 +141,20 @@ Ext.define('PVE.ConsoleWorkspace', {
toplevel: true
};
} else if (consoleType === 'shell') {
me.title = "node '" + param.node;
me.title = "node '" + param.node + "'";
content = {
xtype: 'pveShell',
nodename: param.node,
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 {
content = {
border: false,
......
......@@ -80,14 +80,20 @@ Ext.define('PVE.node.APT', {
var upgrade_btn = new PVE.button.Button({
text: gettext('Upgrade'),
dangerous: true,
confirmMsg: function(rec) {
return gettext('Are you sure you want to upgrade this node?');
},
handler: function(){
PVE.Utils.checked_command(function() { apt_command('upgrade'); });
disabled: !(PVE.UserName && PVE.UserName === 'root@pam'),
handler: function() {
PVE.Utils.checked_command(function() {
var url = Ext.urlEncode({
console: 'upgrade',
node: nodename
});
var nw = window.open("?" + url, '_blank',
"innerWidth=745,innerheight=427");
nw.focus();
});
}
});
});
var show_changelog = function(rec) {
if (!rec || !rec.data || !(rec.data.ChangeLogUrl && rec.data.Package)) {
......
......@@ -144,14 +144,17 @@ Ext.define('PVE.node.Config', {
itemId: 'support',
xtype: 'pveNodeSubscription',
nodename: nodename
},
{
}
]);
if (caps.nodes['Sys.Console']) {
me.items.push([{
title: gettext('Updates'),
itemId: 'apt',
xtype: 'pveNodeAPT',
nodename: nodename
}
]);
}]);
}
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