aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2011-02-02 19:38:56 +0000
committerMichael Scherer <misc@mageia.org>2011-02-02 19:38:56 +0000
commit41684519aa964d08810b55337514f43ed2b4c537 (patch)
treefd7c9ee430430a56307cda89c98313e71d9084b1 /modules/git
parent35bb51eec4c196252c6b12c9e9be34e89a7b1768 (diff)
downloadpuppet-41684519aa964d08810b55337514f43ed2b4c537.tar
puppet-41684519aa964d08810b55337514f43ed2b4c537.tar.gz
puppet-41684519aa964d08810b55337514f43ed2b4c537.tar.bz2
puppet-41684519aa964d08810b55337514f43ed2b4c537.tar.xz
puppet-41684519aa964d08810b55337514f43ed2b4c537.zip
- use a script, with a lock , so we can have more than one update
running without trouble. Remove older comments in manifests
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/files/update_git_svn.sh13
-rw-r--r--modules/git/manifests/init.pp15
2 files changed, 24 insertions, 4 deletions
diff --git a/modules/git/files/update_git_svn.sh b/modules/git/files/update_git_svn.sh
new file mode 100644
index 00000000..b3802f81
--- /dev/null
+++ b/modules/git/files/update_git_svn.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+GIT_REP="$1"
+LOCKFILE="$GIT_REP/.git/update.cron.lock"
+
+cd "$GIT_REP"
+[ -f $LOCKFILE ] && exit 0
+trap "rm -f '$LOCKFILE'" EXIT
+
+touch "$LOCKFILE"
+
+/usr/bin/git svn fetch
+/usr/bin/git svn rebase
+exit 0
diff --git a/modules/git/manifests/init.pp b/modules/git/manifests/init.pp
index e32a9642..c4847c3b 100644
--- a/modules/git/manifests/init.pp
+++ b/modules/git/manifests/init.pp
@@ -84,14 +84,21 @@ class git {
alias => "git svn $name",
creates => $name,
}
- # TODO what if there is 2 concurents jobs ?
- # should we add a lock ( ie, a script + lock file for first sync )
+
+ file { "/usr/local/bin/update_git_svn.sh":
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => 755,
+ source => 'puppet:///modules/git/update_git_svn.sh',
+ }
+
cron { "update $name":
# done in 2 times, so fetch can fill the repo after init
- command => "cd $name && /usr/bin/git svn fetch && /usr/bin/git svn rebase" ,
+ command => "/usr/local/bin/update_git_svn.sh $name" ,
minute => $refresh
}
- # TODO find a way to prevent commit
+
file { "$name/.git/hooks/pre-receive":
ensure => present,
owner => root,