-
-
Save dkinzer/cc57a7e87792456162a31c7109840e81 to your computer and use it in GitHub Desktop.
Jenkins init script for centos
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 characters
/usr/sbin/groupadd -g 30119 jenkins | |
/usr/sbin/useradd -u 30119 -g jenkins jenkins | |
mkdir /home/jenkins | |
chown -R jenkins. /home/jenkins |
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 characters
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 |
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 characters
wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war | |
sudo mkdir /usr/local/jenkins | |
sudo cp jenkins.war /home/jenkins/ |
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 characters
#! /usr/bin/env 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 | |
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 |
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 characters
#!/usr/bin/env bash | |
JENKINS_WAR=/home/jenkins/jenkins.war | |
JENKINS_LOG=/home/jenkins/jenkins.log | |
JAVA=/bin/java | |
nohup nice $JAVA -jar $JENKINS_WAR --prefix=/jenkins > $JENKINS_LOG 2>&1 & |
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 characters
#!/usr/bin/env bash | |
kill `ps -ef | grep [j]enkins.war | awk '{ print $2 }'` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment