script to place webalizer stats outside cpanel

Here is a script I made for my cpanel servers, to place webalizer stats outside cpanel. Users will be able to goto http://www.mydomain.com/stats and see their webstats.

NOTE: This script is for the server administrator, if you have a cpanel account you can do the procces manually (a google search will return lots of howtos).

#!/bin/bash

users=`ls -1A /var/cpanel/users/`
count=1

for x in `echo -n "$users"`;do

if [ ! -d "/home/"$x"/public_html/stats" ]; then

ln -s /home/"$x"/tmp/webalizer /home/"$x"/public_html/stats
chown -R "$x":"$x" /home/"$x"/public_html/stats
chmod 755 /home/"$x"/tmp
chmod 755 /home/"$x"/tmp/webalizer
count=$[$count+1]
echo "stats for user "$x" have been setup"
echo;

else
echo "stats for user "$x" were ready"
echo;

fi

done

Once you execute the script all cpanel accounts will have their webstats available at http://www.mydomain.com/stats. For new accounts you can create /scripts/legacypostwwwacct.

vi /scripts/legacypostwwwacct

and insert

#!/bin/bash

mkdir /home/"$2"/tmp/webalizer
chown -R "$2":"$2" /home/"$2"/tmp/webalizer
ln -s /home/"$2"/tmp/webalizer /home/"$2"/public_html/stats
chown -R "$2":"$2" /home/"$2"/public_html/stats
chmod 755 /home/"$2"/tmp
chmod 755 /home/"$2"/tmp/webalizer

save and make it executable

chmod 755 /scripts/legacypostwwwacct

If you want to have a username & password to access stats, you can go to cpanel “Password Protect Directories” and create them or modify the script and create them¬†automatically.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>