forked from marius311/cosmohome
/
cosmohome_postbuild.py
executable file
·46 lines (34 loc) · 1.38 KB
/
cosmohome_postbuild.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
import os
from os import system as sh
import os.path as osp
import sys
import _mysql_exceptions
sys.path.append('/root/boinc/py')
import boinc_path_config
from Boinc import database, configxml
print "Copying project files to data volume..."
sh('cp -r /root/projects.build/cosmohome /root/projects')
for x in ['html', 'html/cache', 'upload', 'log_cosmohome']:
sh('chmod -R g+w /root/projects/cosmohome/'+x)
print "Linking httpd.conf..."
conf_file = '/root/projects/cosmohome/cosmohome.httpd.conf'
sym_target = osp.join("/etc/apache2/sites-enabled/",osp.basename(conf_file))
if not osp.exists(sym_target): os.symlink(os.path.abspath(conf_file),sym_target)
if not '--copy-only' in sys.argv:
print "Creating database..."
try:
database.create_database(
srcdir = '/root/boinc',
config = configxml.ConfigFile(filename='/root/projects/cosmohome/config.xml').read().config,
drop_first = False
)
except _mysql_exceptions.ProgrammingError as e:
if e[0]==1007: print "Database exists, not overwriting."
else: raise
else:
sh('cd /root/projects/cosmohome/html/ops; ./db_schemaversion.php > /root/projects/cosmohome/db_revision')
print "Running BOINC update scripts..."
os.chdir('/root/projects/cosmohome')
sh('bin/xadd')
sh('(%s) | bin/update_versions'%('; '.join(['echo y']*10)))