Forum: Adding sites using a script

 

« Back To Thread List

TekZone
3652 days ago
Hello,

I love your software and I am trying to propose such an option for the clients of the company for which I work for.

I made a little Python script which is the following that allows me to add a site in config.php :

----------------------
import os, sys

if len(sys.argv) != 2:
print 'Les arguments fournis au script ne sont pas corrects'
print ''
print 'Utilisation du script :'
print ''
print 'python CreationJAwstats.py nomdedomaine'
sys.exit()

# On recupere les arguments passes au script
domaine = sys.argv[1]

# On ouvre le fichier de configuration de jawstats
conf = open('config.php','r')
confnew = open('config.php','w')

for line in conf:
if line != '?>':
#confnew.write(line)
print line
print "Ligne OK"
else:
print "Ligne detectee"
confnew.write(' $aConfig[\"'+domaine+'\"] = array(\n')
confnew.write(' \"statspath\" => \"/data/awstats/www/'+domaine+'/\",\n')
confnew.write(' \"updatepath\" => \"/usr/lib/cgi-bin/\",\n')
confnew.write(' \"siteurl\" => \"http://www.'+domaine+'\",\n')
confnew.write(' \"theme\" => \"default\",\n')
confnew.write(' \"fadespeed\" => 250,\n')
confnew.write(' \"password\" => \"'+domaine+'\",\n')
confnew.write(' \"includes\" => \"\"\n')
confnew.write(' );\n')
confnew.write('\n')
confnew.write('?>')
----------------------

The script seems to work fine. The only problem is that the output file has the character ^M at the end of each line. If I manually delete this character or use dos2unix to delete them, the config file doesn't work... JAwstats show the refresh symbol indefinently. If I edit manually the file with the exact same configuration, it works juste fine.

This is really bothering because this is the only think keeping me from sending this in preprod.

I thought of another alternative which would be to include all the files from a folder which would each contain the configuration for a site. That doesn't work either...

I am out of ideas.

Thank you very much for your help,

Antoine Benkemoun
oskar
3617 days ago
I made it a little other way...

// individual site configuration.
$aConfig[(str_replace("www.", "", $_SERVER['HTTP_HOST']))] = array(.
"statspath" => "/usr/local/www/awstats/stats/",.
"updatepath" => "/usr/local/www/awstats/cgi-bin/awstats.pl",.
"siteurl" => "http://".$_SERVER['HTTP_HOST']."/",.
"theme" => "default",.
"fadespeed" => 250,.
"password" => "test",.
"includes" => "".
);.


The idea is that I place JAWStats in a directory, that is avaible on every domain (Directory Alias in Apache). With the above config everything works automaticly, so I don't have to add anything to the config when a new client comes :)

« Back To Thread List

Participate in this discussion

 

You must be logged in to post in this thread.

 

Version 0.7 beta available now

Released 25th Janury 2009

Try the online demo or download now.

 
Latest JAWStats News:

Version 0.7 Beta Released

Sprechen Sie Deutsch? Multi-lingual JAWStats v0.7 is finally here.

posted 25th Jan '09. read more »
 

Help JAWStats

Please donate a dollar (or more!) towards the hosting costs for this site. This money doesn't go anywhere near my pocket, it is purely used against my hosting bill.

 

Get $50 off your webhosting

You could do far worse than choose Dreamhost. I've used them for 6 years and they're great. Simply enter the promo code: JAWSTATS on signup!