diff --git a/README.md b/README.md index 46d4cf9..0f705a6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ **usage** -*init debian* +*guided installation* -bash <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/init_debian.sh) +bash <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/guided_setup.sh) -zsh <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/init.sh) \ No newline at end of file +*shortcut K8s* +zsh <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/initk8s.sh) \ No newline at end of file diff --git a/common_lib.sh b/common_lib.sh new file mode 100644 index 0000000..fbb5a39 --- /dev/null +++ b/common_lib.sh @@ -0,0 +1,91 @@ +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 + + 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" + + 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 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 " " + + 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 + + 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 common_sysadmin + + if [ "$TASK_PERFORMING" = "k8s_setup" ]; then + clone_repo_with_retry shared_resources_k8s + 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 + fi + echo "source .zshrc after pull" + echo "change default SHELL of user sysadmin:" + chsh -s /usr/bin/zsh + source $HOME/.zshrc + else + echo "Aborting" + exit 0 + fi + fi +} \ No newline at end of file diff --git a/guided_setup.sh b/guided_setup.sh new file mode 100644 index 0000000..658bc50 --- /dev/null +++ b/guided_setup.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash + +sudo apt install -y lvm2 zsh cloud-utils xfsprogs jq hstr ufw +zsh +source <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/common_lib.sh) + +mainmenu() { + echo -ne " +MAIN MENU +1) Install K8s +2) Install NFS Server +0) Exit +Choose an option: " + read -r ans + case $ans in + 1) + echo "<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>" + echo "initializing K8s Master Set-Up" + source <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/initk8s.sh) + ;; + 2) + echo "<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>" + echo "initializing K8s Worker Set-Up" + source <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/init_nfs_server.sh) + ;; + 0) + echo "Bye bye." + exit 0 + ;; + *) + echo "Wrong option." + mainmenu + ;; + esac +} + +init_repos +mainmenu + + + diff --git a/init_debian.sh b/init_debian.sh deleted file mode 100644 index c9b6cdb..0000000 --- a/init_debian.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/bash - -source <(curl -sk https://git.service.wiseadvice.eu/wiseadvice_public_repos/wa_public_init_repo/raw/branch/main/init_base.sh) diff --git a/init_nfs_server.sh b/init_nfs_server.sh new file mode 100644 index 0000000..dd71fb2 --- /dev/null +++ b/init_nfs_server.sh @@ -0,0 +1,9 @@ +#!/usr/bin/zsh +WA_REPO=$HOME/wa_repos +TASK_PERFORMING=nfs_server_setup + +sudo apt install nfs-kernel-server rpcbind -y +PNFS=/vgnfs/lvdata +# mkdir -p c + +chown nobody:nogroup $PNFS \ No newline at end of file diff --git a/init.sh b/initk8s.sh similarity index 99% rename from init.sh rename to initk8s.sh index caa0e98..b971f42 100755 --- a/init.sh +++ b/initk8s.sh @@ -1,6 +1,6 @@ #!/usr/bin/zsh WA_REPO=$HOME/wa_repos - +TASK_PERFORMING=k8s_setup echo "################################################" echo " basic init of wiseadvice node "