From eba34261f2fcbdc51e7cb32077cdbf68898b1011 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 26 May 2010 19:38:54 +0200 Subject: [PATCH] auto-update can run in git subdirs; review GIT_WHITELIST for daemon --- scripts/auto-update.sh | 32 ++++++++++++++++++++++++++++---- scripts/git-daemon.init.d | 2 +- scripts/git-daemon.sysconfig | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/scripts/auto-update.sh b/scripts/auto-update.sh index 92bf96a..6b6b6f5 100755 --- a/scripts/auto-update.sh +++ b/scripts/auto-update.sh @@ -1,9 +1,33 @@ #!/bin/bash # performs svn update in this command's directory -DIRNAME=$(dirname $0) -DIRNAME=$(cd $DIRNAME; pwd -P) +function _svn_or_git () { + where="$1"; [ -z "$where" ] && where="." + cd $where + while true; do + [ -d .svn ] && { echo svn ; return ; } + [ -d .git ] && { echo git ; return ; } + [ "$(pwd -P)" == "/" ] && { echo none ; return ; } + cd .. + done +} +# idem but runs in a subshell to protect cwd +function svn_or_git () { ( _svn_or_git "$@" ; ) } + +#################### +# without an argument, use the place where the command is stored +if [[ -z "$@" ]] ; then + DIRNAME=$(dirname $0) + DIRNAME=$(cd $DIRNAME; pwd -P) +else + DIRNAME="$1" ; shift +fi + +########## cd $DIRNAME -[ -d .svn ] && (date ; svn update ) &> .auto-update.log -[ -d .git ] && (date ; git pull ) &> .auto-update.log +case $(svn_or_git) in + svn) (date ; svn update ) >& .auto-update.log ;; + git) (date ; git pull ) >& .auto-update.log ;; + *) echo 'only svn and git are supported' >& .auto-update.log ;; +esac diff --git a/scripts/git-daemon.init.d b/scripts/git-daemon.init.d index f6b6ebc..bc3e64b 100755 --- a/scripts/git-daemon.init.d +++ b/scripts/git-daemon.init.d @@ -29,7 +29,7 @@ runlevel=$(set -- $(runlevel); eval "echo \$$#" ) start() { echo -n $"Starting $prog: " - $(eval $GIT $OPTIONS) && success || failure + $GIT $OPTIONS && success || failure RETVAL=$? [ "$RETVAL" = 0 ] && touch /var/lock/subsys/git echo diff --git a/scripts/git-daemon.sysconfig b/scripts/git-daemon.sysconfig index b78f394..156f5d8 100644 --- a/scripts/git-daemon.sysconfig +++ b/scripts/git-daemon.sysconfig @@ -1,6 +1,6 @@ # variables looked at GITDIR=/git -GITWHITELIST="/git/{build,infrastructure,omf,playground,tests}.git" +GITWHITELIST=$(ls -d /git/{build,infrastructure,omf,playground,tests}.git) PORT=9418 VERBOSE= DETACH=--detach -- 2.43.0