]> git.nbdom.net Git - nb.git/commitdiff
git_conn_check
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 13 Jul 2016 23:06:25 +0000 (00:06 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 13 Jul 2016 23:06:25 +0000 (00:06 +0100)
bin/nb-update

index 2481b1bf8c16e2f19384f35710b96cd1a84154d9..1cde0cb3771eb8ff8658c89250e057fa2e942090 100755 (executable)
@@ -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