Created
September 16, 2012 13:31
-
-
Save imrekel/3732466 to your computer and use it in GitHub Desktop.
Git daemon service script (for /etc/init.d) - used to enable public access for gitolite managed repositories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
NAME=git-daemon | |
PIDFILE=/var/run/$NAME.pid | |
DESC="the git daemon" | |
DAEMON=/usr/lib/git-core/git-daemon | |
DAEMON_OPTS="--base-path=/home/git/repositories --export-all --verbose --syslog --detach --p$ | |
test -x $DAEMON || exit 0 | |
[ -r /etc/default/git-daemon ] && . /etc/default/git-daemon | |
. /lib/lsb/init-functions | |
start_git() { | |
start-stop-daemon --start --quiet --pidfile $PIDFILE \ | |
--startas $DAEMON -- $DAEMON_OPTS | |
} | |
stop_git() { | |
start-stop-daemon --stop --quiet --pidfile $PIDFILE | |
rm -f $PIDFILE | |
} | |
status_git() { | |
start-stop-daemon --stop --test --quiet --pidfile $PIDFILE >/dev/null 2>&1 | |
} | |
case "$1" in | |
start) | |
log_begin_msg "Starting $DESC" | |
start_git | |
log_end_msg 0 | |
;; | |
stop) | |
log_begin_msg "Stopping $DESC" | |
stop_git | |
log_end_msg 0 | |
;; | |
status) | |
log_begin_msg "Testing $DESC: " | |
if status_git | |
then | |
log_success_msg "Running" | |
exit 0 | |
else | |
log_failure_msg "Not running" | |
exit 1 | |
fi | |
;; | |
restart|force-reload) | |
log_begin_msg "Restarting $DESC" | |
stop_git | |
sleep 1 | |
start_git | |
log_end_msg 0 | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment