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.

Mass Change cPanel Package Names?

Discussion in 'General Discussion' started by davidelliott, Jun 28, 2010.

  1. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    Hello,

    Is there way I can upgrade all accounts on my server that are using package name 'xxxx' to a different package name e.g 'xaxa'?
    It would save me a lot of time having to upgrade them manually.

    Thanks A Lot!!
     
  2. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Modify/Upgrade Multiple Accounts

    In the WebHost Manager, you can use Main >> Multi Account Functions >> Modify/Upgrade Multiple Accounts to change settings, including the package, on multiple accounts at once.
     
  3. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    That is still time consuming, I was thinking like there is a command in SSH that you type in and gives a list of domains using the package and you can update the package for all the domains listed on the package to a new one. If there isn't, this is maybe something worth thinking about, it would save a lot of time for people.
     
  4. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Edit the /var/cpanel/users files

    The package name is stored in each account's file in /var/cpanel/users/. You can use the Linux replace command to search for each instance of a string in a file and replace it. For example:

    Code:
    # replace "PLAN=default" "PLAN=mynewplan" -- /var/cpanel/users/foo
    will replace every instance of "PLAN=default" with "PLAN=mynewplan" in /var/cpanel/users/foo. "PLAN" in this case is the same as "package" in the WHM/cPanel interface.

    You can automate this by using wildcards, though I urge extreme caution when using a wildcard and recommend backing up the /var/cpanel/users directory first.

    Code:
    # cp -Rp /var/cpanel/users /root/users-pre-replace.bak
    # replace "PLAN=xxxx" "PLAN=xaxa" -- /var/cpanel/users/*
    # /scripts/updateuserdomains
    /scripts/updateuserdomains should be run anytime any file is edited in the /var/cpanel/users directory.

    I recommend reviewing the documentation for the replace command before using it. You can do this by typing "man replace" at the shell command prompt, or it is available online from several sources, such as this one:

    replace(1): string-replacement utility - Linux man page
     
  5. cPanelJared

    cPanelJared Technical Analyst
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    That is correct

    Yes, that is correct. I do recommend backing up the /var/cpanel/users directory first, as I described, just in case of a typographical error while entering the shell commands.
     
  6. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    So just to confirm

    replace "PLAN=xxxx" "PLAN=xaxa" -- /var/cpanel/users/foo

    Would replace all the users in the users direct running plan 'xxxx' to 'xaxa'?
     
  7. davidelliott

    davidelliott Well-Known Member

    Joined:
    Jun 27, 2010
    Messages:
    67
    Likes Received:
    0
    Trophy Points:
    6
    Thanks!

    That helped so much!
     
  8. mehdi@canaca.co

    mehdi@canaca.co Registered
    PartnerNOC

    Joined:
    Apr 25, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Thanks,

    But if the destination package "xaxa" has different parameters (like MAXFTP, MAXSQL, etc) than source package "xxxx", it does not change them and just update the PLAN line in /var/cpanel/users/foo even after running /scripts/updateuserdomains.

    Any clue?
     
  9. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Automation via XML-API and JSON-API

    Using WebHost Manager and APIs to apply packages should properly update all applicable data. If more automation is desired I would consider creating a custom solution that utilizes the XML and JSON API functions via WHM.

    Related API documentation (with examples):
     
Loading...

Share This Page