a
This commit is contained in:
parent
61e42af6e4
commit
ad88f6ba0a
1 changed files with 13 additions and 1 deletions
14
app/image.py
14
app/image.py
|
@ -19,7 +19,9 @@ def image():
|
||||||
|
|
||||||
@image.command("setup")
|
@image.command("setup")
|
||||||
@click.option("--path", required=True)
|
@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)
|
os.chdir(path)
|
||||||
|
|
||||||
repo_name = "ucloud-image-scanner"
|
repo_name = "ucloud-image-scanner"
|
||||||
|
@ -28,6 +30,14 @@ def setup(path):
|
||||||
f"https://code.ungleich.ch/ungleich-public/{repo_name}.git"
|
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(
|
op_result.add(
|
||||||
GitOperation.clone,
|
GitOperation.clone,
|
||||||
path=repo_name,
|
path=repo_name,
|
||||||
|
@ -37,3 +47,5 @@ def setup(path):
|
||||||
op_result.add(PipenvOperation.install, path=repo_name)
|
op_result.add(PipenvOperation.install, path=repo_name)
|
||||||
|
|
||||||
# Write Crontab entry
|
# 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")
|
Loading…
Add table
Reference in a new issue