#! /usr/bin/env python # Copyright 2008-2010 eGovMon # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the eGovernment Monitoring # (eGovMon) # # eGovMon is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # eGovMon is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with eGovMon; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "$Author$" __version__ = "$Revision$" __updated__ = "$LastChangedDate$" import os import sys import getopt PREFIX="." wam_packages=[ "SystemConfiguration", "WAMs/HWAM", "WAMs/WamServer", ] all_packages=wam_packages+[ "MemCache", "Monitoring", "egovmontime", "eGovMonDB", "SimpleCrawler", "CrawlerServer", "SamplingAlgorithm", "SiteURLServer", "SamplingServer", "logit", "SimpleWAMCaller", "DBCleaner" ] if "dailybuild" in sys.argv: raise('daily build not yet finished') #Clean print "Starting Cleaning" #Yum Remove for package in all_packages: print "Cleaning package: ",package os.system("find "+package+" -name *.pyc -exec rm {} \;") print "Starting Installing" #Yum Install for package in all_packages: print "Package: ",package os.system("cd "+os.path.join(PREFIX,package)+";python setup.py install") print "Starting Restarting" os.system("/etc/init.d/relaxedwam restart") os.system("/etc/init.d/siteurlserver restart") os.system("/etc/init.d/samplingserver restart") os.system("/etc/init.d/etlserver restart") os.system("/etc/init.d/crawlerserver restart") os.system("/etc/init.d/dbleaner restart") #TODO: Run all Unit tests here #Basic Test print "Starting Testing" os.system("python ./Monitoring/checkstatus.py") def createlogs(): #creating logs: import sc import os loglocation = sc.SystemConfiguration().loglocation if not os.path.isdir(loglocation): #Directory does not exist os.system('mkdir '+loglocation) os.system('chmod 666 '+loglocation) os.system('chown nobody:nobody '+loglocation) print 'Directory',loglocation,'did not exist. It has been created' for log in ['sitesloaded_stat.log','siteurlserver.log','dbcleaner.log','crawler'+'.log','crawlerserver.log','etlserver.log','relaxed.log','relaxedStdOutAndErr.log','relaxedwam.log','samplingserver.log','pdfwam.log','failedsites.log']: if not os.path.isfile(loglocation + log): os.system('touch '+loglocation + log) print 'Log file',loglocation+log,'did not exist. It has been created' os.system('chmod 666 '+loglocation + log) os.system('chown nobody:nobody '+loglocation + log) print 'Logs have been created' if "clean" in sys.argv: for package in all_packages: print "Cleaning package: ",package os.system("find "+package+" -name *.pyc -exec rm {} \;") if "install" in sys.argv: for package in all_packages: print "Package: ",package ret = os.system("cd "+os.path.join(PREFIX,package)+";python setup.py install") if ret != 0: raise Exception, "Install failed at " + package os.system("/etc/init.d/relaxedwam restart") if not os.path.isdir('/var/lock/subsys'): os.system("mkdir /var/lock/subsys") createlogs() if "wam" in sys.argv: for package in wam_packages: print "Package: ",package ret = os.system("cd "+os.path.join(PREFIX,package)+" && python setup.py install") if ret != 0: raise Exception, "WAM-Install failed at " + package os.system("/etc/init.d/relaxedwam restart") createlogs() if 'createlogs' in sys.argv: createlogs()