]> git.pld-linux.org Git - packages/gitlab-runner.git/blob - gitlab-ci-multi-runner.init
misc sysv fixes
[packages/gitlab-runner.git] / gitlab-ci-multi-runner.init
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
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 DESC="GitLab CI-Multi Runner"
13 USER="gitlab-runner"
14 GROUP="gitlab-runner"
15 CHDIR="/var/lib/gitlab-runner"
16 NAME="gitlab-ci-multi-runner"
17 DAEMON="/usr/bin/gitlab-runner"
18 PIDFILE="/var/run/gitlab-ci-multi-runner.pid"
19 LOGFILE="/var/log/gitlab-ci-multi-runner.log"
20
21 # Read configuration variable file if it is present
22 [ -f /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
23
24 do_start() {
25         start-stop-daemon --start \
26                 --pidfile "$PIDFILE" \
27                 --chdir "$CHDIR" \
28                 --background \
29                 --make-pidfile \
30                 --chuid "$USER:$GROUP" \
31                 --exec "$DAEMON" -- "run" >> $LOGFILE 2>&1
32 }
33
34 do_stop() {
35         start-stop-daemon --stop --pidfile "$PIDFILE" --user "$USER" --exec "$DAEMON" --quiet
36 }
37
38 okfail() {
39         if [ "$1" = 0 ]; then
40                 ok
41         else
42                 fail
43         fi
44 }
45
46 start() {
47         # Check if the service is already running?
48         if [ -f /var/lock/subsys/$NAME ]; then
49                 msg_already_running "$DESC"
50                 return
51         fi
52
53         msg_starting "$DESC"
54         do_start
55         RETVAL=$?
56         okfail $RETVAL
57         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
58 }
59
60 stop() {
61         if [ ! -f /var/lock/subsys/$NAME ]; then
62                 msg_not_running "$DESC"
63                 return
64         fi
65
66         # Stop daemons.
67         msg_stopping "$DESC"
68         do_stop
69         okfail $?
70         rm -f /var/lock/subsys/$NAME
71 }
72
73 condrestart() {
74         if [ ! -f /var/lock/subsys/$NAME ]; then
75                 msg_not_running "$DESC"
76                 RETVAL=$1
77                 return
78         fi
79
80         stop
81         start
82 }
83
84 RETVAL=0
85 # See how we were called.
86 case "$1" in
87   start)
88         start
89         ;;
90   stop)
91         stop
92         ;;
93   restart)
94         stop
95         start
96         ;;
97   try-restart)
98         condrestart 0
99         ;;
100   force-reload)
101         condrestart 7
102         ;;
103   status)
104         status --pidfile $PIDFILE $NAME
105         RETVAL=$?
106         ;;
107   *)
108         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
109         exit 3
110 esac
111
112 exit $RETVAL
This page took 0.037857 seconds and 3 git commands to generate.