From 81c588b5e4cbcdeef5e74c30a792a0ca7f28aad9 Mon Sep 17 00:00:00 2001 From: Kevin Baensch Date: Thu, 17 Nov 2022 15:27:51 +0100 Subject: [PATCH] sqlproxy setup: use Project Path instead of relative paths --- sqlproxy_setup.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sqlproxy_setup.sh b/sqlproxy_setup.sh index f69bace..1b34ba7 100755 --- a/sqlproxy_setup.sh +++ b/sqlproxy_setup.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash +PROJECT_PATH=$(realpath $(dirname $0)) which myssh > /dev/null 2>&1 if [ $? -eq 1 ] then mkdir -p $HOME/bin - cp ./script/myssh $HOME/bin/myssh + cp $PROJECT_PATH/script/myssh $HOME/bin/myssh if [[ ! $PATH =~ $HOME/bin ]] then if [[ $SHELL =~ bin/bash$ ]] @@ -17,10 +18,10 @@ then fi fi -if [ ! -f ./etc/ssh/ssh_host_ed25519_key ] +if [ ! -f $PROJECT_PATH/etc/ssh/ssh_host_ed25519_key ] then echo "Generating sqlproxy SSHD keys" - ssh-keygen -f ./ -A + ssh-keygen -f $PROJECT_PATH -A fi read -r -p "Auto generate client keys+config? [Y/n] " GEN_KEYS @@ -31,7 +32,6 @@ case $GEN_KEYS in ssh-keygen -t ed25519 -f ~/.ssh/$KEY_NAME.key -C "$(date --iso-8601)_$(whoami)@$HOST" read -r -p "Target Host: " HOST_NAME echo -ne "\n\nHost $HOST_NAME\n User sqlproxy\n IdentityFile ~/.ssh/$KEY_NAME.key" >> ~/.ssh/config - echo -e command=\"/sqlproxy_cli.sh\" $(cat ~/.ssh/$KEY_NAME.key.pub) >> ./etc/ssh/.ssh/authorized_keys - break;; - *) echo -e "Not generating client ssh key.\nPlease put your desired public keys into ./etc/ssh/.ssh/authorized_keys\nAlso add 'command=\"/sqlproxy_cli.sh\" ' in front of your key";; + echo -e command=\"/sqlproxy_cli.sh\" $(cat ~/.ssh/$KEY_NAME.key.pub) >> $PROJECT_PATH/etc/ssh/.ssh/authorized_keys;; + *) echo -e "Not generating client ssh key.\nPlease put your desired public keys into $PROJECT_PATH/etc/ssh/.ssh/authorized_keys\nAlso add 'command=\"/sqlproxy_cli.sh\" ' in front of your key";; esac