From: thierry Date: Wed, 11 Jun 2008 08:12:39 +0000 (+0000) Subject: protect against concurrent runs - redone X-Git-Tag: foo~308 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f38d5a7692827e2836f09bad8bac21d26ef6ac96;p=infrastructure.git protect against concurrent runs - redone --- diff --git a/scripts/all-modules.sh b/scripts/all-modules.sh index a43dd8a..0c81374 100755 --- a/scripts/all-modules.sh +++ b/scripts/all-modules.sh @@ -10,12 +10,8 @@ # when the svn server has problems, this can very well last quite a while COMMAND=$(basename $0) -pid=$$ -running=$(pgrep $COMMAND 2> /dev/null | grep -v "^${pid}"'^' ) -# bail out if another instance is already running -[ -n "$running" ] && exit 1 - OUTPUT=/build/modules +LOCK=/var/run/all-modules.pid # usage: do_version dir name function do_version () { @@ -58,7 +54,33 @@ function do_diff () { rm -f $out_tmp } -do_version /root/svn-build-4.2 4.2 -do_diff /root/svn-build-4.2 4.2 -do_version /root/svn-build trunk -do_diff /root/svn-build trunk +function usage () { + echo "Usage: $COMMAND [-v] [-f] [-i]" +} + +function main () { + + while [[ -n "$@" ]] ; do + case "$1" in + -f) rm -f $LOCK ;; + -i) ls -l $LOCK ; exit 0 ;; + -v) set -x ;; + *) usage; exit 1;; + esac + shift + done + + [ -f $LOCK ] && exit 1 + + echo $$ > $LOCK + + do_version /root/svn-build-4.2 4.2 + do_diff /root/svn-build-4.2 4.2 + do_version /root/svn-build trunk + do_diff /root/svn-build trunk + + rm $LOCK + +} + +main "$@"