summaryrefslogtreecommitdiff
path: root/files/init.d/CentOS/git-daemon
blob: aed20756a94d9cf9a21daa606a0c9a974adf20fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# puppet        Init script for running the git-daemon
#
# Author:       Marcel Haerry <mh+rpms(at)immerda.ch>
#
# 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}
user=${GITUSER-nobody}
options=${OPTIONS-"--reuseaddr --verbose --detach"}
gitdaemon=${GITDAEMON-/usr/bin/git-daemon}
RETVAL=0

gitoptions="--user=${user} ${options}"
if [ $gitvhost = yes ]; then
	gitoptions="${gitoptions} --interpolated-path=${gitdir}/%H/%D"
else
	gitoptions="${gitoptions} --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