41 lines
No EOL
1.3 KiB
Python
41 lines
No EOL
1.3 KiB
Python
import click
|
|
import subprocess
|
|
|
|
|
|
from app.helper import clone, clone_common,\
|
|
clone_etcd_wrapper, pipenv_install
|
|
|
|
@click.group()
|
|
def api():
|
|
pass
|
|
|
|
@api.command("setup")
|
|
@click.option("--auth_name", required=True)
|
|
@click.option("--auth_seed", required=True)
|
|
@click.option("--auth_realm", required=True)
|
|
@click.option("--realm_allowed", multiple=True, required=True)
|
|
@click.option("--otp_server", default="https://otp.ungleich.ch/ungleichotp/",
|
|
help="URL of ungleich OTP server")
|
|
|
|
def setup(auth_name, auth_seed, auth_realm, realm_allowed, otp_server):
|
|
if clone("https://code.ungleich.ch/ungleich-public/ucloud-api.git"):
|
|
with open(".env", "w") as env_file:
|
|
lines = [f"AUTH_NAME={auth_name}",
|
|
f"AUTH_SEED={auth_seed}",
|
|
f"AUTH_REALM={auth_seed}",
|
|
f"REALM_ALLOWED={realm_allowed}",
|
|
f"OTP_SERVER={otp_server}"]
|
|
|
|
env_file.writelines(lines)
|
|
|
|
result = []
|
|
result.append(clone_common())
|
|
result.append(clone_etcd_wrapper())
|
|
|
|
if all(result):
|
|
result.append(pipenv_install("ucloud-api"))
|
|
|
|
if all(result):
|
|
print("Successfull installation :)")
|
|
else:
|
|
print("Unsuccessful installation ;(") |