Commit a928b0b9 by Nicolas Wavrant

new function in utils.py:

clone the git repo of slapos by default (if it is not present), when the runner is launched
parent af2b25ac
...@@ -11,6 +11,7 @@ import os ...@@ -11,6 +11,7 @@ import os
import slapos.runner.process import slapos.runner.process
import sys import sys
from slapos.runner.utils import runInstanceWithLock from slapos.runner.utils import runInstanceWithLock
from utils import cloneDefaultgit
class Parser(OptionParser): class Parser(OptionParser):
...@@ -120,6 +121,8 @@ def run(): ...@@ -120,6 +121,8 @@ def run():
# avoid mistakes (mainly in development mode) # avoid mistakes (mainly in development mode)
raise Exception('Do not run SlapRunner as root.') raise Exception('Do not run SlapRunner as root.')
cloneDefaultgit()
serve(config) serve(config)
return_code = 0 return_code = 0
except SystemExit as err: except SystemExit as err:
......
...@@ -803,3 +803,19 @@ def readParameters(path): ...@@ -803,3 +803,19 @@ def readParameters(path):
return str(e) return str(e)
else: else:
return "No such file or directory: %s" % path return "No such file or directory: %s" % path
def cloneDefaultGit():
"""Test if the slapos git has been downloaded yet
If not, download it in read-only mode"""
slap = os.path.join(config.runner_workdir, 'project', 'slapos')
slap_ro = os.path.join(config.runner_workdir, 'project', 'slapos-readonly')
if not os.path.exists(slap_ro) or not os.path.exists(slap_ro):
from gittools import cloneRepo
user = open(os.path.join(config.etc_dir, '.users')).read().split(';')
data = {'path': slap_ro,
'repo': 'http://git.erp5.org/repos/slapos.git',
'email': user[2],
'user': user[3],
}
cloneRepo(data)
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 sign in to comment