From 5430354d55a0cfe04a66db2aba1cd3c50bbd62a1 Mon Sep 17 00:00:00 2001 From: ag Date: Mon, 29 Apr 2024 11:51:36 +0200 Subject: [PATCH 1/6] commit by to_remotes 2024-04-29 11:51:36 +0200 from vmdevac --- init.sh | 151 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 81 insertions(+), 70 deletions(-) diff --git a/init.sh b/init.sh index 36835ba..1826e0c 100755 --- a/init.sh +++ b/init.sh @@ -2,9 +2,6 @@ WA_REPO=$HOME/wa_repos - - - echo "################################################" echo " basic init of wiseadvice node " echo "################################################" @@ -68,97 +65,105 @@ function start_ssh_agent(){ -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" - source $HOME/.zshrc - git_pull -else - echo -n "client name: " - read -r CLIENT_NAME - - if [ ! -f $HOME/.ssh/deploy_key ]; then - - 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" +function init_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" + source $HOME/.zshrc + git_pull + else + echo -n "client name: " + read -r CLIENT_NAME - mkdir -p $HOME/.ssh + if [ ! -f $HOME/.ssh/deploy_key ]; then - ssh-keygen -t rsa -N "$passphrase" -C "deploy_key_$CLIENT_NAME" -f $HOME/.ssh/deploy_key + echo "create ssh key" + echo -n "ssh passphrase: " - echo "please upload now pub key bay logging into user $CLIENT_NAME keys ..." - - echo "firefox https://git.service.wiseadvice.eu/user/settings/keys" - echo " " - - cat $HOME/.ssh/deploy_key.pub - fi + 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" - echo " " - echo -n "ready to pull? type yes: " - read -r ready_to_pull + mkdir -p $HOME/.ssh + ssh-keygen -t rsa -N "$passphrase" -C "deploy_key_$CLIENT_NAME" -f $HOME/.ssh/deploy_key - if [ "$ready_to_pull" = "yes" ]; then - start_ssh_agent + echo "please upload now pub key by logging into user $CLIENT_NAME keys ..." + echo "if user does not exit. login with admin user and create new user with name: $CLIENT_NAME" - echo "preparing" + echo "https://git.service.wiseadvice.eu/user/settings/keys" + echo " " - if grep "git.service.wiseadvice.eu" $HOME/.ssh/config > /dev/null - then - echo "ssh configuration already set" - else - echo "set ssh configuration" - cat <> $HOME/.ssh/config -Host git.service.wiseadvice.eu - HostName git.service.wiseadvice.eu - IdentityFile ~/.ssh/deploy_key - Port 8422 - IdentitiesOnly yes -EOT + cat $HOME/.ssh/deploy_key.pub fi - - 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 - clone_repo_with_retry cimp_$CLIENT_NAME - clone_repo_with_retry shared_resources_k8s - clone_repo_with_retry common_sysadmin - ln -sf $WA_REPO/common_sysadmin/k8s $HOME/kubeconfs_common - ln -sf $WA_REPO/shared_resources_k8s/k8s $HOME/kubeconfs_common - ln -sf $WA_REPO/shared_resources_k8s/manifest.sh $HOME/.zshrc - ln -sf $WA_REPO/cimp_$CLIENT_NAME/k8s $HOME/kubeconfs + echo " " + echo -n "ready to pull? type yes: " + read -r ready_to_pull - echo "source .zshrc after pull" - source $HOME/.zshrc - else - echo "Aborting" - exit 0 + + if [ "$ready_to_pull" = "yes" ]; then + start_ssh_agent + + echo "preparing" + + if grep "git.service.wiseadvice.eu" $HOME/.ssh/config > /dev/null + then + echo "ssh configuration already set" + else + echo "set ssh configuration" + cat <> $HOME/.ssh/config + Host git.service.wiseadvice.eu + HostName git.service.wiseadvice.eu + IdentityFile ~/.ssh/deploy_key + Port 8422 + IdentitiesOnly yes +EOT + fi + + + 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 + clone_repo_with_retry cimp_$CLIENT_NAME + clone_repo_with_retry shared_resources_k8s + clone_repo_with_retry common_sysadmin + + + ln -sf $WA_REPO/common_sysadmin/k8s $HOME/kubeconfs_common + ln -sf $WA_REPO/shared_resources_k8s/k8s $HOME/kubeconfs_common + ln -sf $WA_REPO/shared_resources_k8s/manifest.sh $HOME/.zshrc + ln -sf $WA_REPO/cimp_$CLIENT_NAME/k8s $HOME/kubeconfs + + echo "source .zshrc after pull" + source $HOME/.zshrc + else + echo "Aborting" + exit 0 + fi fi -fi +} + + mainmenu() { echo -ne " MAIN MENU 1) Init Master 2) Join Worker +3) Reset Repos and start over again 0) Exit Choose an option: " read -r ans @@ -173,6 +178,11 @@ Choose an option: " echo "initializing K8s Worker Set-Up" source $WA_REPO/shared_resources_k8s/k8s/init_worker.sh ;; + 3) + rm -rf $HOME/wa_repos + init_repos + mainmenu + ;; 0) echo "Bye bye." exit 0 @@ -184,4 +194,5 @@ Choose an option: " esac } +init_repos mainmenu From 957ab3b22d795344af6f3cdaa810bcff75098dbf Mon Sep 17 00:00:00 2001 From: ag Date: Mon, 29 Apr 2024 12:03:04 +0200 Subject: [PATCH 2/6] commit by to_remotes 2024-04-29 12:03:04 +0200 from vmdevac --- init.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init.sh b/init.sh index 1826e0c..3a58db8 100755 --- a/init.sh +++ b/init.sh @@ -68,6 +68,9 @@ function start_ssh_agent(){ function init_repos(){ + + + if [ -d "$WA_REPO" ]; then echo "$WA_REPO does exist, skipping cloning" source $WA_REPO/export_client_name.sh @@ -97,6 +100,8 @@ function init_repos(){ echo "please upload now pub key by logging into user $CLIENT_NAME keys ..." echo "if user does not exit. login with admin user and create new user with name: $CLIENT_NAME" + echo "make sure the user $CLIENT_NAME is in team shared_deployments and is allowed to pull repository cimp_$CLIENT_NAME" + echo "https://git.service.wiseadvice.eu/user/settings/keys" echo " " From 010c2884ee95c92cd715c716d28bd1e18f0dc6be Mon Sep 17 00:00:00 2001 From: ag Date: Mon, 29 Apr 2024 12:11:21 +0200 Subject: [PATCH 3/6] commit by to_remotes 2024-04-29 12:11:21 +0200 from vmdevac --- init.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/init.sh b/init.sh index 3a58db8..a82e5fe 100755 --- a/init.sh +++ b/init.sh @@ -153,6 +153,7 @@ EOT ln -sf $WA_REPO/cimp_$CLIENT_NAME/k8s $HOME/kubeconfs echo "source .zshrc after pull" + chsh -s /usr/bin/zsh source $HOME/.zshrc else echo "Aborting" From a11d2c1f2af4b2dee18095fc0d7df2a61f20f5cb Mon Sep 17 00:00:00 2001 From: ag Date: Mon, 29 Apr 2024 12:24:38 +0200 Subject: [PATCH 4/6] commit by to_remotes 2024-04-29 12:24:38 +0200 from vmdevac --- init.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.sh b/init.sh index a82e5fe..659cb03 100755 --- a/init.sh +++ b/init.sh @@ -153,6 +153,7 @@ EOT ln -sf $WA_REPO/cimp_$CLIENT_NAME/k8s $HOME/kubeconfs echo "source .zshrc after pull" + echo "change default SHELL of user sysadmin:" chsh -s /usr/bin/zsh source $HOME/.zshrc else @@ -186,8 +187,7 @@ Choose an option: " ;; 3) rm -rf $HOME/wa_repos - init_repos - mainmenu + kubeadm_reset ;; 0) echo "Bye bye." From 3cc29cba808036bdad6126938e8a6d3ccfa3a7be Mon Sep 17 00:00:00 2001 From: ag Date: Mon, 29 Apr 2024 12:28:15 +0200 Subject: [PATCH 5/6] commit by to_remotes 2024-04-29 12:28:15 +0200 from vmdevac --- init.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/init.sh b/init.sh index 659cb03..4bf960d 100755 --- a/init.sh +++ b/init.sh @@ -68,9 +68,6 @@ function start_ssh_agent(){ function init_repos(){ - - - if [ -d "$WA_REPO" ]; then echo "$WA_REPO does exist, skipping cloning" source $WA_REPO/export_client_name.sh @@ -170,7 +167,7 @@ mainmenu() { MAIN MENU 1) Init Master 2) Join Worker -3) Reset Repos and start over again +3) Reset Cluster and start over again 0) Exit Choose an option: " read -r ans @@ -186,7 +183,6 @@ Choose an option: " source $WA_REPO/shared_resources_k8s/k8s/init_worker.sh ;; 3) - rm -rf $HOME/wa_repos kubeadm_reset ;; 0) From 9df400092e354247ba2fc3c7e6d585b3fd425037 Mon Sep 17 00:00:00 2001 From: ag Date: Mon, 29 Apr 2024 12:45:06 +0200 Subject: [PATCH 6/6] commit by to_remotes 2024-04-29 12:45:06 +0200 from vmdevac --- init.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.sh b/init.sh index 4bf960d..caa0e98 100755 --- a/init.sh +++ b/init.sh @@ -68,11 +68,13 @@ function start_ssh_agent(){ function init_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" source $HOME/.zshrc + git_pull else echo -n "client name: " @@ -106,13 +108,10 @@ function init_repos(){ cat $HOME/.ssh/deploy_key.pub fi - - echo " " echo -n "ready to pull? type yes: " read -r ready_to_pull - if [ "$ready_to_pull" = "yes" ]; then start_ssh_agent