# Following path are the one
#-------------------------------------------------------
use vars qw/
+$AWSTATS_PATH
$AWSTATS_ICON_PATH
$AWSTATS_CSS_PATH
$AWSTATS_CLASSES_PATH
$AWSTATS_CGI_PATH
-$AWSTATS_TOOLS_PATH
$AWSTATS_MODEL_CONFIG
$AWSTATS_DIRDATA_PATH
/;
+$AWSTATS_PATH='';
$AWSTATS_ICON_PATH='/usr/local/awstats/wwwroot/icon';
$AWSTATS_CSS_PATH='/usr/local/awstats/wwwroot/css';
$AWSTATS_CLASSES_PATH='/usr/local/awstats/wwwroot/classes';
$AWSTATS_CGI_PATH='/usr/local/awstats/wwwroot/cgi-bin';
-$AWSTATS_TOOLS_PATH='/usr/local/awstats/wwwroot/tools'; # Used only when configure ran on linux
$AWSTATS_MODEL_CONFIG='/etc/awstats/awstats.model.conf'; # Used only when configure ran on linux
$AWSTATS_DIRDATA_PATH='/var/lib/awstats'; # Used only when configure ran on linux
#-------------------------------------------------------
# MAIN
#-------------------------------------------------------
-($DIR=$0) =~ s/([^\/\\]*)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
+($DIR=$0) =~ s/([^\/\\]+)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
+$DIR||='.'; $DIR =~ s/([^\/\\])[\\\/]+$/$1/;
my $QueryString=""; for (0..@ARGV-1) { $QueryString .= "$ARGV[$_] "; }
if ($QueryString =~ /debug=/i) { $Debug=$QueryString; $Debug =~ s/.*debug=//; $Debug =~ s/&.*//; $Debug =~ s/ .*//; }
my $helpfound=0;
my $OS='';
my $CR='';
-my $AWSTATS_PATH=''; # Used only when configure ran on windows
for (0..@ARGV-1) {
if ($ARGV[$_] =~ /^-*h/i) { $helpfound=1; last; }
if ($ARGV[$_] =~ /^-*awstatspath=([^\s\"]+)/i) { $AWSTATS_PATH=$1; last; }
}
+# If AWSTATS_PATH was not forced on command line
if (! $AWSTATS_PATH) {
- $AWSTATS_PATH=$DIR||'..';
+ $AWSTATS_PATH=($DIR eq '.'?'..':$DIR);
$AWSTATS_PATH=~s/tools[\\\/]?$//;
$AWSTATS_PATH=~s/[\\\/]$//;
}
print "according to your needs.\n";
print "Read the AWStats documentation (docs/index.html).\n";
-# Detect web server path
-# ----------------------
+# Detect OS type
+# --------------
if (-d "/etc" && -d "/home") { $OS='linux'; $CR=''; }
else { $OS='windows'; $CR="\r"; }
#print "Running OS detected: $OS (Perl $^[)\n";
print "\n-----> Running OS detected: $OS\n";
-if ($OS eq 'windows') {
+if ($OS eq 'linux') {
+ $AWSTATS_PATH=`pwd`; $AWSTATS_PATH =~ s/[\r\n]//;
+ $AWSTATS_PATH=~s/tools[\\\/]?$//;
+ $AWSTATS_PATH=~s/[\\\/]$//;
+ if ($AWSTATS_PATH ne '/usr/local/awstats') {
+ print "Warning: AWStats standard directory on Linux OS is '/usr/local/awstats'.\n";
+ print "If you want to use standard directory, you should first move all content\n";
+ print "of AWStats distribution from current directory:\n";
+ print "$AWSTATS_PATH\n";
+ print "to standard directory:\n";
+ print "/usr/local/awstats\n";
+ print "And then, run configure.pl from this location.\n";
+ print "Do you want to continue setup from this NON standard directory [yN] ? ";
+ my $bidon='';
+ while ($bidon !~ /^[yN]/i) { $bidon=<STDIN>; }
+ if ($bidon !~ /^y/i) {
+ print "configure.pl aborted.\n";
+ exit 1;
+ }
+ $AWSTATS_ICON_PATH="$AWSTATS_PATH/wwwroot/icon";
+ $AWSTATS_CSS_PATH="$AWSTATS_PATH/wwwroot/css";
+ $AWSTATS_CLASSES_PATH="$AWSTATS_PATH/wwwroot/classes";
+ $AWSTATS_CGI_PATH="$AWSTATS_PATH/wwwroot/cgi-bin";
+ }
+}
+elsif ($OS eq 'windows') {
# We do not use default values for awstats directives
# but thoose defined from AWSTATS_PATH
$AWSTATS_ICON_PATH="$AWSTATS_PATH/wwwroot/icon";
$AWSTATS_CGI_PATH="$AWSTATS_PATH/wwwroot/cgi-bin";
}
+
+
# Detect web server path
# ----------------------
print "\n-----> Check for web server install\n";
if ($_ =~ /^CustomLog\s(.*)\scommon$/i) {
print "Warning: You Apache config file contains directives to write 'common' log files\n";
print "This means that some features can't work (os, browsers and keywords detection).\n";
- print "Do you want me to setup Apache to write 'combined' log files [y/N] ?\n";
+ print "Do you want me to setup Apache to write 'combined' log files [y/N] ? ";
my $bidon='';
while ($bidon !~ /^[yN]/i) { $bidon=<STDIN>; }
if ($bidon =~ /^y/i) {
}
}
if ($_ =~ /^CustomLog\s(.*)\scombined$/i) { $LogFormat{$key}=1; }
- if ($_ =~ /Alias \/awstatsclasses/) { $awstatsclassesfound=1; }
- if ($_ =~ /Alias \/awstatscss/) { $awstatscssfound=1; }
- if ($_ =~ /Alias \/awstatsicons/) { $awstatsiconsfound=1; }
- if ($_ =~ /ScriptAlias \/awstats\//) { $awstatscgifound=1; }
+ if ($_ =~ /Alias \/awstatsclasses/) { $awstatsclassesfound=1; }
+ if ($_ =~ /Alias \/awstatscss/) { $awstatscssfound=1; }
+ if ($_ =~ /Alias \/awstatsicons/) { $awstatsiconsfound=1; }
+ if ($_ =~ /ScriptAlias \/awstats\//) { $awstatscgifound=1; }
}
close CONF;
# Define model config file path
# -----------------------------
my $modelfile='';
-if ($OS eq 'linux') { $modelfile="$AWSTATS_MODEL_CONFIG"; }
+if ($OS eq 'linux') {
+ if (-f "$AWSTATS_PATH/wwwroot/cgi-bin/awstats.model.conf") {
+ $modelfile="$AWSTATS_PATH/wwwroot/cgi-bin/awstats.model.conf";
+ }
+ else {
+ $modelfile="$AWSTATS_MODEL_CONFIG";
+ }
+}
elsif ($OS eq 'windows') { $modelfile="$AWSTATS_PATH\\wwwroot\\cgi-bin\\awstats.model.conf"; }
else { $modelfile="$AWSTATS_PATH\\wwwroot\\cgi-bin\\awstats.model.conf"; }
# Update model config file
# ------------------------
-print "\n-----> Update model config file\n";
+print "\n-----> Update model config file '$modelfile'\n";
%ConfToChange=();
if ($OS eq 'linux') { $ConfToChange{'DirData'}="$AWSTATS_DIRDATA_PATH"; }
elsif ($OS eq 'windows') { $ConfToChange{'DirData'}='.'; }
$ConfToChange{'DirIcons'}='/awstatsicons';
}
update_awstats_config("$modelfile");
+print " File awstats.model.conf updated.\n";
# Ask if we need to create a config file
#---------------------------------------
# -------------------------------
print "\n-----> Add update process inside a scheduler\n";
if ($OS eq 'linux') {
- print "Sorry, configure does not support automatic add to cron yet.\n";
+ print "Sorry, configure.pl does not support automatic add to cron yet.\n";
print "You can do it manually by adding the following command to your cron:\n";
print "$AWSTATS_CGI_PATH/awstats -update -config=".($site?$site:"myvirtualserver")."\n";
print "Or if you have several config files and prefer having only one command:\n";
- print "$AWSTATS_TOOLS_PATH/awstats_updateall.pl now\n";
+ print "$AWSTATS_PATH/tools/awstats_updateall.pl now\n";
print "Press ENTER to continue... ";
$bidon=<STDIN>;
}