]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Added awstats_updateall.pl tool
authoreldy <>
Mon, 14 Oct 2002 19:01:23 +0000 (19:01 +0000)
committereldy <>
Mon, 14 Oct 2002 19:01:23 +0000 (19:01 +0000)
Added configure.pl tool

tools/awstats_updateall.pl [new file with mode: 0644]
tools/configure.pl [new file with mode: 0644]

diff --git a/tools/awstats_updateall.pl b/tools/awstats_updateall.pl
new file mode 100644 (file)
index 0000000..335a575
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+#-Description-------------------------------------------
+# Launch update process for all config files found in a particular directory.
+# See COPYING.TXT file about AWStats GNU General Public License.
+#-------------------------------------------------------
+# $Revision$ - $Author$ - $Date$
+
+
+#-------------------------------------------------------
+# Defines
+#-------------------------------------------------------
+my $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+my $VERSION="1.0 (build $REVISION)";
+
+# Default value of DIRCONFIG and AWSTATSSCRIPT
+my $DIRCONFIG = "/etc/opt/awstats";
+my $AWSTATSSCRIPT = "/opt/awstats/wwwroot/cgi-bin/awstats.pl";
+
+
+
+
+#-------------------------------------------------------
+# MAIN
+#-------------------------------------------------------
+
+# Change default value if options are used
+my $helpfound=0;my $nowfound=0;
+for (0..@ARGV-1) {
+       if ($ARGV[$_] =~ /^-*h/i)                        { $helpfound=1; last; }
+       if ($ARGV[$_] =~ /^-*awstatsprog=(.*)/i) { $AWSTATSSCRIPT="$1"; next; }
+       if ($ARGV[$_] =~ /^-*confdir=(.*)/i)     { $DIRCONFIG="$1"; next; }
+       if ($ARGV[$_] =~ /^now/i)                        { $nowfound=1; next; }
+}
+
+# Show usage help
+my $DIR; my $PROG; my $Extension;
+($DIR=$0) =~ s/([^\/\\]*)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
+if (!$nowfound || $helpfound || ! @ARGV) {
+       print "----- $PROG $VERSION (c) Laurent Destailleur -----\n";
+       print "$PROG launch update process for each config file found\n";
+       print "in $DIRCONFIG directory (for fast cron/scheduler setup).\n";
+       print "\n";
+       print "Usage:  $PROG.$Extension now [options]\n";
+       print "\n";
+       print "Where options are:\n";
+       print "  -awstatsprog=pathtoawstatspl\n";
+       print "  -confdir=confdirtoscan\n";
+       print "\n";
+       exit 0;
+}
+
+# Scan directory $DIRCONFIG 
+opendir(DIR, $DIRCONFIG) || die "Can't scan directory $DIRCONFIG";
+my @files = grep { /^awstats\.(.*)conf$/ } sort readdir(DIR);
+closedir(DIR);
+
+# Run update process for each config file found
+if (@files) {
+       foreach (@files) {
+               if ($_ =~ /^awstats\.(.*)conf$/) {
+                       my $domain = $1||"default"; $domain =~ s/\.$//;
+                       print "Running $AWSTATSSCRIPT to update config $domain\n";
+                       my $output = `"$AWSTATSSCRIPT" -config=$domain -update 2>&1`;
+                       print "$output\n";
+               }
+       }
+} else {
+       print "No AWStats config file found in $DIRCONFIG\n";   
+}
+
+0;     # Do not remove this line
diff --git a/tools/configure.pl b/tools/configure.pl
new file mode 100644 (file)
index 0000000..425e67a
--- /dev/null
@@ -0,0 +1,107 @@
+#!/usr/bin/perl
+#-Description-------------------------------------------
+# This script creates one config file for each virtual web servers
+# so AWStats is immedialty working.
+# See COPYING.TXT file about AWStats GNU General Public License.
+#-------------------------------------------------------
+# $Revision$ - $Author$ - $Date$
+
+
+#-------------------------------------------------------
+# Defines
+#-------------------------------------------------------
+my $REVISION='$Revision$'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
+my $VERSION="1.0 (build $REVISION)";
+
+
+
+#-------------------------------------------------------
+# Functions
+#-------------------------------------------------------
+sub error {
+       print "Error: $_[0].\n";
+    exit 1;
+}
+
+sub debug {
+       my $level = $_[1] || 1;
+       if ($Debug >= $level) { 
+               my $debugstring = $_[0];
+               if ($ENV{"GATEWAY_INTERFACE"}) { $debugstring =~ s/^ /&nbsp&nbsp /; $debugstring .= "<br>"; }
+               print "DEBUG $level - ".time." : $debugstring\n";
+               }
+       0;
+}
+
+
+
+#-------------------------------------------------------
+# MAIN
+#-------------------------------------------------------
+my $QueryString=""; for (0..@ARGV-1) { $QueryString .= "$ARGV[$_] "; }
+if ($QueryString =~ /debug=/i) { $Debug=$QueryString; $Debug =~ s/.*debug=//; $Debug =~ s/&.*//; $Debug =~ s/ .*//; }
+if ($QueryString =~ /dnslookup/i) { $DNSLookup=1; }
+if ($QueryString =~ /showsteps/i) { $ShowSteps=1; }
+
+my $helpfound=0;
+for (0..@ARGV-1) {
+       if ($ARGV[$_] =~ /^-*h/i)                        { $helpfound=1; last; }
+}
+
+# Show usage help
+my $DIR; my $PROG; my $Extension;
+($DIR=$0) =~ s/([^\/\\]*)$//; ($PROG=$1) =~ s/\.([^\.]*)$//; $Extension=$1;
+if ($helpfound) {
+       print "----- $PROG $VERSION (c) Laurent Destailleur -----\n";
+       print "$PROG creates all AWStats config files for each virtual servers\n";
+       print "found in an Apache web server configuration.\n";
+       print "\n";
+       print "Usage:  $PROG.$Extension\n";
+       print "\n";
+       exit 0;
+}
+
+# Get current time
+my $nowtime=time;
+my ($nowsec,$nowmin,$nowhour,$nowday,$nowmonth,$nowyear) = localtime($nowtime);
+if ($nowyear < 100) { $nowyear+=2000; } else { $nowyear+=1900; }
+my $nowsmallyear=$nowyear;$nowsmallyear =~ s/^..//;
+if (++$nowmonth < 10) { $nowmonth = "0$nowmonth"; }
+if ($nowday < 10) { $nowday = "0$nowday"; }
+if ($nowhour < 10) { $nowhour = "0$nowhour"; }
+if ($nowmin < 10) { $nowmin = "0$nowmin"; }
+if ($nowsec < 10) { $nowsec = "0$nowsec"; }
+
+
+
+print "This script is not ready yet.\n";
+
+
+
+# Search web server
+
+
+
+
+
+# Search Apache config file
+
+
+
+
+
+# Search virtual servers
+
+
+
+
+
+# Loop on each virtual servers to create one config file
+
+
+
+
+
+
+
+0;     # Do not remove this line