ich habe ja schon angekündigt, das ich ein script schreiben will welches mir folgendes möglich macht:
eine instanz auf einen neuen kunden kopieren.
im idealfall sollte man als gewissenhafter admin 2 contenido instanzen pro mandant haben. eine im live betrieb und eine für entwicklungen (oder tests). erst wenn auf der entwicklungsinstanz alles ok ist wird diese genommen und auf die liveinstanz kopiert.
leider war mir das nun etwas zuvile rumgemache jedesmal mit config.php anpassen, mandanteneinstellungen anpassen, usw.....
daher habe ich ein python buch aus dem schrank genommen und ein script geschrieben welches das alles für mich tut

das script ist für linux server gebaut, obs auf win funktioniert weis ich nicht.
und hier ist es, vielleicht kann es ja jemand von euch gebrauchen:
Code: Alles auswählen
#!/usr/bin/python2.4
#Imports
import os
import string
#Variablendeklaration
userLive = 'web3'
userEntwicklung = 'web4'
passLive = 'xxxxxx'
passEntwicklung = 'xxxxxx'
mandantLive = 'web3'
mandantEntwicklung = 'web4'
liveDB = 'usr_web3_1'
entwicklungsDB = 'usr_web4_1'
dumpEntwicklungsDB = '/home/%s.sql' %(mandantEntwicklung)
configLive = '/var/www/web3/html/contenido/includes/config.php'
webLive = 'www.sieda.com'
webEntwicklung = 'www.siedatest.de'
pathLive = '/var/www/web3/html/'
pathEntwicklung = '/var/www/web4/html/'
delDir = '%scms/cache' %(pathLive)
#Hauptprogramm
print '-----------------------------------------------'
print '| SEL - Contenido |'
print '| Spiegel Entwicklungsinstanz auf Liveinstanz |'
print '-----------------------------------------------'
print ''
print 'Starting...'
print ''
print 'Datenbankoperationen'
print '--------------------'
print 'Erstelle Datenbankdump von Entwicklungsinstanz...'
cmd = 'mysqldump -u %s -p%s %s > /home/%s.sql' %(userEntwicklung, passEntwicklung, entwicklungsDB, mandantEntwicklung)
os.popen(cmd)
print 'Loesche Livedatenbank...'
cmd = 'mysql -u %s -p%s -e "drop database %s"' %(userLive, passLive, liveDB)
os.popen(cmd)
print 'Uebernehme Entwicklungsdatenbank in Livedatenbank...'
cmd = 'mysql -u %s -p%s -e "create database %s"' %(userLive, passLive, liveDB)
os.popen(cmd)
cmd = 'mysql -u %s -p%s %s < %s' %(userLive, passLive, liveDB, dumpEntwicklungsDB)
os.popen(cmd)
print 'Datenbank uebernommen.'
print 'Passe Mandanteneinstellungen an...'
cmd = 'mysql -u %s -p%s -e "update con_clients set frontendpath=\'/var/www/%s/html/cms/\'" %s' %(userLive, passLive, mandantLive ,liveDB)
os.popen(cmd)
cmd = 'mysql -u %s -p%s -e "update con_clients set htmlpath=\'http://%s/cms/\'" %s' %(userLive, passLive, webLive ,liveDB)
os.popen(cmd)
cmd = 'mysql -u %s -p%s -e "delete * from con_code" %s' %(userLive, passLive, mandantLive)
print 'Datenbankoperationen abgeschlossen.'
print ''
print 'Dateioperationen'
print '----------------'
print 'Kopiere Dateien...'
cmd = 'cp -a %s* %s' %(pathEntwicklung, pathLive)
os.popen(cmd)
print 'Editiere ../contenido/includes/config.php...'
myfile = open(configLive, 'r+')
inhalt = myfile.read()
neuerInhalt = inhalt.replace(mandantEntwicklung, mandantLive)
neuerInhalt = neuerInhalt.replace(webEntwicklung, webLive)
myfile.close()
myfile = open(configLive, 'w+')
myfile.write(neuerInhalt)
myfile.close()
dateien = os.listdir(delDir)
for datei in dateien:
full = os.path.join(delDir, datei)
os.remove(full)
print 'Dateioperationen abgeschlossen.'
print ''
print 'Spiegelung der ConSolve Entwicklungsinstanz'
print 'auf die Liveinstanz erfolgreich durchgeführt.'

ach ja, eines ist noch anzumerken. leider wird die *.htaccess nicht mitkopiert

ach ja, die variablen müssen natürlich ans jeweilige system angepasst werden

gruesse rene