The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to change cpanel accts and packages to x3 after uninstalling rvskin?

Discussion in 'General Discussion' started by electric, May 12, 2014.

  1. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    Hello,

    We are going to uninstall the "RVSKIN" cpanel theme from our servers. How can we change all accounts and WHM Packages that are using one of the rvskin themes to "x3"?

    The rvskin includes a bunch of different themes that customers might be using:

    rvskin
    rvneo
    rvdiy
    rvgreen
    rvblue
    rvpink
    rvlight
    etc...

    (They all start with the "rv" prefix...)

    We want to modify all the accounts and packages that are using any of the "rvskin" themes to "x3".

    Thanks!
     
    #1 electric, May 12, 2014
    Last edited: May 12, 2014
  2. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    To clarify, a different way to accomplish what we want is to switch all WHM package themes and customer account themes that are not "paper_lantern" to "x3".

    So any cpanel account or WHM package that is set to "paper_lantern" should be left as-is. Anything else should be switched to "x3".

    Thanks!
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    You can simply edit your packages via:

    "WHM Home » Packages » Edit a Package"

    Change the theme configured for the package, and all accounts using that package will have their theme updated automatically.

    Thank you.
     
  4. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    We have several hundred customer accounts, dozens of resellers, and about 80 different packages.

    Updating every package one-by-one isn't realistic.

    Also, your solution doesn't consider any cpanel accounts not associated with a package.

    It also doesn't consider the scenario where reseller has modified a cpanel account in some way, yet chosen to keep it linked to the package without modifying the package settings. By updating the reseller's package, we would cause any custom modifications they've made to that account to be lost. (Which would result in a reseller customer who is mad at us for screwing around with his accounts...)
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Yes, that's all important information to consider. You may want to manually modify the files in:

    /var/cpanel/users/
    /var/cpanel/packages/

    Change the "RS=" value for the cPanel user files, and the "CPMOD=" value in the packages using a custom bash command (e.g. replace). After modifying the cPanel user files, then run:

    Code:
    /scripts/updateuserdomains
    Thank you.
     
  6. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    Is there any way to automate this? As I mentioned, we have many hundreds of cpanel accounts and dozens of packages on our servers. Manually editing individual files is not realistic. (Especially since we have multiple servers...)

    - - - Updated - - -

    In other words, surely the cpanel devs must have a tool or code to do this already? I can't believe I'm the first/only cpanel customer to ask how to do this over the years...
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I suggested using a custom bash command such as "replace" to complete this for all accounts with one or two commands. In a thread you replied to last week, a user suggests a custom script:

    http://forums.cpanel.net/f8/how-modify-theme-rvblue-x3-all-accounts-406041.html#post1633941

    However, if you are looking for native functionality within cPanel, that would require a feature request:

    Submit A Feature Request

    Thank you.
     
  8. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    For anyone who is reading this, here is some simple PHP code the uses the cpanel/WHM api to change the theme for all accounts that are NOT using "x3" or "paper_lantern":
    PHP:
    <?php

    $whm_hostname 
    "your.serverdomain.com";
    $whm_username "root";
    $whm_password "password";

    // Get list of all accounts on the server.
    $result doCpanelQuery("https://".$whm_hostname.":2087/json-api/listaccts");
    $result json_decode($resulttrue);

    // Check if current theme is anything besides x3 or paper_lantern.
    foreach($result['acct'] as $key=>$value) {

        if ( (
    $value['theme'] != "x3") && ($value['theme'] != "paper_lantern") ) {

            echo 
    $value['user'] ." : " $value['theme'] . " : ";

            
    // Change theme to x3.
            
    $result2 doCpanelQuery("https://".$whm_hostname.":2087/json-api/modifyacct?user=".$value['user']."&RS=x3");
            
    $result2 json_decode($result2true);

            echo 
    $result2['result'][0]['statusmsg'] . "<br />";

        }
    }

    function 
    doCpanelQuery($query) {
        global 
    $whm_username$whm_password;
        
    $curl curl_init();
        
    # Create Curl Object
        
    curl_setopt($curlCURLOPT_SSL_VERIFYPEER,0);
        
    # Allow self-signed certs
        
    curl_setopt($curlCURLOPT_SSL_VERIFYHOST,0);
        
    # Allow certs that do not match the hostname
        
    curl_setopt($curlCURLOPT_HEADER,0);
        
    # Do not include header in output
        
    curl_setopt($curlCURLOPT_RETURNTRANSFER,1);
        
    # Return contents of transfer on curl_exec
        
    $header[0] = "Authorization: Basic " base64_encode($whm_username.":".$whm_password) . "\n\r";
        
    curl_setopt($curlCURLOPT_HTTPHEADER$header);
        
    # set the username and password
        
    curl_setopt($curlCURLOPT_URL$query);
        
    # execute the query
        
    $result curl_exec($curl);
        if (
    $result == false) { die("curl_exec threw error \"" curl_error($curl) . "\" for $query");}
        
    curl_close($curl);

        return 
    $result;
    }


    ?>
     
  9. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    And here is the PHP code for updating all WHM packages on the server that are NOT "x3" or "paper_lantern":

    PHP:
    <?php

    // Changes cpanel theme for all WHM packages on the server.

    $whm_hostname "your.servername.com";
    $whm_username "root";
    $whm_password "password";

    // Get list of all accounts on the server.
    $result doCpanelQuery("https://".$whm_hostname.":2087/json-api/listpkgs");
    $result json_decode($resulttrue);

    // Check if current theme is anything besides x3 or paper_lantern.
    foreach($result['package'] as $key=>$value) {

        if ( (
    $value['CPMOD'] != "x3") && ($value['theme'] != "paper_lantern") ) {

            echo 
    $value['name'] ." : " $value['CPMOD'] . " : ";

            
    // Change theme to x3.
            
    $result2 doCpanelQuery("https://".$whm_hostname.":2087/json-api/editpkg?name=".$value['name']."&cpmod=x3");
            
    $result2 json_decode($result2true);

            echo 
    $result2['result'][0]['statusmsg'] . "<br />";

        }
    }

    function 
    doCpanelQuery($query) {
        global 
    $whm_username$whm_password;
        
    $curl curl_init();
        
    # Create Curl Object
        
    curl_setopt($curlCURLOPT_SSL_VERIFYPEER,0);
        
    # Allow self-signed certs
        
    curl_setopt($curlCURLOPT_SSL_VERIFYHOST,0);
        
    # Allow certs that do not match the hostname
        
    curl_setopt($curlCURLOPT_HEADER,0);
        
    # Do not include header in output
        
    curl_setopt($curlCURLOPT_RETURNTRANSFER,1);
        
    # Return contents of transfer on curl_exec
        
    $header[0] = "Authorization: Basic " base64_encode($whm_username.":".$whm_password) . "\n\r";
        
    curl_setopt($curlCURLOPT_HTTPHEADER$header);
        
    # set the username and password
        
    curl_setopt($curlCURLOPT_URL$query);
        
    # execute the query
        
    $result curl_exec($curl);
        if (
    $result == false) { die("curl_exec threw error \"" curl_error($curl) . "\" for $query");}
        
    curl_close($curl);

        return 
    $result;
    }


    ?>
    Please note -- using the API method to update all WHM packages on your server will trigger an "update" to all accounts that are using that package. So if you have customized a cpanel account, but kept is assigned to a package that is updated, the cpanel account will be "synced" to the package your customization will be lost.
     
Loading...

Share This Page