[pve-devel] [PATCH manager 2/4] api: new parameter for each shell to pass custom command string

Tim Marx t.marx at proxmox.com
Thu Jan 10 13:54:31 CET 2019


Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
 PVE/API2/Nodes.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index dd5471f8..c1f73cd0 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -658,6 +658,11 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 0,
 	    },
+	    cmd => {
+		type => 'string',
+		description => "Run command instead of normal shell.",
+		optional => 1,
+	    },
 	    websocket => {
 		optional => 1,
 		type => 'boolean',
@@ -731,6 +736,8 @@ __PACKAGE__->register_method ({
 		my $upgradecmd = "pveupgrade --shell";
 		$upgradecmd = PVE::Tools::shellquote($upgradecmd) if $remip;
 		$shcmd = [ '/bin/bash', '-c', $upgradecmd ];
+	    } elsif ($param->{cmd}) {
+		push(@$shcmd, split(' ',$param->{cmd}));
 	    } else {
 		$shcmd = [ '/bin/login', '-f', 'root' ];
 	    }
@@ -817,6 +824,11 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 0,
 	    },
+	    cmd => {
+		type => 'string',
+		description => "Run command instead of normal shell.",
+		optional => 1,
+	    },
 	},
     },
     returns => {
@@ -861,6 +873,8 @@ __PACKAGE__->register_method ({
 	if ($user eq 'root at pam') {
 	    if ($param->{upgrade}) {
 		$concmd = [ '/usr/bin/pveupgrade', '--shell' ];
+	    } elsif ($param->{cmd}) {
+		@$concmd = split(' ',$param->{cmd});
 	    } else {
 		$concmd = [ '/bin/login', '-f', 'root' ];
 	    }
@@ -964,6 +978,11 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 0,
 	    },
+	    cmd => {
+		type => 'string',
+		description => "Run command instead of normal shell.",
+		optional => 1,
+	    },
 	},
     },
     returns => get_standard_option('remote-viewer-config'),
@@ -991,6 +1010,8 @@ __PACKAGE__->register_method ({
 	    if ($param->{upgrade}) {
 		my $upgradecmd = "pveupgrade --shell";
 		$shcmd = [ '/bin/bash', '-c', $upgradecmd ];
+	    } elsif ($param->{cmd}) {
+		@$shcmd = split(' ',$param->{cmd});
 	    } else {
 		$shcmd = [ '/bin/login', '-f', 'root' ];
 	    }
-- 
2.11.0




More information about the pve-devel mailing list