WHM / cPanel Cleanup Script

I’m working on a script that cleans up the users home directory. It currently:

  • archives and removes all error_log files it can find
  • removes cpmove.psql directories that are sometimes left in place after a user is moved to another server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#####################################
# How2 Solutions - http://how2.be
# cPanel Cleanup Script
# version 1.0
#####################################

for user in `ls -A /var/cpanel/users`
do
    echo $user

    #####################################
    # archive error_log
    #####################################
    rm -f /home/$user/error_log.tar
    rm -f /home/$user/error_log.tar.gz

    FILE_LIST=`find /home/$user/public_html -type f -name "error_log"`
    for error_log_file in $FILE_LIST
    do
        echo $error_log_file
        tar -rf /home/$user/error_log.tar $error_log_file
        rm -f $error_log_file
    done

    gzip -f /home/$user/error_log.tar
    chown root:$user /home/$user/error_log.tar.gz

    #####################################
    # remove cpmove.psql
    #####################################
    rm -rf /home/$user/cpmove.psql*
done

I’m planning to custimize this a bit more so error_log files are archived once a month and offer users the ability to disable archiving. More cleanup actions will be added as well. If you think of something usefull to add to this script let me know!

Wake On Lan with the Draytek Vigor 2920

I recently switched out my main router for the Dual WAN Draytek Vigor 2920. While setting everything up, I had some trouble getting Wake On Lan to work as I would like.

Sure, the router offers the ability to logon to the Administration Console remotely or trough telnet and wake up a machine from there. But I am spoiled these days and used to waking my computer wit the press of a button. I actually use Wake On Lan for Android to wake my machine while walking up the stairs or from work. I use my Dynamic DNS as a host name.

This is the configuration I finally ended up with. It works both from the internet and the local network.

1. Under “Lan” > “Bind IP to MAC” define a new entry for IP “192.168.0.254” with MAC FF:FF:FF:FF:FF

2. Under “NAT” > “Open Ports” you will need to set the following. I added an entry for both my WAN interfaces.

Not the obvoius choice but at least it works :)