]>
Commit | Line | Data |
---|---|---|
975e80c2 AG |
1 | #!/bin/sh |
2 | # | |
3 | # git-daemon git-daemon tcp daemon for git | |
4 | # | |
5 | # chkconfig: 345 90 25 | |
6 | # | |
7 | # description: git-daemon is a simple tcp daemon that serves git repositories | |
8 | # | |
9 | # $Id$ | |
10 | ||
11 | # Source function library | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
14 | # Get network config | |
15 | . /etc/sysconfig/network | |
16 | ||
17 | DAEMON_OPTS="--syslog" | |
18 | ||
19 | # Get service config - may override defaults | |
20 | [ -f /etc/sysconfig/git-daemon ] && . /etc/sysconfig/git-daemon | |
21 | ||
22 | # Check that networking is up. | |
23 | if is_yes "${NETWORKING}"; then | |
24 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
25 | msg_network_down git-daemon | |
26 | exit 1 | |
27 | fi | |
28 | else | |
29 | exit 0 | |
30 | fi | |
31 | ||
32 | start() { | |
33 | # Check if the service is already running? | |
34 | if [ ! -f /var/lock/subsys/git-daemon ]; then | |
35 | msg_starting git-daemon | |
36 | daemon --fork git-daemon $DAEMON_OPTS | |
37 | RETVAL=$? | |
38 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/git-daemon | |
39 | else | |
40 | msg_already_running git-daemon | |
41 | fi | |
42 | } | |
43 | ||
44 | stop() { | |
45 | if [ -f /var/lock/subsys/git-daemon ]; then | |
46 | # Stop daemons. | |
47 | msg_stopping git-daemon | |
48 | killproc git-daemon | |
49 | rm -f /var/lock/subsys/git-daemon | |
50 | else | |
51 | msg_not_running git-daemon | |
52 | fi | |
53 | } | |
54 | ||
55 | reload() { | |
56 | if [ -f /var/lock/subsys/git-daemon ]; then | |
57 | msg_reloading git-daemon | |
58 | killproc git-daemon -HUP | |
59 | RETVAL=$? | |
60 | else | |
61 | msg_not_running git-daemon | |
62 | RETVAL=7 | |
63 | fi | |
64 | } | |
65 | ||
66 | RETVAL=0 | |
67 | # See how we were called. | |
68 | case "$1" in | |
69 | start) | |
70 | start | |
71 | ;; | |
72 | stop) | |
73 | stop | |
74 | ;; | |
75 | restart) | |
76 | stop | |
77 | start | |
78 | ;; | |
79 | reload) | |
80 | reload | |
81 | ;; | |
82 | # ONLY if program allows reloading without stopping | |
83 | # otherwise include force-reload with 'reload' | |
84 | force-reload) | |
85 | reload | |
86 | ;; | |
87 | status) | |
88 | status git-daemon | |
89 | RETVAL=$? | |
90 | ;; | |
91 | *) | |
92 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" | |
93 | exit 3 | |
94 | esac | |
95 | ||
96 | exit $RETVAL |