]> git.nbdom.net Git - nb.git/commitdiff
agent
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 20 Dec 2016 09:32:03 +0000 (09:32 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 20 Dec 2016 09:32:03 +0000 (09:32 +0000)
bin/nb-update

index 9847bd203ac7494d820b50a6c1d1a959f5fd55df..faf7a4e5842a44536fb18e150935d09b249432fb 100755 (executable)
@@ -5,20 +5,16 @@
 # Called by cron/etc/nb
 #
 #####################################################################
-#echo . "${BASH_SOURCE%/*}/../etc/profile" || exit
-#. "${BASH_SOURCE%/*}/../etc/profile" || exit
-#echo "$0 | $(dirname "$0")/.. | $PATH"
-. $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit
-#exit;
-#nb_repos; exit;
 NAME="$(basename "${0}")"
 TMP="/tmp/$NAME.tmp"
 CLEANUP=0
 [ "$1" = "-cleanup" ] && CLEANUP=1
 
 #####################################################################
-# Gits pull
 #
+# Requirments
+#
+. $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit
 if ! which git > /dev/null; then
   echo "$NAME: can't find git!" 1>&2
   exit 1
@@ -28,6 +24,10 @@ ex=0
 printf '#!%s\n%s\n' `which sh` 'ssh -o BatchMode=yes $@' > "$TMP" && chmod 755 "$TMP"
 export GIT_SSH="$TMP"
 
+#####################################################################
+#
+# Repos
+#
 for repo in $(nb_repos); do
 
   [ -d "$repo/.git" ] || continue
@@ -35,13 +35,26 @@ for repo in $(nb_repos); do
 
   name="$(basename $repo)"
 
+  #
   # Get user
+  #
   user=`ls -dl "$repo/.git" |awk '{print $3}'`
 
+  cmd=""
+
+  #
+  # Check ssh agent sh file
+  #
+  agent=$(eval realpath ~$user/.ssh/agent.sh)
+  [ -r "$agent" ] && cmd=". $agent && "
+  #[ -r "$agent" ] && echo "Found agent $agent"
+
+  #
   # Pull
+  #
   echo ">git pull $repo (user=$user)"
 
-  cmd="GIT_SSH=$GIT_SSH cd \"$repo\" && git pull"
+  cmd="${cmd}GIT_SSH=$GIT_SSH cd \"$repo\" && git pull"
   [ "$CLEANUP" = "1" ] && cmd="$cmd && git gc"
 
   if [ 1 = 1 ] && ! git_conn_check; then
@@ -56,6 +69,9 @@ for repo in $(nb_repos); do
   fi
   ret=$?
 
+  #
+  # *-install
+  #
   if [ "$ret" != "0" ]; then
     ex=$ret && echo ">err $ret"
 
@@ -73,11 +89,11 @@ for repo in $(nb_repos); do
   echo
 
 done
-rm -f "$TMP"
 
 #####################################################################
 # End
 #
+rm -f "$TMP"
 if [ "$ex" = "0" ]; then
   printf ">OK\n"
 else