Skip to content

Instantly share code, notes, and snippets.

@moziauddin
Created August 31, 2021 03:20
Show Gist options
  • Save moziauddin/285a583c6099951910e4c550bae27da7 to your computer and use it in GitHub Desktop.
Save moziauddin/285a583c6099951910e4c550bae27da7 to your computer and use it in GitHub Desktop.
Run jenkins in Tomcat as jenkins User
#!/bin/sh
DESC="Jenkins CI Server"
NAME=jenkins
PIDFILE=/var/run/$NAME.pid
RUN_AS=jenkins
JENKINS_LOGFILE=/opt/jenkins/jenkins-log-2020.log
COMMAND="/opt/jenkins/apps/apache-tomcat-9.0.27/bin/startup.sh"
d_start() {
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND
}
d_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE
if [ -e $PIDFILE ]
then rm $PIDFILE
fi
}
case $1 in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_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