5
0
Fork 0

commit by to_remotes 2023-10-05 09:26:19 +0200 from vmdevac

main
ag 2023-10-05 09:26:19 +02:00
parent a483e9680e
commit 7d91d1c7ea
1 changed files with 41 additions and 2 deletions

43
init.sh
View File

@ -2,6 +2,9 @@
WA_REPO=$HOME/wa_repos WA_REPO=$HOME/wa_repos
echo "################################################" echo "################################################"
echo " basic init of wiseadvice node " echo " basic init of wiseadvice node "
echo "################################################" echo "################################################"
@ -34,6 +37,37 @@ function clone_repo_with_retry(){
fi fi
} }
function start_ssh_agent(){
SHORT_HOST="${HOSTNAME/.*/}"
ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
# Oh-my-zsh compatible bash ssh-agent start script
function _start_agent() {
if [[ -f "$ssh_env_cache" ]]; then
. "$ssh_env_cache" > /dev/null
fi
if [[ -S "$SSH_AUTH_SOCK" ]]; then
return 0
fi
echo "Starting ssh-agent ..."
ssh-agent -s | sed '/^echo/d' > "$ssh_env_cache"
chmod 600 "$ssh_env_cache"
. "$ssh_env_cache" > /dev/null
}
_start_agent
unset ssh_env_cache
unset -f _start_agent
ssh-add ~/.ssh/deploy_key
}
if [ -d "$WA_REPO" ]; then if [ -d "$WA_REPO" ]; then
echo "$WA_REPO does exist, skipping cloning" echo "$WA_REPO does exist, skipping cloning"
source $WA_REPO/export_client_name.sh source $WA_REPO/export_client_name.sh
@ -69,18 +103,23 @@ else
cat $HOME/.ssh/deploy_key.pub cat $HOME/.ssh/deploy_key.pub
fi fi
echo " " echo " "
echo -n "ready to pull? type yes: " echo -n "ready to pull? type yes: "
read -r ready_to_pull read -r ready_to_pull
if [ "$ready_to_pull" = "yes" ]; then if [ "$ready_to_pull" = "yes" ]; then
start_ssh_agent
echo "preparing" echo "preparing"
if grep "git.service.wiseadvice.eu" $HOME/.ssh/config > /dev/null
if grep -Fxq "git.service.wiseadvice.eu" $HOME/.ssh/config
then then
echo "ssh configuration already set" echo "ssh configuration already set"
else else
echo "set ssh configuration"
cat <<EOT >> $HOME/.ssh/config cat <<EOT >> $HOME/.ssh/config
Host git.service.wiseadvice.eu Host git.service.wiseadvice.eu
HostName git.service.wiseadvice.eu HostName git.service.wiseadvice.eu