auto-update can run in git subdirs; review GIT_WHITELIST for daemon
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 26 May 2010 17:38:54 +0000 (19:38 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 26 May 2010 17:38:54 +0000 (19:38 +0200)
scripts/auto-update.sh
scripts/git-daemon.init.d
scripts/git-daemon.sysconfig

index 92bf96a..6b6b6f5 100755 (executable)
@@ -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
index f6b6ebc..bc3e64b 100755 (executable)
@@ -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
index b78f394..156f5d8 100644 (file)
@@ -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