How to remove Packages for non existing users ?

vivekvsist

Active Member
May 29, 2007
26
0
151
Hello

I have lot of reseller accountss and some of them are removed by me.
But the problem is that their packages are still there.

How can I delete the packages of those deleted resellers ?

Any custom script , can you suggest any ?
 

JawadArshad

Well-Known Member
PartnerNOC
Apr 8, 2008
459
7
68
PK
cPanel Access Level
DataCenter Provider
Hello

I have lot of reseller accountss and some of them are removed by me.
But the problem is that their packages are still there.

How can I delete the packages of those deleted resellers ?

Any custom script , can you suggest any ?
Packages are located in /var/cpanel/packages folder. Each package name starts with the reseller's username. You can write a script to check if that user still exists, and if does not, delete the package files.
 

vivekvsist

Active Member
May 29, 2007
26
0
151
Packages are located in /var/cpanel/packages folder. Each package name starts with the reseller's username. You can write a script to check if that user still exists, and if does not, delete the package files.
Actually I am not a good shell script writer. Thats why I asked here :)

I already tried a little bit. My idea was,


mkdir /var/cpanel/a
cd /var/cpanel/packages
mv * ../a

This will clean up the packages folder

Then I wrote a script

Code:
#!/bin/bash
for i in $(ls /var/cpanel/users)
do
mv /var/cpanel/a/$i* /var/cpanel/packages/
echo $i;
done

But the mv command is giving error.

mv: cannot stat `/var/cpanel/a/arbnor*': No such file or directory
 

vivekvsist

Active Member
May 29, 2007
26
0
151
Oh! I just figured out my mistake.

Those errors displayed because those are not resellers!
 

vivekvsist

Active Member
May 29, 2007
26
0
151
Just cleared 1471 packages :)

In case if anyone want this, just use this codes created by me


create a file "clear.sh" and paste this codes

Code:
nano clear.sh
Code:
#!/bin/bash
clear
echo "Total Number of packags: ";
find /var/cpanel/packages | wc -l;
echo "Press ENTER to remove the unwanted packages";
read m
mkdir /var/cpanel/a
cd /var/cpanel/packages
mv * ../a
for i in $(ls /var/cpanel/users)
do
mv /var/cpanel/a/$i* /var/cpanel/packages/
echo $i;
done
clear
find /var/cpanel/a | wc -l; echo "Packages have been Cleared";
rm -rf /var/cpanel/a

Save it

Then run

Code:
chmod 755 clear.sh
./clear
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
My apologies to bump up this old thread, What i need to know is, does this script ONLY delete the packages that are NOT being used by any reseller or individual account ????

Would any one clarify,. OR does latest Cpanel remove the packages once they account is deleted ?

Thank
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

There is a better way to accomplish this task. Packages that aren't used any longer by resellers are not normally removed automatically. You can simply run the following command to clear any unused packages on the system:

Code:
/scripts/autorepair cleanup_dead_package_limits
This would only clean up the packages no longer being used.

Thanks.
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Fantastic ...that is one of the wonders.....I guess this could also be incorporated under whm gui....why is not so ?
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
cPanelTristan :

I ran this command on my server, and the server had 1286 packages...

After the command execution i got this first message :-

[email protected] [~]# /scripts/autorepair cleanup_dead_package_limits
Requesting script ... Done Auto Repair is running...Removed the following (1051) unused package limits defi
AND in the end it says :-

Original package limits definition saved to:
/var/cpanel/package-limits.yaml.pre_cleanup.1297229024
This file may be removed at your discretion.
...Auto Repair is done.
But when i count the packages once again..I still get the same number of packages 1286.....What does this mean ...?

Have the packages been deleted or not, or do i have to go ahead and manually delete this file :-/var/cpanel/package-limits.yaml.pre_cleanup.1297229024

Please reply
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Can you do a diff on /var/cpanel/package-limits.yaml.pre_cleanup.1297229024 and /var/cpanel/package-limits.yaml files?

Code:
diff /var/cpanel/package-limits.yaml /var/cpanel/package-limits.yaml.pre_cleanup.1297229024
I don't see why you'd need to remove the saved file.
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
cPanelTristan :

I dot not want to remove any saved and running packages....

All i need to do is remove the packages that are no more being used by any user or reseller...
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello furquan,

I didn't state about removing saved and running packages in my reply. I noted that I don't see why you'd need to remove the saved file, which was the backup of the dead packages prior to the script removing those packages.

Please open a ticket if the dead packages weren't removed and you weren't able to run the diff requested in my last reply. You can open a ticket in WHM > Support Center > Contact cPanel or using the link I have in my signature.

Thanks!
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Bumping this thread again, and this time i need to know, how can we delete unused packages created either by me (root) or by any reseller ?

Thank you
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
my apologies...just don't bother answering this :(
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Tristan :

I surely need assistance here :(,

before i ran the "auto repair cleanup dead packages" i counted the number of packages on the server
"
[email protected] [~]# ls /var/cpanel/packages/ | wc -l
1296"
Then i issued the command
/scripts/autorepair cleanup_dead_package_limits
I got this answer at the end :-

Original package limits definition saved to:
/var/cpanel/package-limits.yaml.pre_cleanup.1304072088
This file may be removed at your discretion.
...Auto Repair is done.
But again when i counted the number of packages i got the same answer :-

[email protected] [~]# ls /var/cpanel/packages/ | wc -l
1296
What is missing here ? What have i omitted ?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
I already answered this question previously:

Please open a ticket if the dead packages weren't removed and you weren't able to run the diff requested in my last reply. You can open a ticket in WHM > Support Center > Contact cPanel or using the link I have in my signature.
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
oke doke :)