Index: trunk/wikiation/installer/settings_handler.py |
— | — | @@ -42,11 +42,6 @@ |
43 | 43 | #where wikiation_check_isolation can be found |
44 | 44 | isolation_create=toolkit_dir+'/wikiation_check_isolation/create_and_ul.sh' |
45 | 45 | isolation_test=toolkit_dir+'/wikiation_check_isolation/dl_and_check.sh' |
46 | | - |
47 | | -# what mysql command should be used. (Who us? Use horrible hacks?) |
48 | | - |
49 | | -mysql_command="mysql -uwiki -pwiki1234" |
50 | | - |
51 | 46 | # run automated tests during installation |
52 | 47 | # this is useful if you are in a testing environment. |
53 | 48 | # If you are running production, you might want to leave |
— | — | @@ -59,7 +54,27 @@ |
60 | 55 | adminuser_name="admin" |
61 | 56 | adminuser_password="admin1234" |
62 | 57 | |
| 58 | +#mysql info |
| 59 | +mysql_user="root" |
| 60 | +mysql_pass="" |
63 | 61 | |
| 62 | +# what mysql commands should be used. (Who us? Use horrible hacks?) |
| 63 | + |
| 64 | +userpart="" |
| 65 | +passpart="" |
| 66 | +if mysql_user: |
| 67 | + userpart="-u"+mysql_user |
| 68 | +if mysql_pass: |
| 69 | + passpart="-p"+mysql_pass |
| 70 | + |
| 71 | +mysql_arguments=" "+userpart+" "+passpart |
| 72 | + |
| 73 | +if not 'mysql_command' in globals(): |
| 74 | + mysql_command="mysql "+mysql_arguments |
| 75 | + |
| 76 | +if not 'mysqldump_command' in globals(): |
| 77 | + mysqldump_command="mysqldump "+mysql_arguments |
| 78 | + |
64 | 79 | if os.path.exists(os.path.join(installerdir, 'settings.py')): |
65 | 80 | from settings import * |
66 | 81 | |
Index: trunk/wikiation/installer/installer.py |
— | — | @@ -80,6 +80,11 @@ |
81 | 81 | """install something""" |
82 | 82 | installers.install(args) |
83 | 83 | |
| 84 | +def duplicate(args): |
| 85 | + """duplicate an instance""" |
| 86 | + if len(args)!=3: |
| 87 | + print "syntax:\n duplicate source_instance destination_instance" |
| 88 | + installers.duplicate(args) |
84 | 89 | |
85 | 90 | def uninstall(args): |
86 | 91 | """uninstall something""" |
— | — | @@ -154,7 +159,8 @@ |
155 | 160 | "info":info, |
156 | 161 | "check_isolation":check_isolation, |
157 | 162 | "update_self":update_self, |
158 | | - "update_tags":update_tags |
| 163 | + "update_tags":update_tags, |
| 164 | + "duplicate":duplicate |
159 | 165 | } |
160 | 166 | |
161 | 167 | # additional help texts for some commands. |
Index: trunk/wikiation/installer/mediawiki_installer.py |
— | — | @@ -115,7 +115,31 @@ |
116 | 116 | return settings.trunkdir |
117 | 117 | |
118 | 118 | |
| 119 | + def duplicate(self, src, dst): |
| 120 | + if not self.is_installed(src): |
| 121 | + raise Mediawiki_Installer_Exception(src+" not found.") |
119 | 122 | |
| 123 | + if self.is_installed(dst): |
| 124 | + raise Mediawiki_Installer_Exception(dst+" already exists.") |
| 125 | + |
| 126 | + srcpath= os.path.join(settings.instancesdir,src) |
| 127 | + dstpath= os.path.join(settings.instancesdir,dst) |
| 128 | + dbtmp=os.path.join(dstpath,"installerdbtmp.sql") |
| 129 | + print "Copying instance files..." |
| 130 | + shutil.copytree(srcpath,dstpath,symlinks=True) |
| 131 | + print "updating unique settings" |
| 132 | + uniquesettings(dst) |
| 133 | + print "Copying instance database..." |
| 134 | + dumpdb(src,dbtmp) |
| 135 | + dropdb(dst) |
| 136 | + createdb(dst) |
| 137 | + do_sql(dst,dbtmp) |
| 138 | + print "cleanup" |
| 139 | + os.unlink(dbtmp) |
| 140 | + print "done." |
| 141 | + |
| 142 | + |
| 143 | + |
120 | 144 | #TODO: use this method everywhere a database name is requested |
121 | 145 | def dbname(installer_name): |
122 | 146 | """based on the name of the installer/instance, figure out what the name of the |
— | — | @@ -172,8 +196,9 @@ |
173 | 197 | else: |
174 | 198 | checkout(target+"/", name, revision) |
175 | 199 | |
176 | | - print "Creating LocalSettings.php..." |
| 200 | + print "Copying LocalSettings.php,creating unique settings..." |
177 | 201 | localsettings(name) |
| 202 | + uniquesettings(name) |
178 | 203 | print "Copy logo..." |
179 | 204 | logo(name) |
180 | 205 | print "Setting up database..." |
— | — | @@ -228,19 +253,22 @@ |
229 | 254 | |
230 | 255 | def localsettings(target): |
231 | 256 | """Copy over our LocalSettings.php , and create InstallerUniqueSettings.php |
232 | | - (which contains settings unique to this instance) |
| 257 | + (which contains settings unique to this instance), and create LocalSettings dir. |
233 | 258 | LocalSettings.php is the main configuration file for mediawiki.""" |
234 | 259 | |
235 | 260 | here=settings.installerdir+"/LocalSettings.php" |
236 | 261 | instancedir=settings.instancesdir+"/"+target |
237 | 262 | there=instancedir+"/LocalSettings.php" |
238 | 263 | shutil.copy2(here,there) |
| 264 | + subdir=os.path.join(settings.revisionsdir,target,"LocalSettings") |
| 265 | + os.mkdir(subdir) |
239 | 266 | |
| 267 | +def uniquesettings(target): |
240 | 268 | uniquesettings=settings.instancesdir+"/"+target+"/InstallerUniqueSettings.php" |
241 | 269 | unique=file(uniquesettings,"w") |
242 | 270 | unique.write('<?php\n') |
243 | 271 | unique.write('$wgSitename = "Wikiation_'+target+'";\n') |
244 | | - unique.write('$wgScriptPath = "'+settings.base_scriptpath+"/"+target+'";\n') |
| 272 | + unique.write('$wgScriptPath = "'+settings.base_scriptpath+target+'";\n') |
245 | 273 | unique.write('$wgDBname = "'+target+'";\n') |
246 | 274 | unique.write('?>\n') |
247 | 275 | |
— | — | @@ -276,6 +304,10 @@ |
277 | 305 | command="php "+phpfile+" --bureaucrat "+settings.adminuser_name+" "+settings.adminuser_password |
278 | 306 | os.system(command) |
279 | 307 | |
| 308 | +def dumpdb(target,outfile): |
| 309 | + command=settings.mysqldump_command+" "+target+" > "+outfile |
| 310 | + os.system(command) |
| 311 | + |
280 | 312 | def do_sql(target, infile): |
281 | 313 | """execute an sql file, using mysql""" |
282 | 314 | |
Index: trunk/wikiation/installer/installers.py |
— | — | @@ -147,6 +147,14 @@ |
148 | 148 | system.get_info(ppath["installer"]) |
149 | 149 | |
150 | 150 | |
| 151 | +def duplicate(args): |
| 152 | + mw=get_system("mediawiki") |
| 153 | + try: |
| 154 | + mw.duplicate(args[1],args[2]) |
| 155 | + except Mediawiki_Installer_Exception,e: |
| 156 | + print e.message |
| 157 | + |
| 158 | + |
151 | 159 | def install(args): |
152 | 160 | if len(args)<1: |
153 | 161 | print "install: Internal error: expected more arguments" |