Commit 72fe465b authored by Alain Takoudjou's avatar Alain Takoudjou

Use dedicaced python, update dependency between Trac and Mysql

parent e6a156b6
...@@ -43,7 +43,6 @@ class Recipe(GenericBaseRecipe): ...@@ -43,7 +43,6 @@ class Recipe(GenericBaseRecipe):
if eggs: if eggs:
for item in os.listdir(eggs): for item in os.listdir(eggs):
path = os.path.join(eggs, item) path = os.path.join(eggs, item)
if os.path.isdir(path):
pythonPath = path + ":" + pythonPath pythonPath = path + ":" + pythonPath
options['python_path'] = pythonPath options['python_path'] = pythonPath
...@@ -60,7 +59,10 @@ class Recipe(GenericBaseRecipe): ...@@ -60,7 +59,10 @@ class Recipe(GenericBaseRecipe):
admin = self.options['admin-user'].strip() admin = self.options['admin-user'].strip()
passwd = self.options['admin-password'].strip() passwd = self.options['admin-password'].strip()
config = os.path.join(project_dir, 'conf/trac.ini') config = os.path.join(project_dir, 'conf/trac.ini')
filestat = self.options['file-status'].strip()
self.logger.info("Checking if trac project is not installed...") self.logger.info("Checking if trac project is not installed...")
if os.path.exists(filestat):
os.unlink(filestat)
if not os.path.exists(project_dir): if not os.path.exists(project_dir):
self.logger.info("Starting trac project installation at %s" % project_dir) self.logger.info("Starting trac project installation at %s" % project_dir)
trac_args = [trac_admin, project_dir, 'initenv'] trac_args = [trac_admin, project_dir, 'initenv']
...@@ -71,15 +73,17 @@ class Recipe(GenericBaseRecipe): ...@@ -71,15 +73,17 @@ class Recipe(GenericBaseRecipe):
self.options['mysql-port'].strip(), self.options['mysql-port'].strip(),
self.options['mysql-database'].strip() self.options['mysql-database'].strip()
) )
process = subprocess.Popen(trac_args, stdout=subprocess.PIPE, process_install = subprocess.Popen(trac_args, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stderr=subprocess.STDOUT) stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
process.stdin.write('%s\n%s\n' % (self.options['project'].strip(), process_install.stdin.write('%s\n%s\n' % (self.options['project'].strip(),
db_string)) db_string))
result = process.communicate()[0] result = process_install.communicate()[0]
process.stdin.close() process_install.stdin.close()
if process.returncode is None or process.returncode != 0: if process_install.returncode is None or process_install.returncode != 0:
if os.path.exists(project_dir):
shutil.rmtree(project_dir) shutil.rmtree(project_dir)
raise Exception("Failed to execute Trac-admin.\nThe error was: %s" % result) self.logger.error("Failed to initialize Trac.\nThe error was: %s" % result)
return []
os.mkdir(self.options['wsgi-dir']) os.mkdir(self.options['wsgi-dir'])
os.mkdir(self.options['git-dir']) os.mkdir(self.options['git-dir'])
os.mkdir(self.options['svn-dir']) os.mkdir(self.options['svn-dir'])
...@@ -90,6 +94,13 @@ class Recipe(GenericBaseRecipe): ...@@ -90,6 +94,13 @@ class Recipe(GenericBaseRecipe):
else: else:
self.logger.info("The directory %s already exist, skip project installation" self.logger.info("The directory %s already exist, skip project installation"
% project_dir) % project_dir)
trac_args = [trac_admin, project_dir, 'upgrade']
process_upgrade = subprocess.Popen(trac_args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
result = process_upgrade.communicate()[0]
if process_upgrade.returncode is None or process_upgrade.returncode != 0:
self.logger.error("Failed to upgrade Trac.\nThe error was: %s" % result)
return []
#Add All grant to admin user #Add All grant to admin user
self.logger.info("Granting admin rights to the admin user.") self.logger.info("Granting admin rights to the admin user.")
...@@ -146,6 +157,7 @@ class Recipe(GenericBaseRecipe): ...@@ -146,6 +157,7 @@ class Recipe(GenericBaseRecipe):
(user, result)) (user, result))
fd.write("\n%s = %s" % (user, user_list[user])) fd.write("\n%s = %s" % (user, user_list[user]))
fd.close() fd.close()
open(filestat, "w").write("done.")
return install_path return install_path
...@@ -313,6 +313,7 @@ svn-repo-script = $${trac-svnrepo-script:output} ...@@ -313,6 +313,7 @@ svn-repo-script = $${trac-svnrepo-script:output}
post-revprop-change = $${post-revprop-change-script:output} post-revprop-change = $${post-revprop-change-script:output}
trac-svn-hook = $${trac-svn-hook-script:output} trac-svn-hook = $${trac-svn-hook-script:output}
trac-git-hook = $${trac-git-hook-script:output} trac-git-hook = $${trac-git-hook-script:output}
file-status = $${buildout:directory}/.status
#Trac User list #Trac User list
htpasswd = ${apache:location}/bin/htpasswd htpasswd = ${apache:location}/bin/htpasswd
passwd-file = $${trac-config:project_dir}/.htpasswd passwd-file = $${trac-config:project_dir}/.htpasswd
...@@ -323,7 +324,9 @@ user-list = $${slap-parameter:trac-user-list} ...@@ -323,7 +324,9 @@ user-list = $${slap-parameter:trac-user-list}
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = ${apache:location}/bin/httpd -DFOREGROUND -f "$${httpd-conf:output}" command-line = ${apache:location}/bin/httpd -DFOREGROUND -f "$${httpd-conf:output}"
environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:python_path} environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:python_path}
PATH=${python2.7:location}/bin:$PATH
wrapper-path = $${basedirectory:services}/httpd wrapper-path = $${basedirectory:services}/httpd
wait-for-files = $${inittrac:file-status}
[logrotate-entry-apache] [logrotate-entry-apache]
<= logrotate <= logrotate
...@@ -433,6 +436,7 @@ path = $${basedirectory:promises}/content ...@@ -433,6 +436,7 @@ path = $${basedirectory:promises}/content
url = $${request-frontend:connection-site_url} url = $${request-frontend:connection-site_url}
dash_path = ${dash:location}/bin/dash dash_path = ${dash:location}/bin/dash
curl_path = ${curl:location}/bin/curl curl_path = ${curl:location}/bin/curl
match = $${slap-parameter:project-name}
[slap-parameter] [slap-parameter]
domain = domain =
......
...@@ -115,7 +115,7 @@ md5sum = bc6ed91a1862a10af661713aa0691848 ...@@ -115,7 +115,7 @@ md5sum = bc6ed91a1862a10af661713aa0691848
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-trac.cfg url = ${:_profile_base_location_}/instance-trac.cfg
output = ${buildout:directory}/template-trac.cfg output = ${buildout:directory}/template-trac.cfg
md5sum = e31ae66fb08f9e44cedbaa09357b15ce md5sum = 4c5caf5cfb7567964c54cd57adba46a4
mode = 0644 mode = 0644
[create-svn-repo] [create-svn-repo]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment