diff options
-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-daemon | 22 | ||||
-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-daemon | 151 | ||||
-rw-r--r-- | manifests/base.pp | 3 | ||||
-rw-r--r-- | manifests/centos.pp | 2 | ||||
-rw-r--r-- | manifests/daemon.pp | 28 | ||||
-rw-r--r-- | manifests/daemon/base.pp | 30 | ||||
-rw-r--r-- | manifests/daemon/centos.pp | 19 | ||||
-rw-r--r-- | manifests/daemon/debian.pp | 11 | ||||
-rw-r--r-- | manifests/daemon/disable.pp | 18 | ||||
-rw-r--r-- | manifests/daemon/vhosts.pp | 10 | ||||
-rw-r--r-- | manifests/debian.pp | 5 | ||||
-rw-r--r-- | manifests/init.pp | 13 |
15 files changed, 274 insertions, 38 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..4edfe4c --- /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/lib/git-core/$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..ca89aac 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 0d22adf..33c0a26 100644 --- a/manifests/daemon.pp +++ b/manifests/daemon.pp @@ -1,32 +1,14 @@ class git::daemon { + include git - package{'git-daemon': - ensure => installed, - require => Package['git'], - } - file{'/etc/init.d/git-daemon': - source => [ "puppet://$server/modules/site-git/init.d/${fqdn}/git-daemon", - "puppet://$server/modules/site-git/init.d/git-daemon", - "puppet://$server/modules/git/init.d/git-daemon" ], - require => Package['git-daemon'], - owner => root, group => 0, mode => 0755; - } - file{'/etc/sysconfig/git-daemon': - source => [ "puppet://$server/modules/site-git/sysconfig/${fqdn}/git-daemon", - "puppet://$server/modules/site-git/sysconfig/git-daemon", - "puppet://$server/modules/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'] ], + case $operatingsystem { + debian: { include git::daemon::debian } + centos: { include git::daemon::centos } } 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..940ae52 --- /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..758c9fe --- /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 6e01268..fe0c9b0 100644 --- a/manifests/daemon/disable.pp +++ b/manifests/daemon/disable.pp @@ -1,23 +1,29 @@ class git::daemon::disable inherits git::daemon { - Package['git-daemon']{ - ensure => absent, + + 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 4250a5e..d627df1 100644 --- a/manifests/daemon/vhosts.pp +++ b/manifests/daemon/vhosts.pp @@ -1,7 +1,9 @@ class git::daemon::vhosts inherits git::daemon { - File['/etc/sysconfig/git-daemon']{ - source => [ "puppet://$server/modules/site-git/sysconfig/${fqdn}/git-daemon.vhosts", - "puppet://$server/modules/site-git/sysconfig/git-daemon.vhosts", - "puppet://$server/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" ], } } diff --git a/manifests/debian.pp b/manifests/debian.pp new file mode 100644 index 0000000..1c17df9 --- /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 + } + } |