Upgrade/Downgrade accounts from command line

FrankLaszlo

Active Member
Dec 19, 2008
35
0
56
Is there a /scripts command or any other way to upgrade/downgrade an account from the command line? I have a fairly large list of accounts on many servers that I need to upgrade/downgrade, and I was not able to locate a way to do this from the command line. I know I could code some stuff using the cPanel API and do requests with curl, but I'd rather avoid having to do that if I can solve it with a simple shell script.

Any ideas?
 

sirdopes

Well-Known Member
PartnerNOC
Sep 25, 2007
141
0
66
I'm not sure how to do it directly from the command line without calling the api, but this is how I would do it in perl

Code:
#!/usr/bin/perl

my $name = "user";


open(AHASH, "/root/.accesshash");
my @access = <AHASH> ;
close AHASH;
my $hash = join("\n", @access);

$hash =~ s/\n//g;
my $auth = "WHM root:" . $hash;
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new( GET => "http://127.0.0.1:2086/xml-api/changepackage?user=$name&pkg=TestPKG" );
$request->header( Authorization => $auth );

my $response = $ua->request($request);
print $response->content;
 

FrankLaszlo

Active Member
Dec 19, 2008
35
0
56
I ended up modifying some of my own API code to do it. The code you have would work, but its designed for local access, and for a single server. :) I had to run this across about 50 of our servers.

Fortunately, I had some existing API code that wasn't too difficult to modify to suite my needs.

Thanks anywyas.