From 5ea9128a28e4ff52425491e022576e9746fbb477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 29 Oct 2021 14:57:58 +0200 Subject: [PATCH] fix some small problems * change options for sshs * run sshs only when server is reachable * change echo to logging * fix loadagent to abort, when af is empty --- functions.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions.sh b/functions.sh index a0b0a89..e285075 100755 --- a/functions.sh +++ b/functions.sh @@ -346,6 +346,7 @@ EOF sshs() { ENTRY + local LOGLEVEL="WARN" # MKTMPCMD='mktemp $(echo ${XDG_RUNTIME_DIR}/bashrc.XXXXXXXX.conf)' # VIMMKTMPCMD="mktemp ${XDG_RUNTIME_DIR}/vimrc.XXXXXXXX.conf" @@ -363,9 +364,10 @@ sshs() { done fi logdebug "FILELIST: $FILELIST" - local SSH_OPTS="-o VisualHostKey=no -o ControlMaster=auto -o ControlPersist=15s -o ControlPath=~/.ssh/ssh-%C" + local SSH_OPTS="-o VisualHostKey=no -o ControlMaster=auto -o ControlPersist=2s -o ControlPath=~/.ssh/master-%C" #local SSH_OPTS="-o VisualHostKey=no -o ControlMaster=yes -o ControlPersist=10s -o ControlPath=~/.ssh/ssh-%C" # Read /etc/bashrc or /etc/bash.bashrc (depending on distribution) and /etc/profile.d/*.sh first + ssh -T ${SSH_OPTS} $@ "pwd" >/dev/null 2>/dev/null || { logerror "Server $@ not reachable -> exit"; return 1; } cat << EOF >> "${TMPBASHCONFIG}" [ -e /etc/bashrc ] && BASHRC=/etc/bashrc [ -e /etc/bash.bashrc ] && BASHRC=/etc/bash.bashrc @@ -490,7 +492,7 @@ vim-repair-vundle () { getbashrcfile () { ENTRY if [ -z ${BASHRC+x} ] ; then - echo "bash uses default" >&2 + loginfo "bash uses default" else cat /proc/$$/cmdline | xargs -0 echo|awk '{print $3}' fi @@ -500,7 +502,7 @@ getbashrcfile () { catbashrcfile () { ENTRY if [ -z ${BASHRC+x} ] ; then - echo "bash uses default" >&2 + loginfo "bash uses default" else #cat $(cat /proc/$$/cmdline | xargs -0 echo|awk '{print $3}') cat $(getbashrcfile) @@ -879,7 +881,7 @@ loadagent() { af=$(startagent --create-only $1 ) loginfo "Load agent from $af" unset SSH_AUTH_SOCKET SSH_AGENT_PID - eval $(<$af) + [ -n "${af+x}" ] && eval $(<$af) logdebug "SSH_AUTH_SOCK: ${SSH_AUTH_SOCK-not set}" logdebug "SSH_AGENT_PID: ${SSH_AGENT_PID-not set}" loginfo "currently loaded keys in agent: