Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Init.d script for Jenkins-CI standalone (Tested on Ubuntu 14.04)
#! /bin/sh
#/etc/init.d/jenkins
### BEGIN INIT INFO
# Provides: Jenkins-CI
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Jenkins-server daemon
# Description: "Jenkins CI Server"
### END INIT INFO
NAME=jenkins
RUN_AS=jenkins
HTTP_PORT=8089
LOGFILE=/var/log/jenkins.log
JAVA_HOME="/home/jenkins/jdk1.7.0_80"
JAVA_OPTS="-server -Xmn128M -Xms256M -Xmx256M -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF8 -Duser.timezone=Europe/Tallinn"
JENKINS_HOME="/home/jenkins/jenkins_std"
COMMAND="nohup $JAVA_HOME/bin/java $JAVA_OPTS -jar $JENKINS_HOME/jenkins.war --httpPort=$HTTP_PORT > $LOGFILE 2>&1 &"
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_start()
{
su $RUN_AS -s /bin/bash -c "$COMMAND"
return 0
}
do_stop() {
pkill -u $RUN_AS
return 0
}
case $1 in
'start')
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
'stop')
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
'restart')
echo -n "Restarting $DESC: $NAME"
do_stop
sleep 1
do_start
echo "."
;;
*)
echo "usage: $NAME {start|stop|restart}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.