]>
Commit | Line | Data |
---|---|---|
50a69960 ER |
1 | #!/bin/sh |
2 | # | |
3 | # gitlab-ci-multi-runner GitLab CI-Multi Runner | |
4 | # | |
5 | # chkconfig: 345 20 80 | |
6 | # description: Enables automatic start of runners at boot time in the background | |
7 | # processname: gitlab-ci-multi-runner | |
af21cb3e | 8 | |
50a69960 ER |
9 | # Source function library |
10 | . /etc/rc.d/init.d/functions | |
af21cb3e ER |
11 | |
12 | DESC="GitLab CI-Multi Runner" | |
50a69960 ER |
13 | USER="gitlab-runner" |
14 | GROUP="gitlab-runner" | |
15 | CHDIR="/var/lib/gitlab-runner" | |
af21cb3e ER |
16 | NAME="gitlab-ci-multi-runner" |
17 | DAEMON="/usr/bin/gitlab-ci-multi-runner" | |
18 | PIDFILE="/var/run/gitlab-ci-multi-runner.pid" | |
19 | LOGFILE="/var/log/gitlab-ci-multi-runner.log" | |
20 | ||
af21cb3e | 21 | # Read configuration variable file if it is present |
50a69960 | 22 | [ -f /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME |
af21cb3e | 23 | |
50a69960 ER |
24 | do_start() { |
25 | start-stop-daemon --start \ | |
26 | --pidfile "$PIDFILE" \ | |
27 | --chdir "$CHDIR" \ | |
28 | --background \ | |
29 | --make-pidfile \ | |
30 | --chuid "$USER:$GROUP" \ | |
50a69960 ER |
31 | --exec "$DAEMON" -- "run" >> $LOGFILE 2>&1 |
32 | } | |
af21cb3e | 33 | |
50a69960 ER |
34 | do_stop() { |
35 | start-stop-daemon --stop --pidfile "$PIDFILE" --user "$USER" --exec "$DAEMON" --quiet | |
36 | } | |
af21cb3e | 37 | |
50a69960 ER |
38 | start() { |
39 | # Check if the service is already running? | |
40 | if [ -f /var/lock/subsys/$NAME ]; then | |
41 | msg_already_running "$DESC" | |
42 | return | |
43 | fi | |
af21cb3e | 44 | |
50a69960 ER |
45 | msg_starting "$DESC" |
46 | do_start | |
47 | RETVAL=$? | |
48 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME | |
af21cb3e ER |
49 | } |
50 | ||
50a69960 ER |
51 | stop() { |
52 | if [ ! -f /var/lock/subsys/$NAME ]; then | |
53 | msg_not_running "$DESC" | |
54 | return | |
55 | fi | |
56 | ||
57 | # Stop daemons. | |
58 | msg_stopping "$DESC" | |
59 | do_stop | |
60 | rm -f /var/lock/subsys/$NAME | |
61 | } | |
62 | ||
63 | condrestart() { | |
64 | if [ ! -f /var/lock/subsys/$NAME ]; then | |
65 | msg_not_running "$DESC" | |
66 | RETVAL=$1 | |
67 | return | |
68 | fi | |
69 | ||
70 | stop | |
71 | start | |
af21cb3e ER |
72 | } |
73 | ||
50a69960 ER |
74 | RETVAL=0 |
75 | # See how we were called. | |
af21cb3e ER |
76 | case "$1" in |
77 | start) | |
50a69960 ER |
78 | start |
79 | ;; | |
af21cb3e | 80 | stop) |
50a69960 ER |
81 | stop |
82 | ;; | |
af21cb3e | 83 | restart) |
50a69960 ER |
84 | stop |
85 | start | |
86 | ;; | |
87 | try-restart) | |
88 | condrestart 0 | |
89 | ;; | |
90 | force-reload) | |
91 | condrestart 7 | |
92 | ;; | |
af21cb3e | 93 | status) |
4bd75c48 | 94 | status --pidfile $PIDFILE $NAME |
50a69960 ER |
95 | RETVAL=$? |
96 | ;; | |
af21cb3e | 97 | *) |
50a69960 ER |
98 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" |
99 | exit 3 | |
af21cb3e ER |
100 | esac |
101 | ||
50a69960 | 102 | exit $RETVAL |