From a77753bc237bf7cf91ff25bb54dfea99d04232b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Wed, 28 Sep 2022 09:53:50 +0200 Subject: [PATCH 01/11] neues setup --- tmux/sessions/dev.session | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tmux/sessions/dev.session b/tmux/sessions/dev.session index fa18a40..7c76895 100644 --- a/tmux/sessions/dev.session +++ b/tmux/sessions/dev.session @@ -1,7 +1,6 @@ selectp -t 1 # select the first (0) pane splitw -h -p 50 # split it into two halves - selectp -t 2 # select the new, second (1) pane splitw -v -p 50 # split it into two halves selectp -t 1 # go back to the first pane - +set-environment -u sshcon From 29e8ad1fc5077b9b48f7fd49dc19a255df31d5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 13 Oct 2022 16:20:26 +0200 Subject: [PATCH 02/11] change function to check reachable git remote --- bashrc_add | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bashrc_add b/bashrc_add index 4e43215..74fd29c 100755 --- a/bashrc_add +++ b/bashrc_add @@ -95,8 +95,10 @@ EOF -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") ]; then logwarning "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) reached" logwarning "check if reachable" - git ls-remote - if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then +# git ls-remote +# if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then +# git fetch --dry-run --verbose + if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT fetch --dry-run >/dev/null 2>&1) ;then logwarning "reachable" return 0 else From ebe4f43c176458cbf8d6c17783ff2faf112cd349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 21 Oct 2022 10:49:02 +0200 Subject: [PATCH 03/11] change variable-name --- myshell_git_sync | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/myshell_git_sync b/myshell_git_sync index 3a210c5..62ad427 100644 --- a/myshell_git_sync +++ b/myshell_git_sync @@ -88,19 +88,19 @@ if ! $SSHS; then #*term*|*linux*) *term*) - if [ -d "${MSC_BASE}" -a $($SGIT status 1>/dev/null 2>&1; echo $?) -eq 0 ]; then + if [ -d "${MSC_BASE}" -a $($MSC_GIT status 1>/dev/null 2>&1; echo $?) -eq 0 ]; then [ -d "${MSC_LOGDIR}" ] || mkdir -p "${MSC_LOGDIR}" - if ! $SGIT rev-parse --git-dir > /dev/null 2>&1 ; then + if ! $MSC_GIT rev-parse --git-dir > /dev/null 2>&1 ; then loginfo "Init ${MSC_BASE} as git-repo" >&2 - $SGIT init + $MSC_GIT init fi # Update Userinformations for git - $SGIT config user.email "${USERNAME}" - $SGIT config user.name "${FULLNAME}" + $MSC_GIT config user.email "${USERNAME}" + $MSC_GIT config user.name "${FULLNAME}" # set upstream only if not detached - [ $($SGIT rev-parse --abbrev-ref HEAD) != "HEAD" ] && $SGIT branch --set-upstream-to=${MSC_GIT_REMOTE_NAME}/$($SGIT rev-parse --abbrev-ref HEAD) + [ $($MSC_GIT rev-parse --abbrev-ref HEAD) != "HEAD" ] && $MSC_GIT branch --set-upstream-to=${MSC_GIT_REMOTE_NAME}/$($MSC_GIT rev-parse --abbrev-ref HEAD) # sync repo with origin if git is reachable if ckrepo ; then @@ -130,12 +130,12 @@ if ! $SSHS; then [ -d "${MSC_BASE}" ] && { loginfo create ${MSC_LOGDIR} >&2; mkdir -p "${MSC_LOGDIR}"; } - $SGIT config user.email "${USERNAME}" - $SGIT config user.name "${FULLNAME}" + $MSC_GIT config user.email "${USERNAME}" + $MSC_GIT config user.name "${FULLNAME}" # Initialize Vundle as preconfigured Submodule - #$SGIT submodule update --init --recursive - #$SGIT submodule foreach 'git checkout master' + #$MSC_GIT submodule update --init --recursive + #$MSC_GIT submodule foreach 'git checkout master' loginfo "sync config" >&2 sync_config @@ -148,7 +148,7 @@ if ! $SSHS; then # not necessary any more. Vim plugins are updated through git submodules #vim -c "PluginInstall" -c ":qa!" fi - [ -z ${MSC_GIT_REMOTE_PUSH+x} ] || $SGIT remote set-url --push ${MSC_GIT_REMOTE_NAME} "${MSC_GIT_REMOTE_PUSH}" + [ -z ${MSC_GIT_REMOTE_PUSH+x} ] || $MSC_GIT remote set-url --push ${MSC_GIT_REMOTE_NAME} "${MSC_GIT_REMOTE_PUSH}" ;; *screen*) loginfo "I'm in sceen/tmux now - no profily syncing" >&2 From 67b1c1bdaf16700620b0e7be9ef064b3231b325c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 21 Oct 2022 10:49:35 +0200 Subject: [PATCH 04/11] change variable-name and login --- functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions.sh b/functions.sh index aff074e..59584da 100755 --- a/functions.sh +++ b/functions.sh @@ -84,7 +84,7 @@ create_symlinks() { ln -sf "${MSC_BASE}/tmux/tmux.conf" ~/.tmux.conf # Configure to use githooks in .githooks, not in standardlocation .git/hooks - $SGIT config core.hooksPath .githooks + $MSC_GIT config core.hooksPath .githooks # remove all old symlinks in .githooks and relink files from .githooks to .git/hooks # don't know, why i do it here. TODO: Check it find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \; @@ -669,7 +669,7 @@ function checkbkp() { ENTRY if ping -c 3 backup.vpn >/dev/null 2>&1 ; then local SSH="/usr/bin/ssh" - local CMD="$SSH -T backup.vpn" + local CMD="$SSH -T root@backup.vpn" $CMD /bin/bash << EOF sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1|grep -v -e "git$\|git-backup-repos"|while read i;do printf "%-30s%s\\n" "\$i" \$(ls \$i|tail -n1);done|sort -k 2.1 -r EOF @@ -684,7 +684,7 @@ function checkbkp-full() { ENTRY if ping -c 3 backup.vpn >/dev/null 2>&1 ; then local SSH="/usr/bin/ssh" - local CMD="$SSH -T backup.vpn" + local CMD="$SSH -T root@backup.vpn" $CMD /bin/bash << EOF sudo find /srv/nfs/backup -mindepth 1 -maxdepth 1|grep -v -e "git$\|git-backup-repos"|while read i;do printf "%-30s%s\\n" "\$i" \$(ls \$i|tail -n1);done|sort -k 2.1 -r EOF From df804c318b4328fac218564150d02ded341a76f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 21 Oct 2022 10:50:14 +0200 Subject: [PATCH 05/11] change variable-name --- bin/git-myshellconfig-checkout | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index fec633d..f5c397c 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -11,7 +11,7 @@ # notes : # ################################################################################################# -[ -z "${SGIT+x}" ] && SGIT=git +[ -z "${MSC_GIT+x}" ] && MSC_GIT=git [ -z "${MSC_LOGDIR+x}" ] && export MSC_LOGDIR="${HOME}/logs" [ -z "${MSC_LOGFILE+x}" ] && export MSC_LOGFILE="${MSC_LOGDIR}/myshellconfig.log" #MSC_LOGDIR="./logs" @@ -88,23 +88,23 @@ if [ $(stat --printf %Y ${MSC_GIT_UPD_SUBMOD_STATFILE} 2>/dev/null || echo 0 ) [ -z "${dosubmodupdate+x}" ] && dosubmodupdate="true" fi -#echo $SGIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2 +#echo $MSC_GIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2 if $dorepoupdate; then loginfo "fetch repo${dosubmodupdate:+ and submodules}" - #$SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; } - $SGIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; } + #$MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; } + $MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; } if ${dosubmodupdate:-false}; then lastupdatesubmodules fi echo "Check for local changes:" >> "${MSC_LOGFILE}" - if $SGIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then + if $MSC_GIT diff-index --ignore-submodules --exit-code HEAD -- >> "${MSC_LOGFILE}" ; then cat << EOF >> "${MSC_LOGFILE}" no changes in local repo - $SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} + $MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} EOF - $SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; } - $SGIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; } + $MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; } + $MSC_GIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; } touch $MSC_GIT_UPD_REPO_STATFILE else logwarning -n " Lokale Änderungen festgestellt:" @@ -112,17 +112,17 @@ EOF cat << EOF >> "${MSC_LOGFILE}" um die Änderung zurückzusetzen bitte - $SGIT checkout \$FILENAME + $MSC_GIT checkout \$FILENAME oder um alle lokalen Änderungen auf einmal zurückzusetzen: - $SGIT checkout . + $MSC_GIT checkout . ausführen Die Änderungen sind: - $($SGIT diff-index HEAD --|awk '{print $5, $6}') - $($SGIT diff-index -p HEAD --) + $($MSC_GIT diff-index HEAD --|awk '{print $5, $6}') + $($MSC_GIT diff-index -p HEAD --) EOF gitupdateend @@ -134,8 +134,8 @@ EOF if ${dosubmodupdate:-false}; then loginfo "update and commit submodules" - logdebug "$($SGIT submodule update --remote)" - logdebug "$($SGIT commit -a -m 'update submodules')" + logdebug "$($MSC_GIT submodule update --remote)" + logdebug "$($MSC_GIT commit -a -m 'update submodules')" touch $MSC_GIT_UPD_SUBMOD_STATFILE logwarning "submodules synced" fi From 9f2be861520432fb82829c2f4d108072f0795e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 21 Oct 2022 10:50:39 +0200 Subject: [PATCH 06/11] change variable-name and logging --- bashrc_add | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bashrc_add b/bashrc_add index 74fd29c..0d05451 100755 --- a/bashrc_add +++ b/bashrc_add @@ -49,7 +49,7 @@ if [[ $- = *i* ]] ; then [ -z "${MSC_GIT_SYNC+x}" ] && export MSC_GIT_SYNC=true # hardcoded git - export SGIT="git -C ${MSC_BASE}" + export MSC_GIT="git -C ${MSC_BASE}" @@ -94,15 +94,15 @@ EOF if [ $(stat --printf %Y ${MSC_GIT_UPD_REPO_STATFILE} 2>/dev/null || echo 0 ) \ -lt $(date --date="${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours ago" "+%s") ]; then logwarning "sync-intervall (${MSC_GIT_REPO_UPDATE_INTERVALL-${MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT}} hours) reached" - logwarning "check if reachable" + loginfo "check if remote »$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1)« is reachable" # git ls-remote -# if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT ls-remote >/dev/null 2>&1) ;then +# if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $MSC_GIT ls-remote >/dev/null 2>&1) ;then # git fetch --dry-run --verbose - if $( timeout --foreground "${MSC_GIT_TIMEOUT-$MSC_GIT_TIMEOUT_DEFAULT}" $SGIT fetch --dry-run >/dev/null 2>&1) ;then - logwarning "reachable" + if $MSC_GIT fetch --dry-run >/dev/null 2>&1 ;then + loginfo "reachable" return 0 else - logwarning "not reachable" + logwarning "$($MSC_GIT rev-parse --abbrev-ref @{u} 2>/dev/null | cut -d'/' -f1) not reachable" return 3 fi else From 6dbd379916568adade044fa60b8e7dcb61c937ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 11 Oct 2022 14:27:00 +0200 Subject: [PATCH 07/11] change urls from submodules --- .gitmodules | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 891805b..db31e59 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ [submodule "tmux/plugins/tpm"] path = tmux/plugins/tpm - url = git://git.schuerz.at/github.com/tmux-plugins/tpm.git + url = https://github.com/tmux-plugins/tpm.git [submodule "tmux/plugins/tmux-sensible"] path = tmux/plugins/tmux-sensible - url = git://git.schuerz.at/github.com/tmux-plugins/tmux-sensible.git + url = https://github.com/tmux-plugins/tmux-sensible.git [submodule "tmux/plugins/tmux-themepack"] path = tmux/plugins/tmux-themepack - url = git://git.schuerz.at/github.com/jimeh/tmux-themepack.git + url = https://github.com/jimeh/tmux-themepack.git [submodule "vim/pack/color/start/Zenburn"] path = vim/pack/color/start/Zenburn url = https://github.com/vim-scripts/Zenburn.git @@ -60,4 +60,4 @@ url = https://github.com/jamessan/vim-gnupg [submodule "vim/pack/plugins/start/vim-soa"] path = vim/pack/plugins/start/vim-soa - url = https://git.schuerz.at/public/vim-soa.git + url = https://gitea.schuerz.at/jakob/vim-soa.git From e78a781638d90c5a52efe9647a9edd022a3ccfa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 11 Oct 2022 14:41:40 +0200 Subject: [PATCH 08/11] change to vim-soa url codeberg.org --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index db31e59..bc1c951 100644 --- a/.gitmodules +++ b/.gitmodules @@ -60,4 +60,4 @@ url = https://github.com/jamessan/vim-gnupg [submodule "vim/pack/plugins/start/vim-soa"] path = vim/pack/plugins/start/vim-soa - url = https://gitea.schuerz.at/jakob/vim-soa.git + url = https://codeberg.org/xundeenergie/vim-soa.git From 9491f9f017246c2f2a5076b11702c89a52b55afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 11 Oct 2022 14:50:18 +0200 Subject: [PATCH 09/11] change function-names from xx-xx to xx_xx --- bin/startagent | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/bin/startagent b/bin/startagent index 2859587..2cd0a47 100755 --- a/bin/startagent +++ b/bin/startagent @@ -1,13 +1,14 @@ #!/bin/bash FILELOGLEVEL=DEBUG +. $(dirname $0)/../logging # loggerfactory LANG=C usage(){ cat << EOF - Usage: ssh-agent-start-or-restart [[-c]|[--create-only]]|[[-t]|[--token-only]]|[[-k]|[--key-only]]|[[-r]|[-f]|[--readd]|[--force]] [] + Usage: $(basename $0) [[-c]|[--create-only]]|[[-t]|[--token-only]]|[[-k]|[--key-only]]|[[-r]|[-f]|[--readd]|[--force]] [] If started only with , the script looks up in configured identity-path \$SSH_IDENTITIES_DIR (${SSH_IDENTITIES_DIR}) if it can find a directory named after . If no is given, the identity is set to \$SSH_DEFAULT_IDENTITY ($SSH_DEFAULT_IDENTITY) configured via Environment. @@ -121,7 +122,7 @@ logtrace " SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR" [ -z "${SSH_IDENTITIES_DIR-x}" ] || mkdir -vp "$SSH_IDENTITIES_DIR" -agent-start-or-restart () { +agent_start_or_restart () { # If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work # So remember and unset DISPLAY, and set it at the end again, if it was set before @@ -146,7 +147,7 @@ agent-start-or-restart () { logtrace "agentsocket for ${ssh_identity}: $agentsocket" if (! $keyonly && ! $tokenonly ) && $remove ; then logdebug "delete keys and tokens in this ssh-agent" - logdebug "$(ssh-runinagent $agentfile ssh-add -D 2>&1)" + logdebug "$(ssh_runinagent $agentfile ssh-add -D 2>&1)" createonly=true else @@ -183,7 +184,7 @@ agent-start-or-restart () { #logdebug "ssh-agent for identity »$ssh_identity«: $agentfile" $createonly && logtrace "current loaded keys after action: -$(ssh-runinagent $agentfile ssh-add -l)" +$(ssh_runinagent $agentfile ssh-add -l)" echo $agentfile ret=0 else @@ -201,7 +202,7 @@ $(ssh-runinagent $agentfile ssh-add -l)" logdebug "$(cat $agentfile)" logdebug "ssh-agent for identity »$ssh_identity«: $agentfile" # logdebug "currently loaded keys after action: -#$(ssh-runinagent $agentfile ssh-add -l)" +#$(ssh_runinagent $agentfile ssh-add -l)" echo $agentfile ret=0 else @@ -217,7 +218,7 @@ $(ssh-runinagent $agentfile ssh-add -l)" } -agent-load-identity-keys () { +agent_load_identity_keys () { # If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work # So remember and unset DISPLAY, and set it at the end again, if it was set before @@ -247,7 +248,7 @@ agent-load-identity-keys () { logtrace "agentsocket: $agentsocket" logtrace "identitydir: $identitydir" - fingerprints=( $(ssh-runinagent $agentfile "ssh-add -l|awk '{print \$2}'") ) + fingerprints=( $(ssh_runinagent $agentfile "ssh-add -l|awk '{print \$2}'") ) logdebug "fingerprints from loaded keys before action:" for f in ${fingerprints[*]};do logdebug "$f" @@ -261,13 +262,13 @@ agent-load-identity-keys () { if $readd || $remove ; then $readd && logdebug "re-add key $key" $remove && logdebug "remove key $key" - logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)" - $remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)" + logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)" + $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)" fi else logdebug "key: $key is not loaded -> load it" - #logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)" - $remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)" + #logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)" + $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)" fi done fi @@ -308,24 +309,24 @@ agent-load-identity-keys () { if [[ ${fingerprints[*]} =~ "$tokenfingerprint" ]]; then logdebug "token: $key ($tokenfingerprint) is loaded" - check-pubkeysonly + check_pubkeysonly if $readd || $remove ; then $readd && logdebug "re-add token $key" $remove && logdebug "remove token $key" echo agentfile1 $agentfile \$SSH_ADD_OPTIONS $key >&2 - logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -e "${key}" 2>&1)" - ssh-runinagent $agentfile echo $SSH_AUTH_SOCK >&2 - $remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s "${key}" 2>&1)" + logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -e "${key}" 2>&1)" + ssh_runinagent $agentfile echo $SSH_AUTH_SOCK >&2 + $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s "${key}" 2>&1)" fi else logdebug "token: $key is not loaded -> load it" - logdebug "$(ssh-runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)" - $remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)" + logdebug "$(ssh_runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)" + $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)" fi done fi - loginfo "currently loaded keys after action: $(ssh-runinagent $agentfile ssh-add -l|wc -l)" - logdebug "$(ssh-runinagent $agentfile ssh-add -l)" + loginfo "currently loaded keys after action: $(ssh_runinagent $agentfile ssh-add -l|wc -l)" + logdebug "$(ssh_runinagent $agentfile ssh-add -l)" else logwarning "ssh-identity $ssh_identity is not configured. Please create $identitydir and add keys" fi @@ -336,10 +337,10 @@ agent-load-identity-keys () { } -function check-pubkeysonly () { +function check_pubkeysonly () { if [ ${#pubkeysonly[*]} -gt 0 ] ; then for p in ${pubkeysonly[@]}; do - ssh-runinagent $agentfile ssh-add -T ${p} 2>&1 || { $remove || readd=true; break; } + ssh_runinagent $agentfile ssh-add -T ${p} 2>&1 || { $remove || readd=true; break; } done else logwarning "obviously there is no pubkey for the token in ${SSH_IDENTITIES_DIR}/${ssh_identity}/" @@ -352,7 +353,7 @@ function check-pubkeysonly () { logdebug "readd: $readd" } -ssh-runinagent () { +ssh_runinagent () { local agentfile @@ -375,13 +376,13 @@ ssh-runinagent () { } if [[ $SSH_TTY || $X2GO_SESSION ]] ; then - logdebug "run with forwarded ssh-agent" + logdebug "Shell running with forwarded ssh-agent. Please add local token manually" check_token res=1 else logdebug "run with local ssh-agent" - agent-start-or-restart $ssh_identity - ! $createonly && agent-load-identity-keys $ssh_identity + agent_start_or_restart $ssh_identity + ! $createonly && agent_load_identity_keys $ssh_identity res=0 fi SCRIPTEXIT From 2ab30111e9976cab2a638583585798e9e7101879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Tue, 11 Oct 2022 14:50:49 +0200 Subject: [PATCH 10/11] add submodule handling --- bin/git-myshellconfig-checkout | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index f5c397c..a84e9de 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -90,6 +90,8 @@ fi #echo $MSC_GIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2 if $dorepoupdate; then + loginfo "git submodule sync" + logdebug "$(git submodule sync 2>&1)" loginfo "fetch repo${dosubmodupdate:+ and submodules}" #$MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; } $MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; } @@ -103,8 +105,11 @@ if $dorepoupdate; then no changes in local repo $MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} EOF - $MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; } - $MSC_GIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; } + $SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; } + $SGIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; } + if ${dosubmodupdate:+false}; then + $SGIT submodule update --init --recursive + fi touch $MSC_GIT_UPD_REPO_STATFILE else logwarning -n " Lokale Änderungen festgestellt:" From a91118423a3239c9b37452db48121122836381e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 21 Oct 2022 17:09:07 +0200 Subject: [PATCH 11/11] print error, when more than one token is plugged in --- bin/startagent | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/bin/startagent b/bin/startagent index 2cd0a47..1e451dc 100755 --- a/bin/startagent +++ b/bin/startagent @@ -250,7 +250,7 @@ agent_load_identity_keys () { fingerprints=( $(ssh_runinagent $agentfile "ssh-add -l|awk '{print \$2}'") ) logdebug "fingerprints from loaded keys before action:" - for f in ${fingerprints[*]};do + for f in ${fingerprints[@]};do logdebug "$f" done if ! $tokenonly ; then @@ -303,25 +303,33 @@ agent_load_identity_keys () { #[ "$(readlink - f $key)" == "$P11M" ] || key="$P11M" [ "$(readlink -f $key)" != "$P11M" -a "${P11M:-x}" != "x" ] && key="$P11M" logdebug "P11M2: ${P11M:-not set} - key: $key" - echo "P11M: ${P11M:-not set} - key: $key" + logdebug "P11M: ${P11M:-not set} - key: $key" - tokenfingerprint="$(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}')" + tokenfingerprints=($(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}')) - if [[ ${fingerprints[*]} =~ "$tokenfingerprint" ]]; then - logdebug "token: $key ($tokenfingerprint) is loaded" - check_pubkeysonly - if $readd || $remove ; then - $readd && logdebug "re-add token $key" - $remove && logdebug "remove token $key" - echo agentfile1 $agentfile \$SSH_ADD_OPTIONS $key >&2 - logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -e "${key}" 2>&1)" - ssh_runinagent $agentfile echo $SSH_AUTH_SOCK >&2 - $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s "${key}" 2>&1)" - fi + logtrace "fingerprints: ${fingerprints[*]}" + logtrace "tokenfingerprints count: ${#tokenfingerprints[@]}" + if [ ${#tokenfingerprints[@]} -gt 1 ]; then + logerr "Found ${#tokenfingerprints[@]} in p11-kit-proxy! Check if only one token is plugged into your computer" else - logdebug "token: $key is not loaded -> load it" - logdebug "$(ssh_runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)" - $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)" + tokenfingerprint=${tokenfingerprints[0]} + logtrace "tokenfingerprint: ${tokenfingerprint}" + if [[ "${fingerprints[@]}" =~ "$tokenfingerprint" ]]; then + logdebug "token: $key ($tokenfingerprint) is loaded" + check_pubkeysonly + if $readd || $remove ; then + $readd && logdebug "re-add token $key" + $remove && logdebug "remove token $key" + echo agentfile1 $agentfile \$SSH_ADD_OPTIONS $key >&2 + logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -e "${key}" 2>&1)" + ssh_runinagent $agentfile echo $SSH_AUTH_SOCK >&2 + $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s "${key}" 2>&1)" + fi + else + logdebug "token: $key is not loaded -> load it" + logdebug "$(ssh_runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)" + $remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)" + fi fi done fi