#!/bin/bash # # Init file for git daemon # # chkconfig: 2345 55 25 # description: git server daemon # # processname: git-daemon # pidfile: /var/run/git.pid # # NOTE. on f14 at least git daemon comes linked with xinetd # however as we had written this for f8, and as I don't feel # comfy with xinetd on top of chkconfig, # I turned off xinetd and still use this one on f14 as well # source function library . /etc/rc.d/init.d/functions # pull in sysconfig settings [ -f /etc/sysconfig/git ] && . /etc/sysconfig/git RETVAL=0 prog="git-daemon" # Some functions to make the below more readable # previous location (f8) #GIT=/usr/bin/git-daemon # for f14 GIT=/usr/libexec/git-core/git-daemon PID_FILE=/var/run/git-daemon.pid # override OPTIONS altogether for more flexibility OPTIONS=${OPTIONS:- --pid-file=${PID_FILE} --base-path=${GITDIR} --port=${PORT} ${VERBOSE} ${DETACH} ${SYSLOG} ${EXPORT} ${GITWHITELIST}} runlevel=$(set -- $(runlevel); eval "echo \$$#" ) start() { echo -n $"Starting $prog: " $GIT $OPTIONS && success || failure RETVAL=$? [ "$RETVAL" = 0 ] && touch /var/lock/subsys/git echo } stop() { echo -n $"Stopping $prog: " if [ -n "`pidfileofproc $GIT`" ] ; then killproc $GIT else failure $"Stopping $prog" fi RETVAL=$? # if we are in halt or reboot runlevel kill all running sessions # so the TCP connections are closed cleanly if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then killall $prog 2>/dev/null fi [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/git echo } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; condrestart) if [ -f /var/lock/subsys/git ] ; then if [ "$RETVAL" = 0 ] ; then stop # avoid race sleep 3 start fi fi ;; status) status -p $PID_FILE git-daemon RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL