Skip to content

Instantly share code, notes, and snippets.

@leitu
Last active August 29, 2015 14:14
Show Gist options
  • Save leitu/33b93d7bac913d58755e to your computer and use it in GitHub Desktop.
Save leitu/33b93d7bac913d58755e to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Startup/shutdown script for Git Daemon
# chkconfig: 345 56 10
#
# description: Startup/shutdown script for Git Daemon
#
. /etc/init.d/functions
DAEMON=/usr/libexec/git-core/git-daemon
USER=gitdaemon
GROUP=git
BASE_PATH=/opt/gitrepo/
ARGS="--user=$USER --group=$GROUP --detach --base-path=$BASE_PATH"
prog=git-daemon
start () {
echo -n $"Starting $prog: "
# start daemon
daemon $DAEMON $ARGS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/git-daemon
return $RETVAL
}
stop () {
# stop daemon
echo -n $"Stopping $prog: "
killproc $DAEMON
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/git-daemon
}
restart() {
stop
start
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status $DAEMON
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 3
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment