4 # Required-Start: $network $remote_fs $syslog
5 # Required-Stop: $network $remote_fs $syslog
6 # Default-Start: 2 3 4 5
8 # Short-Description: git-daemon service
9 # Description: git-daemon is a simple server for git repositories,
10 # ideally suited for read-only updates, i.e. pulling from
11 # git repositories through the network.
14 # PATH should only include /usr/* if it runs after the mountnfs.sh script
15 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/git-core
16 DESC="git-daemon service"
18 DAEMON=/usr/lib/git-core/$NAME
19 PIDFILE=/var/run/$NAME.pid
20 SCRIPTNAME=/etc/init.d/$NAME
22 # Exit if the package is not installed
23 [ -x $DAEMON ] || exit 0
25 # Read configuration variable file if it is present
26 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
28 GIT_DAEMON_USER=${GIT_DAEMON_USER:-gitdaemon}
29 GIT_DAEMON_DIRECTORY=${GIT_DAEMON_DIRECTORY:-/var/cache/git}
31 DAEMON_ARGS="--user=$GIT_DAEMON_USER --reuseaddr --syslog --verbose $GIT_DAEMON_OPTIONS --base-path=$GIT_DAEMON_DIRECTORY $GIT_DAEMON_DIRECTORY"
33 # Load the VERBOSE setting and other rcS variables
36 # Define LSB log_* functions.
37 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
38 . /lib/lsb/init-functions
41 # Function that starts the daemon/service
46 # 0 if daemon has been started
47 # 1 if daemon was already running
48 # 2 if daemon could not be started
49 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
51 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile -- \
57 # Function that stops the daemon/service
62 # 0 if daemon has been stopped
63 # 1 if daemon was already stopped
64 # 2 if daemon could not be stopped
65 # other if a failure occurred
66 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
68 [ "$RETVAL" = 2 ] && return 2
69 # Wait for children to finish too if this is a daemon that forks
70 # and if the daemon is only ever run from this initscript.
71 # If the above conditions are not satisfied then add some other code
72 # that waits for the process to drop all resources that could be
73 # needed by services started subsequently. A last resort is to
74 # sleep for some time.
75 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
76 [ "$?" = 2 ] && return 2
77 # Many daemons don't delete their pidfiles when they exit.
84 if [ $GIT_DAEMON_ENABLE = true ]; then
85 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
87 [ "$VERBOSE" != no ] && log_warning_msg "$NAME not enabled in /etc/default/$NAME, not starting..."
93 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
94 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
98 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
101 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
102 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
106 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
108 restart|force-reload)
109 log_daemon_msg "Restarting $DESC" "$NAME"
116 1) log_end_msg 1 ;; # Old process is still running
117 *) log_end_msg 1 ;; # Failed to start
127 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2