#============================================================================# # vHost - one-step solution for all virtual hosting needs # # V35awstats - awstats virtualization module # # # # Copyright(c) Chaogic Systems, LLC. http://chaogic.com # # Author: Jake Fan # # # # This is Free Software; permission to use, copy, modify, and distribute # # this software and its documentation for any purpose - with or without fee # # - is hereby granted, provided that the above copyright information and # # this permission notice appear in all copies and documentations. This # # software is provided "as is" without express or implied warranty. For # # more details, see GNU General Public License as published by the Free # # Software Foundation. # # # #============================================================================# $X eq "configuration" && do { ################################################ ### EDITABLE CONFIGURATIONS ################################################## ### webstats directory name on virtual hosts. virtual host webstats will be # accessed at "http://virtual.host.name/$wsDir". # $wsDir = "webstats"; $wsDir = "webstats"; ### awstats cgi directory on the main host which contains "awstats.pl". make # sure it's accessible by the httpd user. # $asCgiRoot = "/usr/share/awstats/wwwroot/cgi-bin"; $asCgiRoot = "/usr/share/awstats/wwwroot/cgi-bin"; ### awstats icon directory on the main host. make sure it's accessible by the # httpd user. # $asIconRoot = "/usr/share/awstats/wwwroot/icon"; $asIconRoot = "/usr/share/awstats/wwwroot/icon"; ### awstats configuration file on the main host. # $awstatsCf = "$asCgiRoot/awstats.model.conf"; $awstatsCf = "$asCgiRoot/awstats.model.conf"; ### DO NOT TOUCH ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!! ### SanityChecking ########################################################### $ERR = 1, Error "$MOD: \$wsDir = '$wsDir'" if $wsDir eq $guiDir || !CheckN $wsDir; $ERR = 1, Error "$MOD: \$asCgiRoot = '$asCgiRoot'" if !-x "$asCgiRoot/awstats.pl"; $ERR = 1, Error "$MOD: \$asIconRoot = '$asIconRoot'" if !-d $asIconRoot; $ERR = 1, Error "$MOD: \$awstatsCf = '$awstatsCf'" if !-f $awstatsCf; $awstats = "$asCgiRoot/awstats.pl"; $asIconDir = (split /\//, $asIconRoot)[-1]; $wsRoot = "$VHOME/$H/var/$webDir/$urlDir/$wsDir"; $EVAL{'$wsRoot;'} = 4; $EVAL{'$awstats;'} = 4; }; $X eq "initialization" && do { ############################################### if ($ONCFG) { `chown -Rh 0:$GHID $asCgiRoot $NERR` if !-o $asCgiRoot; `chown -Rh 0:$GHID $asIconRoot $NERR` if !-o $asIconRoot; `chmod 0755 $asCgiRoot/../.. $NERR` if -d "$asCgiRoot/../../wwwroot" && ((stat "$asCgiRoot/../..")[2] & 07777) != 0755; my ($i, $j); Flock $awstats, "+<", 0 if !grep /^\s*$FOOT/, Cat $awstats; BackupCf $awstats; /^[^#]*\@PossibleConfigDir\s*=/ && ($j = $i), $i++ for @FILE; $FILE[$j] .= "\n$FOOT\n".<<'#'."\n"; @PossibleConfigDir = (".", @PossibleConfigDir); # print FILE @FILE if $j; Flock 0; } if ($ARGV[0] eq "rotatelog") { my $d; $d = "$HOME{$PROF{$_}}/$_/var/$webDir/$urlDir/$wsDir", -d $d || next, `(cd $d && $awstats -config=$_ -update) $NERR` for $H || grep CheckQ ($QHOST{$_}), keys %PROF; } }; $X eq "addhost" && do { ###################################################### `mkdir $wsRoot $NERR`; `cp -p $awstatsCf $wsRoot/awstats.$H.conf $NERR`; `ln -f $wsRoot/awstats.$H.conf $VHOME/$H/etc/awstats.conf $NERR`; `rm -r $wsRoot/$asIconDir $NERR`; `ln -s $asIconRoot $wsRoot/$asIconDir $NERR`; Flock "$wsRoot/awstats.$H.conf", "+<", 0; s/^\s*(LogFile\s*=).*/$1"$VHOME\/$H\/var\/log\/access_log"\n/s, s/^\s*(DirData\s*=).*/$1"$wsRoot"\n/s, s/^\s*(DirIcons\s*=).*/$1"\/$wsDir\/$asIconDir"\n/s, s/^\s*(SiteDomain\s*=).*/$1"$H"\n/s, s/^\s*(UseFramesWhenCGI\s*=).*/${1}0\n/s for @FILE; print FILE @FILE; Flock 0; Flock "$wsRoot/index.php", ">", 0; print FILE "\n"; Flock 0; }; $X eq "finalization" && do { ################################################# if ($ARGV[0] eq "addhost" || $ARGV[0] eq "adduser" && $U eq $webDir || $ARGV[0] eq "rotatelog") { for ($H || grep CheckQ ($QHOST{$_}), keys %PROF) { # my $wuid = getpwnam $webUser; my $wsroot = "$HOME{$PROF{$_}}/$_/var/$webDir/$urlDir/$wsDir"; `chown -Rh $O[2]:$GHID $wsroot $NERR`; -l && `chown -h 0:$GHID $_ $NERR` for <$wsroot/*>; -f && `chmod 0664 $_ $NERR` for <$wsroot/*>; `chmod 0644 $wsroot/index.* $NERR`; `chmod 0644 $wsroot/*.conf $NERR`; `chmod 0775 $wsroot $NERR`; }} }; 1;