Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Upgrade/Downgrade accounts from command line

Discussion in 'General Discussion' started by FrankLaszlo, Aug 3, 2010.

  1. FrankLaszlo

    FrankLaszlo Active Member

    Joined:
    Dec 19, 2008
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    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?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. sirdopes

    sirdopes Well-Known Member
    PartnerNOC

    Joined:
    Sep 25, 2007
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    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;
     
  3. FrankLaszlo

    FrankLaszlo Active Member

    Joined:
    Dec 19, 2008
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice