This commit is contained in:
ahmadbilalkhalid 2019-08-28 23:58:00 +05:00
parent 61e42af6e4
commit ad88f6ba0a
1 changed files with 13 additions and 1 deletions

View File

@ -19,7 +19,9 @@ def image():
@image.command("setup")
@click.option("--path", required=True)
def setup(path):
@click.option("--etcd_url", required=True)
@click.option("--etcd_password", required=True)
def setup(path, etcd_url, etcd_password):
os.chdir(path)
repo_name = "ucloud-image-scanner"
@ -28,6 +30,14 @@ def setup(path):
f"https://code.ungleich.ch/ungleich-public/{repo_name}.git"
)
content = f"ETCD_URL={etcd_url}\n" \
f"ETCD_PASSWORD={etcd_password}\n"
op_result.add(
FileOperation.write, path=os.path.join(repo_name, ".env"), content=content
)
op_result.add(
GitOperation.clone,
path=repo_name,
@ -37,3 +47,5 @@ def setup(path):
op_result.add(PipenvOperation.install, path=repo_name)
# Write Crontab entry
with open("/etc/crontabs/root", "a") as crontab:
crontab.write(f"*/5\t*\t*\t*\t*\tcd {os.path.join(os.getcwd(), repo_name)} && pipenv run python main.py")