From a6e4c8952b6564976b3baabe8765502b422459e6 Mon Sep 17 00:00:00 2001 From: Elizabeth Krumbach Joseph Date: Tue, 20 Aug 2013 15:54:37 -0700 Subject: [PATCH] Swap git daemon in xinetd for service Add git-daemon init file to /etc/init.d and make sure the service is started. For transition, keep the git xinetd file and service defined but switch git service to stopped, we can remove this later. Change-Id: I0cf02c7292496e39695b80b00cdcb82ec7a61700 --- modules/cgit/files/git.xinetd | 2 +- modules/cgit/manifests/init.pp | 16 +++++- modules/cgit/templates/git-daemon.init.erb | 63 ++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 modules/cgit/templates/git-daemon.init.erb diff --git a/modules/cgit/files/git.xinetd b/modules/cgit/files/git.xinetd index d427f235d9..4f6081da67 100644 --- a/modules/cgit/files/git.xinetd +++ b/modules/cgit/files/git.xinetd @@ -4,7 +4,7 @@ service git { - disable = no + disable = yes socket_type = stream wait = no user = nobody diff --git a/modules/cgit/manifests/init.pp b/modules/cgit/manifests/init.pp index b3c52025b3..913c9ddc1c 100644 --- a/modules/cgit/manifests/init.pp +++ b/modules/cgit/manifests/init.pp @@ -18,6 +18,7 @@ class cgit( $vhost_name = $::fqdn, $serveradmin = "webmaster@${::fqdn}", $cgitdir = '/var/www/cgit', + $daemon_port = '29418', $staticfiles = '/var/www/cgit/static', $ssl_cert_file = '', $ssl_key_file = '', @@ -119,10 +120,23 @@ class cgit( } service { 'xinetd': - ensure => running, + ensure => stopped, subscribe => File['/etc/xinetd.d/git'], } + file { '/etc/init.d/git-daemon': + ensure => present, + owner => 'root', + group => 'root', + mode => '0755', + content => template('cgit/git-daemon.init.erb'), + } + + service { 'git-daemon': + ensure => running, + subscribe => File['/etc/init.d/git-daemon'], + } + if $ssl_cert_file_contents != '' { file { $ssl_cert_file: owner => 'root', diff --git a/modules/cgit/templates/git-daemon.init.erb b/modules/cgit/templates/git-daemon.init.erb new file mode 100644 index 0000000000..d45e17c233 --- /dev/null +++ b/modules/cgit/templates/git-daemon.init.erb @@ -0,0 +1,63 @@ +#!/bin/sh +# +# Startup/shutdown script for the git daemon +# chkconfig: 345 56 10 +# +# description: Startup/shutdown script for the git daemon +# +. /etc/init.d/functions + +NAME=git-daemon +USER=nobody +DAEMON=/usr/libexec/git-core/git-daemon +GIT_REPO=/var/lib/git +PORT=<%= scope.lookupvar("cgit::daemon_port") %> +ARGS="--base-path=/var/lib/git --user=$USER --export-all --syslog --detach --verbose --port=$PORT $GIT_REPO" + +start () { + echo -n $"Starting $NAME: " + + # start daemon + daemon $DAEMON $ARGS + RETVAL=$? + echo + [ $RETVAL = 0 ] && touch /var/lock/git-daemon + return $RETVAL +} + +stop () { + # stop daemon + + echo -n $"Stopping $NAME: " + killproc $DAEMON + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f /var/lock/git-daemon +} + +restart() { + stop + start +} + +case $1 in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + status) + status $DAEMON + RETVAL=$? + ;; + *) + echo $"Usage: $NAME {start|stop|restart|status}" + exit 3 + ;; +esac + +exit $RETVAL