akitaonrails (owner)

Revisions

gist: 14047 Download_button fork
public
Description:
CentOS init script for Gitorious' git-daemon
Public Clone URL: git://gist.github.com/14047.git
Embed All Files: show embed
Bash #
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
#
# Init file for Gitorious GIT-Daemon daemon
#
# chkconfig: 2345 55 25
# description: GIT-Daemon server daemon
#
# processname: git-daemon
# pidfile: /var/www/gitorious/log/git-daemon.pid
 
# source function library
. /etc/rc.d/init.d/functions
 
RETVAL=0
GIT_DAEMON="/opt/ruby-enterprise/bin/ruby /var/www/gitorious/script/git-daemon -d"
LOCK_FILE=/var/lock/git-daemon
PID_FILE=/var/www/gitorious/log/git-daemon.pid
 
do_check_pid() {
if [ -f $PID_FILE ]; then
PID=`cat $PID_FILE`
RUNNING=`ps --pid $PID | wc -l`
else
PID=0
RUNNING=0
fi
}
 
runlevel=$(set -- $(runlevel); eval "echo \$$#" )
 
start()
{
do_check_pid
if [ $RUNNING != 2 ] ; then
echo -n $"Starting $PROG: "
                /bin/su - git -c "$GIT_DAEMON"
sleep 1
if [ -f $PID_FILE ] ; then
success
else
failure
fi
RETVAL=$?
else
echo -n $"$PROG already running"
failure
fi
[ "$RETVAL" = 0 ] && touch $LOCK_FILE
echo
}
 
stop()
{
do_check_pid
echo -n $"Stopping $PROG: "
if [ $RUNNING != 2 ] ; then
failure $"Stopping $PROG"
else
killproc -p $PID_FILE
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
killproc -p $PID 2>/dev/null
fi
[ "$RETVAL" = 0 ] && rm -f $LOCK_FILE
echo
}
 
case "$1" in
start)
start
;;
stop)
stop
;;
    restart)
        stop
        start
        ;;
condrestart)
if [ -f $LOCK_FILE ] ; then
if [ "$RETVAL" = 0 ] ; then
stop
# avoid race
sleep 5
start
fi
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart}"
RETVAL=1
esac
exit $RETVAL