forked from antonyx/jenkins-slave-jnlp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins-slave.init.d.sh
94 lines (80 loc) · 2.2 KB
/
jenkins-slave.init.d.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
### BEGIN INIT INFO
# Provides: jenkins-slave
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Jenkins Slave at boot time
# Description: Controls Jenkins Continuous Integration Slave
### END INIT INFO
# chkconfig: 2345 20 80
# description: Jenkins Continuous Integration Slave
# processname: jenkins-slave
# pidfile: ${JENKINS_WRKSPC}/.slave.pid
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DESC="Jenkins Continuous Integration Slave Server"
NAME=jenkins-slave
SCRIPTNAME=/etc/init.d/$NAME
JENKINS_USER="${JENKINS_USER}"
JENKINS_HOME="${JENKINS_HOME}"
PIDFILE="${JENKINS_WRKSPC}/.slave.pid"
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
DAEMON=/usr/bin/daemon
DAEMON_ARGS="-r ${JENKINS_HOME}/slave.jnlp.sh"
# load environments
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG LANGUAGE
elif [ -r /etc/environment ]; then
. /etc/environment
export LANG LANGUAGE
fi
# Load the VERBOSE setting and other rcS variables
if [ -e /lib/init/vars.sh ]; then
. /lib/init/vars.sh
fi
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
if [ -e /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi
# Source function library.
if [ -e /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
export PATH=$PATH:/usr/bin:/usr/local/bin
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting $NAME: "
su -s /bin/sh -l $JENKINS_USER -c "$DAEMON $DAEMON_ARGS"
RETVAL=$?
echo
# [ $RETVAL = 0 ] && touch $LOCKFILE
;;
stop)
# Stop daemons.
echo -n "Shutting down $NAME: "
su -s /bin/sh -l $JENKINS_USER -c "$DAEMON $DAEMON_ARGS stop"
RETVAL=$?
echo
# [ $RETVAL = 0 ] && rm -f $LOCKFILE
;;
restart)
$0 stop
sleep 1
$0 start
;;
condrestart)
# [ -e $LOCKFILE ] && $0 restart
;;
status)
# status -p ${PIDFILE} jenkins
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0