Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Startup script for the Jenkins Continuous Integration server for Amazon EC2 Linux (via jar execution)
#!/bin/sh
#
# Startup script for the Jenkins Continuous Integration server for Amazon EC2 Linux
# (via jar execution)
#
# chkconfig: - 85 15
# description: Jenkins Continuous Integration Server
# processname: jenkins
# pidfile: /var/run/jenkins.pid
JENKINS_USER=ec2-user
LOCKFILE=/var/lock/jenkins
export M2_HOME=/home/ec2-user/apache-maven-3.1.1
export M2=$M2_HOME/bin
export ANT_HOME=/usr/share/ant
export PATH=$M2:/usr/local/bin:$PATH
export HOME=/home/ec2-user
export JAVA_HOME=/usr/java/jdk1.7.0_51/
export JAVA_OPTS="-Xms64m -Xmx320m -Djava.awt.headless=true"
# NOTE: By default Jenkins creates .jenkins directory on home dir
# export JENKINS_BASEDIR=/home/jenkins
export PATH=$PATH:/usr/bin:/usr/local/bin
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting Jenkins: "
su -p -s /bin/sh $JENKINS_USER -c "java $JAVA_OPTS -jar /home/ec2-user/jenkins.war > /dev/null 2>&1 &"
PID=$$
RETVAL=$?
echo
[ $RETVAL = 0 ] && echo $PID > $LOCKFILE
;;
stop)
# Stop daemons.
echo -n "Shutting down Jenkins: "
su -p -s /bin/sh $JENKINS_USER -c "kill $(cat $LOCKFILE)"
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $LOCKFILE
;;
restart)
$0 stop
$0 start
;;
condrestart)
[ -e $LOCKFILE ] && $0 restart
;;
status)
status tomcat
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment