Created
December 10, 2012 23:49
-
-
Save naga41/4254447 to your computer and use it in GitHub Desktop.
Revisions
-
naga41 created this gist
Dec 10, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ #!/bin/sh # # jenkins-slave: Launch a Jenkins BuildSlave instance on this node # # chkconfig: - 99 01 # description: Enable this node to fulfill build jobs # # Source function library. . /etc/rc.d/init.d/functions [ -f /etc/sysconfig/jenkins-slave ] && . /etc/sysconfig/jenkins-slave JENKINS_URL="http://example.com/" JENKINS_WORKDIR="/var/lib/jenkins" JENKINS_USER="jenkins" JENKINS_NODENAME="YOUR OWN NODENAME (e.g. exampleslave)" [ -n "$JENKINS_URL" ] || exit 0 [ -n "$JENKINS_WORKDIR" ] || exit 0 [ -n "$JENKINS_USER" ] || exit 0 [ -n "$JENKINS_NODENAME" ] || exit 0 prog=Jenkins-BuildSlave download_jar() { curl -s -o slave.jar $JENKINS_URL/jnlpJars/slave.jar || exit 0 } start() { cd $JENKINS_WORKDIR [ -f slave.jar ] || download_jar echo -n $"Starting $prog: " su - $JENKINS_USER sh -c "\ java -jar slave.jar \ -jnlpUrl $JENKINS_URL/computer/$JENKINS_NODENAME/slave-agent.jnlp \ >slave.log 2>&1 &" if [ $? = 0 ]; then echo '[OK]'; else echo '[NG]'; fi } stop() { echo -n $"Shutting down $prog: " PID=`ps -ef | grep '[j]ava -jar slave.jar' | awk '{print $2}'` [ -n "$PID" ] && kill $PID if [ $? = 0 ]; then echo '[OK]'; else echo '[NG]'; fi } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) stop start ;; status) status java ;; *) echo $"Usage: $0 {start|stop|restart|reload}" exit 1 esac exit 0