$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 for linux only
-$AWSTATS_MODEL_CONFIG='/etc/awstats/awstats.model.conf'; # Used for linux only
-$AWSTATS_DIRDATA_PATH='/var/lib/awstats'; # Used for linux only
+$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
my $helpfound=0;
my $OS='';
my $CR='';
-my $AWSTATS_PATH=''; # Used for windows only
+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 ($ARGV[$_] =~ /^-*awstatspath=([^\s\"]+)/i) { $AWSTATS_PATH=$1; last; }
}
if (! $AWSTATS_PATH) {
$AWSTATS_PATH=$DIR||'..';
#print "Running OS detected: $OS (Perl $^[)\n";
print "\n-----> Running OS detected: $OS\n";
+if ($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_CSS_PATH="$AWSTATS_PATH/wwwroot/css";
+ $AWSTATS_CLASSES_PATH="$AWSTATS_PATH/wwwroot/classes";
+ $AWSTATS_CGI_PATH="$AWSTATS_PATH/wwwroot/cgi-bin";
+}
+
# Detect web server path
# ----------------------
print "\n-----> Check for web server install\n";
print CONF "# Directives to allow use of AWStats as a CGI$CR\n";
print CONF "#$CR\n";
if (! $awstatsclassesfound) {
- print " Add 'Alias \/awstatsclasses \"$AWSTATS_CLASSES_PATH\/\"' to config file\n";
+ print " Add 'Alias \/awstatsclasses \"$AWSTATS_CLASSES_PATH\/\"'\n";
print CONF "Alias \/awstatsclasses \"$AWSTATS_CLASSES_PATH\/\"$CR\n";
}
if (! $awstatscssfound) {
- print " Add 'Alias \/awstatscss \"$AWSTATS_CSS_PATH\/\"' to config file\n";
+ print " Add 'Alias \/awstatscss \"$AWSTATS_CSS_PATH\/\"'\n";
print CONF "Alias \/awstatscss \"$AWSTATS_CSS_PATH\/\"$CR\n";
}
if (! $awstatsiconsfound) {
- print " Add 'Alias \/awstatsicons \"$AWSTATS_ICON_PATH\/\"' to config file\n";
+ print " Add 'Alias \/awstatsicons \"$AWSTATS_ICON_PATH\/\"'\n";
print CONF "Alias \/awstatsicons \"$AWSTATS_ICON_PATH\/\"$CR\n";
}
if (! $awstatscgifound) {
- print " Add 'ScriptAlias \/awstats\/ \"$AWSTATS_CGI_PATH\/\"' to config file\n";
+ print " Add 'ScriptAlias \/awstats\/ \"$AWSTATS_CGI_PATH\/\"'\n";
print CONF "ScriptAlias \/awstats\/ \"$AWSTATS_CGI_PATH\/\"$CR\n";
}
close CONF;
# -------------------------------
print "\n-----> Add update process inside a scheduler\n";
if ($OS eq 'linux') {
- print "Sorry, programming update is not supported yet.\n";
- print "You can do it manually by adding the following line to your crontab\n";
+ print "Sorry, configure 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";
}
if (! $ErrorMessages && ! $donotshowsetupinfo) {
if ($message =~ /Couldn.t open config file/i) {
- my $dir=$DIR; $dir =~ s/[\\\/]?wwwroot[\/\\]cgi-bin[\\\/]?//;
+ my $dir=$DIR;
+ if ($dir =~ /^\./) { $dir.='/../..'; }
+ else { $dir =~ s/[\\\/]?wwwroot[\/\\]cgi-bin[\\\/]?//; }
if ($ENV{'GATEWAY_INTERFACE'}) {
print "- ${tagbr}${tagbold}Did you use the correct URL ?${tagunbold}${tagbr}\n";
print "Example: http://localhost/awstats/awstats.pl?config=mysite${tagbr}\n";
#------------------------------------------------------------------------------
sub Read_Ref_Data {
# Check lib files in common possible directories :
- # Windows : "${DIR}lib" (lib in same dir than awstats.pl)
+ # Windows and standard package: "$DIR/lib" (lib in same dir than awstats.pl)
# Debian package : "/usr/share/awstats/lib"
- # Other possible directories : "./lib"
- my @PossibleLibDir=("${DIR}lib","/usr/share/awstats/lib","./lib");
+ my @PossibleLibDir=("$DIR/lib","/usr/share/awstats/lib");
my %FilePath=(); my %DirAddedInINC=();
my @FileListToLoad=();
while (my $file=shift) { push @FileListToLoad, "$file.pm"; }
#------------------------------------------------------------------------------
sub Read_Language_Data {
# Check lang files in common possible directories :
- # Windows : "${DIR}lang" (lang in same dir than awstats.pl)
+ # Windows and standard package: "$DIR/lang" (lang in same dir than awstats.pl)
# Debian package : "/usr/share/awstats/lang"
- # Other possible directories : "./lang"
- my @PossibleLangDir=("$DirLang","${DIR}lang","/usr/share/awstats/lang","./lang");
+ my @PossibleLangDir=("$DirLang","$DIR/lang","/usr/share/awstats/lang");
my $FileLang='';
foreach (@PossibleLangDir) {
#------------------------------------------------------------------------------
sub Read_Plugins {
# Check plugin files in common possible directories :
- # Windows : "${DIR}plugins" (plugins in same dir than awstats.pl)
+ # Windows and standard package: "$DIR/plugins" (plugins in same dir than awstats.pl)
# Redhat : "/usr/local/awstats/wwwroot/cgi-bin/plugins"
# Debian package : "/usr/share/awstats/plugins"
- # Other possible directories : "./plugins"
- my @PossiblePluginsDir=("${DIR}plugins","./plugins","/usr/local/awstats/wwwroot/cgi-bin/plugins","/usr/share/awstats/plugins");
+ my @PossiblePluginsDir=("$DIR/plugins","/usr/local/awstats/wwwroot/cgi-bin/plugins","/usr/share/awstats/plugins");
my %DirAddedInINC=();
foreach my $key (keys %NoLoadPlugin) { if ($NoLoadPlugin{$key} < 0) { push @PluginsToLoad, $key; } }
#------------------------------------------------------------------------------
# MAIN
#------------------------------------------------------------------------------
-($DIR=$0) =~ s/([^\/\\]*)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
+($DIR=$0||'.') =~ s/[\/\\]([^\/\\]+)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
$starttime=time();
if ($Debug) {
if ($ENV{'GATEWAY_INTERFACE'}) { print "\n"; } # To end the HTTP header and see all debug
debug(ucfirst($PROG)." - $VERSION - Perl $^X $]",1);
+ debug("DIR=$DIR PROG=$PROG",2);
debug("QUERY_STRING=$QueryString",2);
debug("HTMLOutput=".join(',',keys %HTMLOutput),1);
debug("YearRequired=$YearRequired, MonthRequired=$MonthRequired",2);