davidelliott

Well-Known Member
Jun 27, 2010
67
0
56
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!!
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
27
143
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.
 

davidelliott

Well-Known Member
Jun 27, 2010
67
0
56
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.
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
27
143
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
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
27
143
Houston, TX
cPanel Access Level
Root Administrator
That is correct

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'?
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.
 

davidelliott

Well-Known Member
Jun 27, 2010
67
0
56
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'?
 

[email protected]

Registered
PartnerNOC
Apr 25, 2007
4
0
151
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?
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,544
14
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Automation via XML-API and JSON-API

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?
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):