generate awstats scripts

This script assumes the following
1) you ahve install the awstat package in the folloing /usr/local/src/*
2) this script will add the cron job to run the perl- update -wasstat script every day  located at "/etc/cron.daily/awstatsupdate
3 you have a folder called /websites/domain.com/webstats and /websites/domain.com/web/awstats 
 
#!/bin/bash


echo -e " enter the domain to generate webstats "
read d

domain_user=` echo $d |sed s/\.com/com2631/g `
tmp_name=` echo $d |sed s/\.com//g `


if [ -d /websites/"$d" -a -d /websites/"$d"/webstats   ]; then
echo -e "awstats exist for this $d exist "
else
echo -e "generating awstats for $d "
mkdir /websites/"$d"/webstats

chown "$domain_user":"$domain_user"  /websites/"$d"/webstats

cp -R /usr/local/src/awstats-6.7/* /websites/"$d"/webstats

echo -e "copying source dir to the webstats dir"
sleep 2

cp /websites/"$d"/webstats/wwwroot/cgi-bin/awstats.model.conf  /websites/"$d"/webstats/wwwroot/cgi-bin/awstats."$tmp_name".sys.qualiproj.qualispace.com.conf
sleep 2  

  if [ -d /websites/"$d"/web/awstats ];then
echo -e "/web/awstats  exist "
exist 1
  else
echo -e "creating awstats"
sleep 2
mkdir /websites/"$d"/web/awstats
    fi

chown "$domain_user":"$domain_user"  /websites/$d/web/awstats
cp -R /websites/"$d"/webstats/wwwroot/icon    /websites/"$d"/web/awstats/

config_file="/websites/$d/webstats/wwwroot/cgi-bin/awstats.$tmp_name.sys.qualiproj.qualispace.com.conf"

cat >> $config_file << _eof_
LogFile="/websites/"$d"/logs/$tmp_name.sys.qualiproj.access_log"
LogType=W
LogFormat=1
LogSeparator=" "
SiteDomain="$tmp_name.sys.qualiproj.qualispace.com"
HostAliases="www.$tmp_name.sys.qualiproj.qualispace.com agnello.sys.qualiproj.qualispace.com localhost 127.0.0.1 "
DNSLookup=1
DirData="/websites/$d/webstats"
DirCgi="/cgi-bin"
DirIcons="/web/awstats/icon"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=2
EnableLockForUpdate=0
DNSStaticCacheFile="dnscache.txt"
DNSLastUpdateCacheFile="dnscachelastupdate.txt"
SkipDNSLookupFor=""
AllowAccessFromWebToAuthenticatedUsersOnly=0
AllowAccessFromWebToFollowingAuthenticatedUsers=""
AllowAccessFromWebToFollowingIPAddresses=""
CreateDirDataIfNotExists=0
BuildHistoryFormat=text
BuildReportFormat=html
SaveDatabaseFilesWithPermissionsForEveryone=0
PurgeLogFile=0
KeepBackupOfHistoricFiles=0
DefaultFile="index.html"
SkipHosts=""
SkipUserAgents=""
SkipFiles=""
SkipReferrersBlackList=""
OnlyHosts=""
OnlyUserAgents=""
OnlyFiles=""
NotPageList="css js class gif jpg jpeg png bmp ico swf"
ValidHTTPCodes="200 304"
ValidSMTPCodes="1 250"
AuthenticatedUsersNotCaseSensitive=0
URLNotCaseSensitive=0
URLWithAnchor=0
URLQuerySeparators="?;"
URLWithQuery=0
URLWithQueryWithOnlyFollowingParameters=""
URLWithQueryWithoutFollowingParameters=""
URLReferrerWithQuery=0
WarningMessages=1
ErrorMessages=""
DebugMessages=0
NbOfLinesForCorruptedLog=50
WrapperScript=""
DecodeUA=0
LevelForBrowsersDetection=2
LevelForOSDetection=2
LevelForRefererAnalyze=2
LevelForRobotsDetection=2
LevelForSearchEnginesDetection=2
LevelForKeywordsDetection=2
LevelForFileTypesDetection=2
LevelForWormsDetection=0
_eof_

perl /websites/"$d"/webstats/tools/awstats_buildstaticpages.pl -awstatsprog=/websites/"$d"/webstats/wwwroot/cgi-bin/awstats.pl  -update -config="$tmp_name".sys.qualiproj.qualispace.com -dir=/websites/"$d"/web/awstats/

mv /websites/"$d"/web/awstats/awstats.$tmp_name.sys.qualiproj.qualispace.com.html /websites/"$d"/web/awstats/index.html

cron_awstatsupdate="/etc/cron.daily/awstatsupdate"

cat >> $cron_awstatsupdate <<  _eof_

###################cron_upadte for domain $d#######################
perl /websites/"$d"/webstats/tools/awstats_buildstaticpages.pl -awstatsprog=/websites/"$d"/webstats/wwwroot/cgi-bin/awstats.pl  -update -config="$tmp_name".sys.qualiproj.qualispace.com -dir=/websites/"$d"/web/awstats/

###############

No comments:

Other Articles

Enter your email address: