Skip to content

Commit

Permalink
Merge branch 'master' of github.com:defunkt/cijoe
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Oct 25, 2009
2 parents 3ef5aa9 + 1eca495 commit eebb94c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
53 changes: 53 additions & 0 deletions examples/cijoed
@@ -0,0 +1,53 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: cijoe
# Required-Start: $syslog $local_fs $network
# Required-Stop: $syslog $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1
# Description: Run the CIJoe CI server. Yo Joe!!
### END INIT INFO

. /lib/lsb/init-functions

REPO=/path/to/your/git/repository
PORT=4567

NAME=cijoe
INSTALL_DIR=/usr/sbin
DAEMON=$INSTALL_DIR/$NAME
DAEMON_ARGS="-p $PORT $REPO"
PIDFILE=/var/run/$NAME.pid
DAEMON_USER=www-data
DAEMON_GROUP=$DAEMON_USER

# test -f $DAEMON || exit 0
# test -f $PROJECT_DIR || exit 0

case "$1" in
start)
log_daemon_msg "Starting cijoe" "cijoe"
start-stop-daemon --background --make-pidfile --exec $DAEMON --start --name $NAME --pidfile $PIDFILE --chuid $DAEMON_USER:$DAEMON_GROUP -- $DAEMON_ARGS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping cijoe" "cijoe"
start-stop-daemon --stop --pidfile $PIDFILE --quiet --retry 10
log_end_msg $?
;;
restart)
log_daemon_msg "Restarting cijoe" "cijoe"
start-stop-daemon --stop --pidfile $PIDFILE --quiet --retry 10
start-stop-daemon --background --make-pidfile --exec $DAEMON --start --name $NAME --pidfile $PIDFILE --chuid $DAEMON_USER:$DAEMON_GROUP -- $DAEMON_ARGS
log_end_msg $?
;;
status)
status_of_proc $DAEMON $NAME && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/cijoe (start|stop|restart)"
exit 2
;;
esac

exit 0
9 changes: 8 additions & 1 deletion lib/cijoe.rb
Expand Up @@ -129,7 +129,14 @@ def git_branch
# massage our repo
def run_hook(hook)
if File.exists?(file=".git/hooks/#{hook}") && File.executable?(file)
`sh #{file}`
data = {
"MESSAGE" => @last_build.commit.message,
"AUTHOR" => @last_build.commit.author,
"SHA" => @last_build.commit.sha,
"OUTPUT" => @last_build.clean_output
}
env = data.collect { |k, v| %(#{k}=#{v.inspect}) }.join(" ")
`#{env} sh #{file}`
end
end
end

0 comments on commit eebb94c

Please sign in to comment.