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.

Migrating from enXim and importing awstats data

Discussion in 'General Discussion' started by DomineauX, Mar 28, 2010.

  1. DomineauX

    DomineauX Well-Known Member
    PartnerNOC

    Joined:
    Apr 12, 2003
    Messages:
    414
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    For those who migrate from enXim and are using the AwStats installation procedure that has been around for a long time prior to AwStats being built in to the product, the following script will handle importing of the AwStats historical data stored in /home/username/cgi-bin/awstats/data:


    Code:
    #!/bin/bash
    for USERNAME in `/bin/ls -A /var/cpanel/users/`
    do
        HOMEDIR=`grep "^$USERNAME:" /etc/passwd | awk -F: '{print $6}'`
        DOMAIN=`/bin/ls -A $HOMEDIR/tmp/awstats/ | grep -E "awstats\..*\.conf" | sed 's/awstats\.\(.*\)\.conf/\1/'`
        if [ -d $HOMEDIR/cgi-bin/awstats/data ]
        then
            for OLDFILE in `/bin/ls -A $HOMEDIR/cgi-bin/awstats/data`
            do
                NEWFILE=`echo $OLDFILE | sed "s/txt$/$DOMAIN\.txt/"`
                echo "mv $HOMEDIR/cgi-bin/awstats/data/$OLDFILE $HOMEDIR/tmp/awstats/$NEWFILE"
            done
        fi
    done
    Save this as something such as "awstats.sh" and then execute with "sh awstats.sh" and it will echo the "mv" commands for you to review.

    If they look good, you can execute them directly from the awstats.sh output with "sh awstats.sh | sh"
     
Loading...

Share This Page