diff --git a/bin/ssh-agent-start-or-restart b/bin/ssh-agent-start-or-restart index 421c333..569ddf8 100755 --- a/bin/ssh-agent-start-or-restart +++ b/bin/ssh-agent-start-or-restart @@ -3,9 +3,9 @@ [ -z "${SSH_IDENTITIES_DIR+x}" ] && { SSH_IDENTITIES_DIR="${SSH_IDENTITIES_DEFAULT_DIR-${HOME}/.ssh/identities}"; export SSH_IDENTITIES_DIR; } [ -z "${SSH_AGENTS_DIR+x}" ] && { SSH_AGENTS_DIR=${SSH_AGENTS_DEFAULT_DIR-~/.ssh/agents}; export SSH_AGENTS_DIR; } [ -z "${SSH_AGENT_SOCKETS_DIR+x}" ] && { SSH_AGENT_SOCKETS_DIR=${SSH_AGENT_SOCKETS_DEFAULT_DIR-~/.ssh/agents}; export SSH_AGENT_SOCKETS_DIR; } -echo SSH_AGENTS_DIR: $SSH_AGENTS_DIR >&2 -echo SSH_AGENT_SOCKETS_DIR: $SSH_AGENT_SOCKETS_DIR >&2 -echo SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR >&2 +logdebug SSH_AGENTS_DIR: $SSH_AGENTS_DIR >&2 +logdebug SSH_AGENT_SOCKETS_DIR: $SSH_AGENT_SOCKETS_DIR >&2 +logdebug SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR >&2 [ -z "${SSH_AGENTS_DIR-x}" ] || mkdir -vp "$SSH_AGENTS_DIR" [ -z "${SSH_AGENT_SOCKETS_DIR-x}" ] || mkdir -vp "$SSH_AGENT_SOCKETS_DIR" [ -z "${SSH_IDENTITIES_DIR-x}" ] || mkdir -vp "$SSH_IDENTITIES_DIR" @@ -19,9 +19,9 @@ agent-start-or-restart () { ssh_identity="$1" agentfile="${SSH_AGENTS_DIR}/agent-${ssh_identity}-$(hostname)" agentsocket="${SSH_AGENT_SOCKETS_DIR}/socket-${ssh_identity}-$(hostname)" - echo "agentfile: $agentfile" >&2 - echo "agentsocket: $agentsocket" >&2 - echo ssh-identität: $ssh_identity >&2 + logdebug "agentfile: $agentfile" >&2 + logdebug "agentsocket: $agentsocket" >&2 + logdebug ssh-identität: $ssh_identity >&2 if [ -e $agentfile ]; then # look if agent is reachable @@ -32,29 +32,29 @@ agent-start-or-restart () { /bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>&1; ssh-add -l >&2" case $? in 0|1) - echo "agent is running" >&2 + logdebug "agent is running" >&2 ;; 2) - echo "agent is not running 1" >&2 + logdebug "agent is not running 1" >&2 [ -e $agentsocket ] && rm "$agentsocket" ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile 2>&2 - echo "agent started" >&2 + logdebug "agent started" >&2 ;; esac else - echo "agent is not running 2" >&2 + logdebug "agent is not running 2" >&2 #rm "$agentsocket" - echo ssh-agent -a $agentsocket \> $agentfile + logdebug ssh-agent -a $agentsocket \> $agentfile ssh-agent -a $agentsocket $SSH_AGENT_OPTIONS > $agentfile 2>&2 - echo "agent started" >&2 + logdebug "agent started" >&2 fi - echo -n "agent for $ssh_identity: " >&2 + loginfo -n "agent for $ssh_identity: " >&2 echo $agentfile return 0 else - echo no identity given - exit >&2 + logwarn no identity given - exit >&2 return 1 fi @@ -77,29 +77,29 @@ agent-load-identity-keys () { [ -e "${identitydir}/.config" ] && . "${identitydir}/.config" agentfile="${SSH_AGENTS_DIR}/agent-${ssh_identity}-$(hostname)" agentsocket="${SSH_AGENT_SOCKETS_DIR}/socket-${ssh_identity}-$(hostname)" - echo "agentfile: $agentfile" >&2 - echo "agentsocket: $agentsocket" >&2 - echo ssh-identität: $ssh_identity >&2 + logdebug "agentfile: $agentfile" >&2 + logdebug "agentsocket: $agentsocket" >&2 + logdebug ssh-identität: $ssh_identity >&2 fingerprints=( $(ssh-runinagent $agentfile "ssh-add -l|awk '{print \$2}'") ) for key in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}|grep -v "pub$\|so$"); do - echo key: $key + logdebug key: $key fingerprint=$(ssh-keygen -l -f ~/.ssh/identities/bmi/id_ed25519|awk '{print $2}') - echo ${fingerprints[*]} and $fingerprint + logdebug ${fingerprints[*]} and $fingerprint if [[ ${fingerprints[*]} =~ "$fingerprint" ]]; then - echo "$key is loaded" >&2 + logdebug "$key is loaded" >&2 else - echo "$key is not loaded" >&2 + logdebug "$key is not loaded" >&2 ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${identitydir}/${key} fi done for token in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}|grep "so$"); do - echo token: $token + logdebug token: $token tokenfingerprint="$(ssh-keygen -l -D $token|tr -s ' '|awk '{print $2}')" if [[ ${fingerprints[*]} =~ "$tokenfingerprint" ]]; then - echo "$token is loaded" >&2 + logdebug "$token is loaded" >&2 else - echo "$token is not loaded" >&2 + logdebug "$token is not loaded" >&2 ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${identitydir}/${token} fi done @@ -114,12 +114,12 @@ ssh-runinagent () { shift sshcommand=${@} - echo "run command »$sshcommand« in agent $agentfile" >&2 + logdebug "run command »$sshcommand« in agent $agentfile" >&2 if [ -e "$agentfile" ]; then /bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>/dev/null; $sshcommand" return $? else - echo "agentfile not existent" >&2 + logwarn "agentfile not existent" >&2 return 1 fi } diff --git a/myshell_git_sync b/myshell_git_sync index 52dae83..2356749 100644 --- a/myshell_git_sync +++ b/myshell_git_sync @@ -89,7 +89,7 @@ if ! $SSHS; then if [ -d "${MYSHELLCONFIG_BASE}" -a $($SGIT status 1>/dev/null 2>&1; echo $?) -eq 0 ]; then [ -d "${MYSHELLCONFIG_LOGDIR}" ] || mkdir -p "${MYSHELLCONFIG_LOGDIR}" if ! $SGIT rev-parse --git-dir > /dev/null 2>&1 ; then - echo "Init ${MYSHELLCONFIG_BASE} as git-repo" >&2 + loginfo "Init ${MYSHELLCONFIG_BASE} as git-repo" >&2 $SGIT init fi @@ -102,29 +102,29 @@ if ! $SSHS; then # sync repo with origin if git is reachable if ckrepo ; then - echo "git checokut" >&2 + loginfo "git checokut" >&2 sync_config . ${MYSHELLCONFIG_BASE}/functions.sh create_symlinks "$MYSHELLCONFIG_BASE" else - echo "${MYSHELLCONFIG_GIT_SERVER}" not reachable >&2; - echo profile not syncing >&2; + loginfo "${MYSHELLCONFIG_GIT_SERVER}" not reachable >&2; + loginfo profile not syncing >&2; fi else - echo "Clone ${MYSHELLCONFIG_GIT_REMOTE} and configure git" >&2 + loginfo "Clone ${MYSHELLCONFIG_GIT_REMOTE} and configure git" >&2 if $( timeout --foreground "${MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT}" git -C ${HOME} clone "${MYSHELLCONFIG_GIT_REMOTE}" "${MYSHELLCONFIG_BASE}" ); then : else MYSHELLCONFIG_GIT_REMOTE="${MYSHELLCONFIG_GIT_REMOTE_PUBLIC_HTTP}${MYSHELLCONFIG_GIT_REPO_NAME}" - echo "Clone ${MYSHELLCONFIG_GIT_REMOTE} and configure git" >&2 + loginfo "Clone ${MYSHELLCONFIG_GIT_REMOTE} and configure git" >&2 timeout --foreground "${MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT}" git -C ${HOME} clone "${MYSHELLCONFIG_GIT_REMOTE}" "${MYSHELLCONFIG_BASE}" || return 1 2>/dev/null || exit 1 fi - [ -d "${MYSHELLCONFIG_BASE}" ] && { echo create ${MYSHELLCONFIG_LOGDIR} >&2; mkdir -p "${MYSHELLCONFIG_LOGDIR}"; } + [ -d "${MYSHELLCONFIG_BASE}" ] && { loginfo create ${MYSHELLCONFIG_LOGDIR} >&2; mkdir -p "${MYSHELLCONFIG_LOGDIR}"; } $SGIT config user.email "${USERNAME}" $SGIT config user.name "${FULLNAME}" @@ -133,10 +133,10 @@ if ! $SSHS; then #$SGIT submodule update --init --recursive #$SGIT submodule foreach 'git checkout master' - echo "sync config" >&2 + loginfo "sync config" >&2 sync_config . ${MYSHELLCONFIG_BASE}/functions.sh - echo "config synced, functions.sh sourced" >&2 + loginfo "config synced, functions.sh sourced" >&2 create_symlinks "$MYSHELLCONFIG_BASE" # Install vim Plugins @@ -146,13 +146,13 @@ if ! $SSHS; then [ -z ${MYSHELLCONFIG_GIT_REMOTE_PUSH+x} ] || $SGIT remote set-url --push ${MYSHELLCONFIG_GIT_REMOTE_NAME} "${MYSHELLCONFIG_GIT_REMOTE_PUSH}" ;; *screen*) - echo "I'm in sceen/tmux now" >&2 + loginfo "I'm in sceen/tmux now" >&2 ;; *dumb*) - echo "Run with dumb terminal" 1>&2 + loginfo "Run with dumb terminal" 1>&2 ;; *) - echo "Run with $TERM" >&2 + loginfo "Run with $TERM" >&2 ;; esac fi diff --git a/myshell_load_x2go_tokenforward b/myshell_load_x2go_tokenforward index 00748ee..f0b173e 100644 --- a/myshell_load_x2go_tokenforward +++ b/myshell_load_x2go_tokenforward @@ -14,10 +14,9 @@ if [ -n "$SSH_AUTH_SOCK" ] && \ chmod 600 ~/.x2go/agentsocket chown $USER ~/.x2go/agentsocket # write file name of agent socket into file - echo old agentsock - cat ~/.x2go/agentsocket + logdebug old agentsock $( cat ~/.x2go/agentsocket) echo $SSH_AUTH_SOCK > ~/.x2go/agentsocket - echo "write SSH_AUTH_SOCK (${SSH_AUTH_SOCK}) to ~/.x2go/agentsocket" + logdebug "write SSH_AUTH_SOCK (${SSH_AUTH_SOCK}) to ~/.x2go/agentsocket" fi # Part that runs in X2Go session @@ -39,11 +38,11 @@ if which x2golistsessions >/dev/null && \ # (might still contain stale agent socket or garbage MIGHTBEOURAGENT=$(cat ~/.x2go/agentsocket) # check if it corresponds to an existing socket - echo "MIGHTBEOURAGENT: $MIGHTBEOURAGENT" + logdebug "MIGHTBEOURAGENT: $MIGHTBEOURAGENT" if [ -S "$MIGHTBEOURAGENT" ]; then # export path to agent socket export SSH_AUTH_SOCK=$MIGHTBEOURAGENT - echo export it + logdebug export it fi fi