From 1c29b648c98999f09767c63b9b8904bab6bb8b67 Mon Sep 17 00:00:00 2001 From: Holger Wasem Date: Mon, 4 Sep 2023 10:39:18 +0200 Subject: [PATCH] commit by to_remotes 2023-09-04 10:39:18 +0200 from vmdevhw --- init.sh | 66 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/init.sh b/init.sh index e77ac77..352bd53 100755 --- a/init.sh +++ b/init.sh @@ -1,41 +1,43 @@ #!/bin/bash +WA_REPO=$HOME/wa_repos + echo "################################################" echo " basic init of wiseadvice node " echo "################################################" -echo "create ssh key" - -echo -n "client name: " -read -r client_name - -echo -n "ssh passphrase: " - -stty_orig=$(stty -g) # save original terminal setting. -stty -echo -read -r passphrase -stty "$stty_orig" # restore terminal setting. - - -echo "1. client name: $client_name" - -mkdir -p $HOME/.ssh - -ssh-keygen -t rsa -N "$passphrase" -C "deploy_key_$client_name" -f $HOME/.ssh/deploy_key - -echo "please now upload pub key into repo ..." -echo "firefox https://git.service.wiseadvice.eu/" -echo " " - -cat $HOME/.ssh/deploy_key.pub - -echo " " -echo -n "ready to pull? type yes: " -read -r ready_to_pull -WA_REPO=$HOME/wa_repos if [ -d "$WA_REPO" ]; then echo "$WA_REPO does exist, skipping cloning" + source $WA_REPO/export_client_name.sh + echo "found client name: $CLIENT_NAME" else + echo -n "client name: " + read -r CLIENT_NAME + echo "create ssh key" + echo -n "ssh passphrase: " + + stty_orig=$(stty -g) # save original terminal setting. + stty -echo + read -r passphrase + stty "$stty_orig" # restore terminal setting. + + + echo "1. client name: $CLIENT_NAME" + + mkdir -p $HOME/.ssh + + ssh-keygen -t rsa -N "$passphrase" -C "deploy_key_$CLIENT_NAME" -f $HOME/.ssh/deploy_key + + echo "please upload now pub key into user $CLIENT_NAME keys ..." + echo "firefox https://git.service.wiseadvice.eu/" + echo " " + + cat $HOME/.ssh/deploy_key.pub + + echo " " + echo -n "ready to pull? type yes: " + read -r ready_to_pull + if [ "$ready_to_pull" = "yes" ]; then echo "preparing" cat <> $HOME/.ssh/config @@ -48,10 +50,14 @@ Host git.service.wiseadvice.eu EOT rm -rf $WA_REPO mkdir -p $WA_REPO + + echo "export CLIENT_NAME=$CLIENT_NAME" > $WA_REPO/export_client_name.sh + source $WA_REPO/export_client_name.sh + cd $WA_REPO echo "starting to pull into $(pwd)" git clone git@git.service.wiseadvice.eu:wiseadvice_apps/shared_resources_k8s.git - git clone git@git.service.wiseadvice.eu:wiseadvice_apps/cimp_etops_lgt.git + git clone git@git.service.wiseadvice.eu:wiseadvice_apps/cimp_$CLIENT_NAME.git git clone git@git.service.wiseadvice.eu:wiseadvice_apps/common_sysadmin.git ln -sf $WA_REPO/common_sysadmin/k8s $HOME/kubeconfs_common