Gentoo - Jenkins startup script

Posted on Wed 19 September 2012 in Linux • 1 min read

Not the best but its working for me...maybe JENKINS_* and JAVA_OPTS can be moved to /etc/conf.d/jenkins or something else.

#!/sbin/runscript

depend() {
        use logger dns
        need apache2
        provide jenkins
}

JENKINS_USER=jenkins
LOCKFILE=/var/run/jenkins.pid

JENKINS_HOME=/home/jenkins
JAVA_HOME=/usr/java/jdk1.6.0_25

JAVA_OPTS="-DJENKINS_HOME=${JENKINS_HOME}/jenkins-home -Xmx512m -Djava.awt.headless=true -server"

JENKINS_OPTS="--httpPort=8080 --httpListenAddress=127.0.0.1 --ajp13Port=-1"
JENKINS_OPTS="${JENKINS_OPTS} --logfile=${JENKINS_HOME}/jenkins.log"

ARGS="${JAVA_OPTS} -jar ${JENKINS_HOME}/jenkins.war ${JENKINS_OPTS}"

start() {
        ebegin "Starting ${SVCNAME}"
        start-stop-daemon --user ${JENKINS_USER} --make-pidfile --pidfile ${LOCKFILE}   
       --background -1 ${JENKINS_HOME}/jenkins-console.log -2 ${JENKINS_HOME}/jenkins-console.log   
       --start --exec ${JAVA_HOME}/bin/java -- ${ARGS}
        eend $?
}

stop() {
        ebegin "Stopping ${SVCNAME}"
        start-stop-daemon --stop --pidfile ${LOCKFILE} --exec ${JAVA_HOME}/bin/java
        eend $?
}