#!/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
start()
{
echo -n $"Starting $prog: "
- $(eval $GIT $OPTIONS) && success || failure
+ $GIT $OPTIONS && success || failure
RETVAL=$?
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/git
echo
# 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