summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2009-01-08 21:03:40 +0000
committermh <mh@immerda.ch>2009-01-08 21:03:40 +0000
commita28669485770e6bf62adba52793b6d193ea88b76 (patch)
tree38db3fe1989f0522f7fdefedb9d9fd4d251f5c52
parent147a631c625c6c0eb7b8dcc88a2e068d7a5eb70e (diff)
introducing git-daemon
-rw-r--r--files/init.d/git-daemon73
-rw-r--r--files/sysconfig/git-daemon23
-rw-r--r--files/sysconfig/git-daemon.vhosts24
-rw-r--r--manifests/daemon.pp28
-rw-r--r--manifests/daemon/vhosts.pp7
5 files changed, 155 insertions, 0 deletions
diff --git a/files/init.d/git-daemon b/files/init.d/git-daemon
new file mode 100644
index 0000000..f574480
--- /dev/null
+++ b/files/init.d/git-daemon
@@ -0,0 +1,73 @@
+#!/bin/bash
+# puppet Init script for running the git-daemon
+#
+# Author: Marcel Haerry <mh+rpms(at)immerda.ch>
+#
+# chkconfig: - 98 02
+#
+# description: Enables the git-daemon to serve various directories. By default it serves /srv/git
+# processname: git-daemon
+# config: /etc/sysconfig/git-daemon
+
+PATH=/usr/bin:/sbin:/bin:/usr/sbin
+export PATH
+
+[ -f /etc/sysconfig/git-daemon ] && . /etc/sysconfig/git-daemon
+lockfile=${LOCKFILE-/var/lock/subsys/git-daemon}
+gitdir=${GITDIR-/srv/git}
+gitvhost=${GITVHOST-no}
+options=${OPTIONS-"--reuseaddr --verbose --detach"}
+gitdaemon=${GITDAEMON-/usr/bin/git-daemon}
+RETVAL=0
+
+if [ $gitvhost = yes ]; then
+ gitoptions="${options} --interpolated-path=${gitdir}/%H/%D"
+else
+ gitoptions="${options} --base-path=${gitdir}"
+fi
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+start() {
+ echo -n $"Starting git-daemon: "
+ daemon $gitdaemon $gitoptions
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && touch ${lockfile}
+ return $RETVAL
+}
+
+stop() {
+ echo -n $"Stopping git-daemon: "
+ killproc $gitdaemon
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && rm -f ${lockfile}
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ restart
+ ;;
+ status)
+ status $gitdaemon
+ RETVAL=$?
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart}"
+ exit 1
+esac
+
+exit $RETVAL
diff --git a/files/sysconfig/git-daemon b/files/sysconfig/git-daemon
new file mode 100644
index 0000000..92e66f2
--- /dev/null
+++ b/files/sysconfig/git-daemon
@@ -0,0 +1,23 @@
+# git-daemon config file
+
+# location of the lockfile
+#LOCKFILE=/var/lock/subsys/git-daemon
+
+# which directory to server
+#GITDIR=/srv/git
+
+# do we serve vhosts?
+# setting this to yes assumes that you
+# have in $GITDIR per vhost to serve
+# a subdirectory containing their repos.
+# for example:
+# - /srv/git/git.example.com
+# - /srv/git/git.example.org
+#GITVHOST=no
+
+# options for the daemon
+#OPTIONS="--reuseaddr --verbose --detach"
+
+# location of the daemon
+#GITDAEMON=/usr/bin/git-daemon
+
diff --git a/files/sysconfig/git-daemon.vhosts b/files/sysconfig/git-daemon.vhosts
new file mode 100644
index 0000000..dce800f
--- /dev/null
+++ b/files/sysconfig/git-daemon.vhosts
@@ -0,0 +1,24 @@
+# git-daemon config file
+
+# location of the lockfile
+#LOCKFILE=/var/lock/subsys/git-daemon
+
+# which directory to server
+#GITDIR=/srv/git
+
+# do we serve vhosts?
+# setting this to yes assumes that you
+# have in $GITDIR per vhost to serve
+# a subdirectory containing their repos.
+# for example:
+# - /srv/git/git.example.com
+# - /srv/git/git.example.org
+#GITVHOST=no
+GITVHOST=yes
+
+# options for the daemon
+#OPTIONS="--reuseaddr --verbose --detach"
+
+# location of the daemon
+#GITDAEMON=/usr/bin/git-daemon
+
diff --git a/manifests/daemon.pp b/manifests/daemon.pp
new file mode 100644
index 0000000..87ec421
--- /dev/null
+++ b/manifests/daemon.pp
@@ -0,0 +1,28 @@
+class git::daemon {
+ include git
+ package{'git-daemon':
+ ensure => installed,
+ require => Package['git'],
+ }
+
+ file{'/etc/init.d/git-daemon':
+ source => [ "puppet://$server/files/git/init.d/${fqdn}/git-daemon",
+ "puppet://$server/files/git/init.d/git-daemon",
+ "puppet://$server/git/init.d/git-daemon" ],
+ require => Package['git-daemon'],
+ owner => root, group => 0, mode => 0755;
+ }
+ file{'/etc/sysconfig/git-daemon':
+ source => [ "puppet://$server/files/git/sysconfig/${fqdn}/git-daemon",
+ "puppet://$server/files/git/sysconfig/git-daemon",
+ "puppet://$server/git/sysconfig/git-daemon" ],
+ require => Package['git-daemon'],
+ owner => root, group => 0, mode => 0644;
+ }
+ service{'git-daemon':
+ ensure => running,
+ enable => true,
+ hasstatus => true,
+ require => [ File['/etc/sysconfig/git-daemon'], File['/etc/init.d/git-daemon'] ],
+ }
+}
diff --git a/manifests/daemon/vhosts.pp b/manifests/daemon/vhosts.pp
new file mode 100644
index 0000000..1ebc7eb
--- /dev/null
+++ b/manifests/daemon/vhosts.pp
@@ -0,0 +1,7 @@
+class git::daemon::vhosts inherits git::daemon {
+ File['/etc/sysconfig/git-daemon']{
+ source => [ "puppet://$server/files/git/sysconfig/${fqdn}/git-daemon.vhosts",
+ "puppet://$server/files/git/sysconfig/git-daemon.vhosts",
+ "puppet://$server/git/sysconfig/git-daemon.vhosts" ],
+ }
+}