summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2011-04-01 13:29:43 -0400
committerMicah Anderson <micah@riseup.net>2011-04-01 13:29:43 -0400
commitf2846099d1e24589600d6a3a346ab92e5c65f843 (patch)
tree9bc6b1ba9502c3bd42b64a4834ef91dc7f7fce5a
parent74ccc33ff4f0158e80db4dbc64d4edc490acb26c (diff)
parent5c746aa9a4ee5748cbaa6812a508e3dd878b621c (diff)
Merge remote-tracking branch 'lavamind/master'
Conflicts: manifests/daemon.pp manifests/daemon/disable.pp manifests/daemon/vhosts.pp
-rw-r--r--files/config/CentOS/git-daemon (renamed from files/sysconfig/git-daemon)0
-rw-r--r--files/config/CentOS/git-daemon.vhosts (renamed from files/sysconfig/git-daemon.vhosts)0
-rw-r--r--files/config/Debian/git-daemon22
-rw-r--r--files/init.d/CentOS/git-daemon (renamed from files/init.d/git-daemon)0
-rw-r--r--files/init.d/Debian/git-daemon151
-rw-r--r--manifests/base.pp3
-rw-r--r--manifests/centos.pp2
-rw-r--r--manifests/daemon.pp62
-rw-r--r--manifests/daemon/base.pp30
-rw-r--r--manifests/daemon/centos.pp19
-rw-r--r--manifests/daemon/debian.pp11
-rw-r--r--manifests/daemon/disable.pp21
-rw-r--r--manifests/daemon/vhosts.pp18
-rw-r--r--manifests/debian.pp5
-rw-r--r--manifests/init.pp13
15 files changed, 277 insertions, 80 deletions
diff --git a/files/sysconfig/git-daemon b/files/config/CentOS/git-daemon
index a9b208c..a9b208c 100644
--- a/files/sysconfig/git-daemon
+++ b/files/config/CentOS/git-daemon
diff --git a/files/sysconfig/git-daemon.vhosts b/files/config/CentOS/git-daemon.vhosts
index 62bb9d4..62bb9d4 100644
--- a/files/sysconfig/git-daemon.vhosts
+++ b/files/config/CentOS/git-daemon.vhosts
diff --git a/files/config/Debian/git-daemon b/files/config/Debian/git-daemon
new file mode 100644
index 0000000..b25e1e7
--- /dev/null
+++ b/files/config/Debian/git-daemon
@@ -0,0 +1,22 @@
+# Defaults for the git-daemon initscript
+
+# Set to yes to start git-daemon
+RUN=yes
+
+# Set to the user and group git-daemon should run as
+USER=nobody
+GROUP=nogroup
+
+# Set the base path and the directory where the repositories are.
+REPOSITORIES="/srv/git"
+
+# Provide a way to have custom setup.
+#
+# Note, when ADVANCED_OPTS is defined the REPOSITORIES setting is ignored,
+# so take good care to specify exactly what git-daemon have to do.
+#
+# Here is an example from the man page:
+#ADVANCED_OPTS="--verbose --export-all \
+# --interpolated-path=/pub/%IP/%D \
+# /pub/192.168.1.200/software \
+# /pub/10.10.220.23/software"
diff --git a/files/init.d/git-daemon b/files/init.d/CentOS/git-daemon
index aed2075..aed2075 100644
--- a/files/init.d/git-daemon
+++ b/files/init.d/CentOS/git-daemon
diff --git a/files/init.d/Debian/git-daemon b/files/init.d/Debian/git-daemon
new file mode 100644
index 0000000..7fc6c8b
--- /dev/null
+++ b/files/init.d/Debian/git-daemon
@@ -0,0 +1,151 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: git-daemon
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: git-daemon service
+# Description: git-daemon makes git repositories available via the git
+# protocol.
+### END INIT INFO
+
+# Author: Antonio Ospite <ospite@studenti.unina.it>
+#
+# Please remove the "Author" lines above and replace them
+# with your own name if you copy and modify this script.
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/git-core
+DESC="git-daemon service"
+NAME=git-daemon
+DAEMON=/usr/bin/$NAME
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Fallback options values, we use these when
+# the /etc/default/git-daemon file does not exist
+RUN=no
+USER=git
+GROUP=git
+REPOSITORIES="/srv/git/"
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# If ADVANCED_OPTS is empty, use a default setting
+if [ "x$ADVANCED_OPTS" == "x" ];
+then
+ ADVANCED_OPTS="--base-path=$REPOSITORIES $REPOSITORIES"
+fi
+
+DAEMON_ARGS="--syslog --reuseaddr \
+ --user=$USER --group=$GROUP \
+ $ADVANCED_OPTS"
+
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile -- \
+ $DAEMON_ARGS \
+ || return 2
+
+ return 0
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/manifests/base.pp b/manifests/base.pp
index 06742a7..51140b6 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -1,5 +1,6 @@
class git::base {
- package{'git':
+ package { 'git':
ensure => present,
+ alias => 'git',
}
}
diff --git a/manifests/centos.pp b/manifests/centos.pp
new file mode 100644
index 0000000..9634475
--- /dev/null
+++ b/manifests/centos.pp
@@ -0,0 +1,2 @@
+class git::centos inherits git::base {
+}
diff --git a/manifests/daemon.pp b/manifests/daemon.pp
index 01cfec2..33c0a26 100644
--- a/manifests/daemon.pp
+++ b/manifests/daemon.pp
@@ -1,60 +1,14 @@
class git::daemon {
- include git
- package{'git-daemon':
- ensure => installed,
- require => Package['git'],
- }
- xinetd::file{'git':
- require => Package['git-daemon'],
- }
- file{'/etc/init.d/git-daemon':
- require => Package['git-daemon'],
- owner => root, group => 0, mode => 0755;
- }
- file{'/etc/sysconfig/git-daemon':
- require => Package['git-daemon'],
- owner => root, group => 0, mode => 0644;
- }
- service{'git-daemon':
- hasstatus => true,
- }
- if $git_daemon == 'service' {
- Xinetd::File['git']{
- source => "puppet:///modules/git/xinetd.d/git.disabled"
- }
- File['/etc/init.d/git-daemon']{
- source => [ "puppet:///modules/site-git/init.d/${fqdn}/git-daemon",
- "puppet:///modules/site-git/init.d/git-daemon",
- "puppet:///modules/git/init.d/git-daemon" ],
- }
- File['/etc/sysconfig/git-daemon']{
- source => [ "puppet:///modules/site-git/sysconfig/${fqdn}/git-daemon",
- "puppet:///modules/site-git/sysconfig/git-daemon",
- "puppet:///modules/git/sysconfig/git-daemon" ],
- }
- Service['git-daemon']{
- ensure => running,
- enable => true,
- require => [ File['/etc/sysconfig/git-daemon'], File['/etc/init.d/git-daemon'] ],
- }
- } else {
- Xinetd::File['git']{
- source => [ "puppet:///modules/site-git/xinetd.d/${fqdn}/git",
- "puppet:///modules/site-git/xinetd.d/git",
- "puppet:///modules/git/xinetd.d/git" ],
- }
- Service['git-daemon']{
- ensure => stopped,
- enable => false,
- before => [ File['/etc/sysconfig/git-daemon'], File['/etc/init.d/git-daemon'] ],
+ include git
+
+ case $operatingsystem {
+ debian: { include git::daemon::debian }
+ centos: { include git::daemon::centos }
}
- File['/etc/init.d/git-daemon','/etc/sysconfig/git-daemon']{
- ensure => absent,
+
+ if $use_shorewall {
+ include shorewall::rules::gitdaemon
}
- }
- if $use_shorewall {
- include shorewall::rules::gitdaemon
- }
}
diff --git a/manifests/daemon/base.pp b/manifests/daemon/base.pp
new file mode 100644
index 0000000..5dd16d6
--- /dev/null
+++ b/manifests/daemon/base.pp
@@ -0,0 +1,30 @@
+class git::daemon::base {
+
+ file { 'git-daemon_initscript':
+ source => [ "puppet://$server/modules/site-git/init.d/${fqdn}/git-daemon",
+ "puppet://$server/modules/site-git/init.d/${operatingsystem}/git-daemon",
+ "puppet://$server/modules/site-git/init.d/git-daemon",
+ "puppet://$server/modules/git/init.d/${operatingsystem}/git-daemon",
+ "puppet://$server/modules/git/init.d/git-daemon" ],
+ require => Package['git'],
+ owner => root, group => 0, mode => 0755;
+ }
+
+ file { 'git-daemon_config':
+ source => [ "puppet://$server/modules/site-git/config/${fqdn}/git-daemon",
+ "puppet://$server/modules/site-git/config/${operatingsystem}/git-daemon",
+ "puppet://$server/modules/site-git/config/git-daemon",
+ "puppet://$server/modules/git/config/${operatingsystem}/git-daemon",
+ "puppet://$server/modules/git/config/git-daemon" ],
+ require => Package['git'],
+ owner => root, group => 0, mode => 0644;
+ }
+
+ service { 'git-daemon':
+ ensure => running,
+ enable => true,
+ hasstatus => true,
+ require => [ File['git-daemon_initscript'], File['git-daemon_config'] ],
+ }
+
+}
diff --git a/manifests/daemon/centos.pp b/manifests/daemon/centos.pp
new file mode 100644
index 0000000..270685a
--- /dev/null
+++ b/manifests/daemon/centos.pp
@@ -0,0 +1,19 @@
+class git::daemon::centos inherits git::daemon::base {
+
+ package { 'git-daemon':
+ ensure => installed,
+ require => Package['git'],
+ alias => 'git-daemon',
+ }
+
+ File['git-daemon_initscript'] {
+ path => '/etc/init.d/git-daemon',
+ require +> Package['git-daemon'],
+ }
+
+ File['git-daemon_config'] {
+ path => '/etc/init.d/git-daemon',
+ require +> Package['git-daemon'],
+ }
+
+}
diff --git a/manifests/daemon/debian.pp b/manifests/daemon/debian.pp
new file mode 100644
index 0000000..006ffc5
--- /dev/null
+++ b/manifests/daemon/debian.pp
@@ -0,0 +1,11 @@
+class git::daemon::debian inherits git::daemon::base {
+
+ File['git-daemon_initscript'] {
+ path => '/etc/init.d/git-daemon',
+ }
+
+ File['git-daemon_config'] {
+ path => '/etc/default/git-daemon',
+ }
+
+}
diff --git a/manifests/daemon/disable.pp b/manifests/daemon/disable.pp
index 807d03e..b60fcec 100644
--- a/manifests/daemon/disable.pp
+++ b/manifests/daemon/disable.pp
@@ -1,26 +1,29 @@
class git::daemon::disable inherits git::daemon {
- Package['git-daemon']{
- ensure => absent,
- }
- Xinetd::File['git']{
- source => "puppet:///modules/git/xinetd.d/git.disabled"
+ if defined(Package['git-daemon']) {
+ Package['git-daemon'] {
+ ensure => absent,
+ }
}
- File['/etc/init.d/git-daemon']{
+
+ File['git-daemon_initscript'] {
ensure => absent,
}
- File['/etc/sysconfig/git-daemon']{
+
+ File['git-daemon_config'] {
ensure => absent,
}
- Service['git-daemon']{
+
+ Service['git-daemon'] {
ensure => stopped,
enable => false,
require => undef,
- before => File['/etc/init.d/git-daemon'],
+ before => File['git-daemon_initscript'],
}
if $use_shorewall {
include shorewall::rules::gitdaemon::absent
}
+
}
diff --git a/manifests/daemon/vhosts.pp b/manifests/daemon/vhosts.pp
index beb33ab..d627df1 100644
--- a/manifests/daemon/vhosts.pp
+++ b/manifests/daemon/vhosts.pp
@@ -1,15 +1,9 @@
class git::daemon::vhosts inherits git::daemon {
- if $git_daemon == 'service' {
- File['/etc/sysconfig/git-daemon']{
- source => [ "puppet:///modules/site-git/sysconfig/${fqdn}/git-daemon.vhosts",
- "puppet:///modules/site-git/sysconfig/git-daemon.vhosts",
- "puppet:///modules/git/sysconfig/git-daemon.vhosts" ],
+ File['git-daemon_config']{
+ source => [ "puppet://$server/modules/site-git/config/${fqdn}/git-daemon.vhosts",
+ "puppet://$server/modules/site-git/config/${operatingsystem}/git-daemon.vhosts",
+ "puppet://$server/modules/site-git/config/git-daemon.vhosts",
+ "puppet://$server/modules/git/config/${operatingsystem}/git-daemon.vhosts",
+ "puppet://$server/modules/git/config/git-daemon.vhosts" ],
}
- } else {
- Xinetd::File['git']{
- source => [ "puppet:///modules/site-git/xinetd.d/${fqdn}/git.vhosts",
- "puppet:///modules/site-git/xinetd.d/git.vhosts",
- "puppet:///modules/git/xinetd.d/git.vhosts" ],
- }
- }
}
diff --git a/manifests/debian.pp b/manifests/debian.pp
new file mode 100644
index 0000000..8eaa778
--- /dev/null
+++ b/manifests/debian.pp
@@ -0,0 +1,5 @@
+class git::debian inherits git::base {
+ Package['git'] {
+ name => 'git-core',
+ }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
index 812830c..3afce8d 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -12,9 +12,14 @@
#
class git {
- include git::base
- if $use_shorewall {
- include shorewall::rules::out::git
- }
+ case $operatingsystem {
+ debian: { include git::debian }
+ centos: { include git::centos }
+ }
+
+ if $use_shorewall {
+ include shorewall::rules::out::git
+ }
+
}