From a28669485770e6bf62adba52793b6d193ea88b76 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 8 Jan 2009 21:03:40 +0000 Subject: introducing git-daemon --- files/init.d/git-daemon | 73 +++++++++++++++++++++++++++++++++++++++ files/sysconfig/git-daemon | 23 ++++++++++++ files/sysconfig/git-daemon.vhosts | 24 +++++++++++++ manifests/daemon.pp | 28 +++++++++++++++ manifests/daemon/vhosts.pp | 7 ++++ 5 files changed, 155 insertions(+) create mode 100644 files/init.d/git-daemon create mode 100644 files/sysconfig/git-daemon create mode 100644 files/sysconfig/git-daemon.vhosts create mode 100644 manifests/daemon.pp create mode 100644 manifests/daemon/vhosts.pp 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 +# +# 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" ], + } +} -- cgit v1.2.3