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 remove Packages for non existing users ?

Discussion in 'General Discussion' started by vivekvsist, Feb 3, 2009.

  1. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    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 ?
     
  2. JawadArshad

    JawadArshad Well-Known Member
    PartnerNOC

    Joined:
    Apr 8, 2008
    Messages:
    447
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    PK
    cPanel Access Level:
    DataCenter Provider
    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.
     
  3. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  4. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Oh! I just figured out my mistake.

    Those errors displayed because those are not resellers!
     
  5. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  6. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    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
     
  7. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  8. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    Fantastic ...that is one of the wonders.....I guess this could also be incorporated under whm gui....why is not so ?
     
  9. LinuxTechie

    LinuxTechie Well-Known Member

    Joined:
    Jan 22, 2011
    Messages:
    502
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hello Tristan,

    That was a new info. Thanks for that :)
     
  10. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    cPanelTristan :

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

    After the command execution i got this first message :-

    AND in the end it says :-

    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
     
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  12. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    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...
     
  13. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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!
     
  14. JawadArshad

    JawadArshad Well-Known Member
    PartnerNOC

    Joined:
    Apr 8, 2008
    Messages:
    447
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    PK
    cPanel Access Level:
    DataCenter Provider
    How are you counting packages if I may ask.

     
  15. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    This is how i do it :-

     
  16. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    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
     
  17. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    my apologies...just don't bother answering this :(
     
  18. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    Tristan :

    I surely need assistance here :(,

    before i ran the "auto repair cleanup dead packages" i counted the number of packages on the server
    "
    Then i issued the command
    I got this answer at the end :-

    But again when i counted the number of packages i got the same answer :-

    What is missing here ? What have i omitted ?
     
  19. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    I already answered this question previously:

     
  20. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    oke doke :)
     
Loading...

Share This Page