From: Nicolas Boisselier Date: Wed, 13 Jul 2016 23:06:25 +0000 (+0100) Subject: git_conn_check X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=29f3c57cdf3942e4a732401b9c4034ab354b5658;p=nb.git git_conn_check --- diff --git a/bin/nb-update b/bin/nb-update index 2481b1bf..1cde0cb3 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -16,10 +16,10 @@ declare -r TMP="/tmp/$NAME.tmp" # _git_conn_check=" " git_conn_check() { - local dest=$(git config --local --get remote.origin.url | sed 's/:.*\?$//') + local dest=$(git config --local --get remote.origin.url | sed -e 's/:.*$//' -e 's/^.*@//') if [ -z "$dest" ]; then - logger -t $NAME -s "Can't get git repo from `cwd`" + logger -t $NAME -s "Can't get \`git config --het remote.origin.url\` from `cwd`" return 1 fi @@ -29,9 +29,11 @@ git_conn_check() { *" $dest=1 "*) ok=1 ;; *) ok=0 - timeout 5 ssh -o BatchMode=yes -o ConnectTimeout=5 $dest true && ok=1 + case "$dest" in + *"@"*) timeout 5 ssh -o BatchMode=yes -o ConnectTimeout=5 $dest true && ok=1 ;; + *) nc -z -w 5 $dest 22 && ok=1 ;; + esac _git_conn_check="${_git_conn_check}$dest=$ok " - echo "<$_git_conn_check>" ;; esac @@ -68,12 +70,11 @@ for repo in $(nb-repo-dirs); do # Pull echo ">git pull $repo (user=$user)" - #git_conn_check || continue cmd="GIT_SSH=$GIT_SSH cd \"$repo\" && git pull" - if ! git_conn_check; then - true + if [ 1 = 1 ] && ! git_conn_check; then + [ 1 = 1 ] elif [ "$USER" == "$user" ]; then bash -c "$cmd" elif [ "$USER" == "root" ]; then