From a0fd38e966aa306459a0c7c7337721b0aba32437 Mon Sep 17 00:00:00 2001 From: MatOgr Date: Sat, 31 Dec 2022 13:17:17 +0100 Subject: [PATCH] ssh-key input parameter allowed --- gitea-deploy/deploy.sh | 2 +- gitea-deploy/just_do_everything.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gitea-deploy/deploy.sh b/gitea-deploy/deploy.sh index b0a39e4..f523f30 100755 --- a/gitea-deploy/deploy.sh +++ b/gitea-deploy/deploy.sh @@ -10,4 +10,4 @@ echo "-------------------------------------------------------------------------- echo " Success! I guess..." echo "############################" echo "Let's spawn some new machines!" -python just_do_everything.py --create \ No newline at end of file +python just_do_everything.py $1 --create \ No newline at end of file diff --git a/gitea-deploy/just_do_everything.py b/gitea-deploy/just_do_everything.py index 157f3cf..bbbc7e4 100755 --- a/gitea-deploy/just_do_everything.py +++ b/gitea-deploy/just_do_everything.py @@ -95,18 +95,17 @@ def create_client(creds_path): return client -def load_key(key_folder, pub_key_name): - home_path = Path.home().joinpath(key_folder, pub_key_name) - print(f"\t\tUsing the {home_path} file") - with open(home_path) as f: +def load_key(pub_key_path): + print(f"\t\tUsing the {pub_key_path} file") + with open(pub_key_path) as f: key = f.readline() print("\t\tThe SSH KEY has been LOADED") return key -def create_key(client, key_name, key_folder, pub_key_name): +def create_key(client, key_name, pub_key_path): print("The SSH KEY has been...") - key_of_power = load_key(key_folder, pub_key_name) + key_of_power = load_key(pub_key_path) key = client.ssh_keys.create(name=key_name, public_key=key_of_power) print("\tCREATED") return key @@ -231,10 +230,11 @@ if __name__ == "__main__": client = create_client("../tokens/token_file") + ssh_path = sys.argv[-2] action = sys.argv[-1] if action == "--create": - ssh_key = create_key(client, key_name, ".ssh", "id_ed25519.pub") + ssh_key = create_key(client, key_name, ssh_path) vnet = create_network(client, net_name, "10.10.10.0/24") volume = create_volume(client, volume_name, location) db = create_db(client, db_name, ssh_key, vnet, location, INIT_DB_CONTENT)