#
#################################################################################
CLEANUP=0
-PULL=0
DEBUG=0
VERBOSE=0
while [ $# -gt 0 ]; do
case "$1" in
--cleanup|-c) CLEANUP=1 ;;
- --pull|-pull) PULL=1 ;;
-*help|-h) usage | pod2text --width 250; exit 0 ;;
--man) usage | pod2man | man -l -; exit 0 ;;
exec {F_INDENT2}> >(sed -e 's/\r/\n/g' -e 's/^ *//' -e 's/^/ /')
trap 'exec {F_INDENT1}>&-; exec {F_INDENT2}>&-;' EXIT
-if [ "$PULL" = "1" ]; then
#V=1
#echo ${V:-2}
fi
#echo
-fi # PULL
#----------------------------------------------------------
# Git hooks
#
DEBUG=0
CLEANUP=0
POST_INFO=1
-PULL=1
#################################################################################
#
# Args
while [ $# -gt 0 ]; do
case "$1" in
- --pull|-pull) PULL=1 ;;
--cleanup|-cleanup|-c) CLEANUP=1 ;;
--no-post|-nop) POST_INFO=0 ;;
# include extra scripts
! [ -r "$NB_ROOT/lib/$NAME/repo.sh" ] || . "$NB_ROOT/lib/$NAME/repo.sh" || bye
-if [ "$PULL" = "1" ]
-then
#exec {F_INDENT}> >(sed 's/^/ /')
- opt="--pull"
+ opt=""
[ "$CLEANUP" = "1" ] && opt="$opt --cleanup"
opt="${opt# *}"
exec_user $user "nb-repo-update $opt" #>&$F_INDENT 2>&1
ex_repo=$?
[ "$ex_repo" = "0" ] || ex=$ex_repo
- #echo $ex_repo
- #exec {F_INDENT}>&-
-else # PULL
- #
- # Build command
- #
- cmd=""
-
- #
- # Check ssh agent sh file
- #
- agent=$(eval realpath ~$user/.ssh/agent.sh)
- [ -r "$agent" ] && cmd=". $agent && "
- #[ -r "$agent" ] && echo "Found agent $agent"
-
- #
- # Pull
- #
- ex_repo=0
- echo ">Pull $name branch=$branch user=$user path=$dir"
-
- cmd="${cmd}GIT_SSH=$GIT_SSH cd \"$dir\" && git pull"
- [ "$CLEANUP" = "1" ] && cmd="$cmd && git gc"
-
- # NB 08.10.24 if [ 1 = 1 ] && ! exec_user $user git_conn_check; then
- if ! exec_user $user git_conn_check; then
- continue
- elif [ "$USER" = "$user" ]; then
- bash -c "$cmd"
- elif [ "$USER" = "root" ]; then
- su - $user -c "$cmd"
- else
- echo "Wrong user current user=$USER repo user=$user"
- false
- fi
- echo
- ex_cmd=$?
-
- #
- # *-install
- #
- ex_cmd_root=0
- if [ "$ex_cmd" != "0" ]; then
- ex_repo=$ex_cmd
- echo ">err $ex_cmd"
-
- else
- cmd_root="true"
-
- exec_user $user "nb-repo-install" | sed 's/^/ /'
- ex_cmd_root=$?
- if [ "$ex_cmd_root" -gt "0" ]; then
- ex_repo=$ex_cmd_root
- echo ">err $ex_cmd_root"
- fi
-
- fi
-
- [ "$ex_repo" = "0" ] && ex_repo="$(exec_user $user git status --short &> /dev/null; echo $?)"
- [ "$ex_repo" = "0" ] || ex=$ex_repo
-fi # PULL
if [ "$POST_INFO" = "1" ]
then