From: Nicolas Boisselier Date: Tue, 20 Dec 2016 09:32:03 +0000 (+0000) Subject: agent X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=3ad563fc33c6185cd1946c84fc10a684d2f0e31e;p=nb.git agent --- diff --git a/bin/nb-update b/bin/nb-update index 9847bd20..faf7a4e5 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -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