Skip to content

Instantly share code, notes, and snippets.

@wataru420
Created February 7, 2012 03:54
Show Gist options
  • Save wataru420/1757063 to your computer and use it in GitHub Desktop.
Save wataru420/1757063 to your computer and use it in GitHub Desktop.
Jenkins init script for centos
/usr/sbin/groupadd -g 30119 jenkins
/usr/sbin/useradd -u 30119 -g jenkins jenkins
mkdir /home/jenkins
chown -R jenkins. /home/jenkins
chown -R jenkins. /usr/local/jenkins
chmod a+x /usr/local/jenkins/start-jenkins.sh
chmod a+x /usr/local/jenkins/stop-jenkins.sh
chmod a+x /etc/init.d/jenkins
wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
sudo mkdir /usr/local/jenkins
sudo cp jenkins.war /usr/local/jenkins/
#! /bin/bash
#
# jenkins Start/Stop the Jenkins Continuous Integration server.
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
startup=/usr/local/jenkins/start-jenkins.sh
shutdown=/usr/local/jenkins/stop-jenkins.sh
export JAVA_HOME=/usr/local/java/
JENKINS_USER=jenkins
start(){
echo -n $"Starting Jenkins service: "
su - $JENKINS_USER -c $startup
RETVAL=$?
echo
}
stop(){
action $"Stopping Jenkins service: "
su - $JENKINS_USER -c $shutdown
RETVAL=$?
echo
}
status(){
numproc=`ps -ef | grep [j]enkins.war | wc -l`
if [ $numproc -gt 0 ]; then
echo "Jenkins is running..."
else
echo "Jenkins is stopped..."
fi
}
restart(){
stop
sleep 5
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
#!/bin/bash
JENKINS_WAR=/usr/local/jenkins/jenkins.war
JENKINS_LOG=/home/jenkins/jenkins.log
JAVA=/usr/local/java/bin/java
nohup nice $JAVA -jar $JENKINS_WAR > $JENKINS_LOG 2>&1 &
#!/bin/bash
kill `ps -ef | grep [j]enkins.war | awk '{ print $2 }'`
@jasonm23
Copy link

jasonm23 commented Aug 6, 2013

Nice - Maybe add as a inital point:

 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

To re-route 8080 to 80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment