]> git.pld-linux.org Git - packages/gitlab-runner.git/blame - gitlab-runner.init
rename to gitlab-runner as upstream, version 10.0
[packages/gitlab-runner.git] / gitlab-runner.init
CommitLineData
50a69960
ER
1#!/bin/sh
2#
8264fff3 3# gitlab-runner GitLab Runner
50a69960
ER
4#
5# chkconfig: 345 20 80
6# description: Enables automatic start of runners at boot time in the background
8264fff3 7# processname: gitlab-runner
af21cb3e 8
50a69960
ER
9# Source function library
10. /etc/rc.d/init.d/functions
af21cb3e 11
8264fff3 12DESC="GitLab Runner"
50a69960
ER
13USER="gitlab-runner"
14GROUP="gitlab-runner"
15CHDIR="/var/lib/gitlab-runner"
8264fff3 16NAME="gitlab-runner"
ea381f69 17DAEMON="/usr/bin/gitlab-runner"
8264fff3
ER
18PIDFILE="/var/run/gitlab-runner.pid"
19LOGFILE="/var/log/gitlab-runner.log"
af21cb3e 20
af21cb3e 21# Read configuration variable file if it is present
50a69960 22[ -f /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
af21cb3e 23
50a69960
ER
24do_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
34do_stop() {
35 start-stop-daemon --stop --pidfile "$PIDFILE" --user "$USER" --exec "$DAEMON" --quiet
36}
af21cb3e 37
89c5c179
ER
38okfail() {
39 if [ "$1" = 0 ]; then
40 ok
41 else
42 fail
43 fi
44}
45
50a69960
ER
46start() {
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
af21cb3e 52
50a69960
ER
53 msg_starting "$DESC"
54 do_start
55 RETVAL=$?
89c5c179 56 okfail $RETVAL
50a69960 57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
af21cb3e
ER
58}
59
50a69960
ER
60stop() {
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
89c5c179 69 okfail $?
50a69960
ER
70 rm -f /var/lock/subsys/$NAME
71}
72
73condrestart() {
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
af21cb3e
ER
82}
83
7b2edca7
ER
84# run gitlab-runner register with proper uid/gid
85register() {
86 runuser -u "$USER" -g "$GROUP" gitlab-runner "$@"
87}
88
50a69960
ER
89RETVAL=0
90# See how we were called.
af21cb3e
ER
91case "$1" in
92 start)
50a69960
ER
93 start
94 ;;
af21cb3e 95 stop)
50a69960
ER
96 stop
97 ;;
af21cb3e 98 restart)
50a69960
ER
99 stop
100 start
101 ;;
102 try-restart)
103 condrestart 0
104 ;;
105 force-reload)
106 condrestart 7
107 ;;
7b2edca7
ER
108 register)
109 register "$@"
110 ;;
af21cb3e 111 status)
4bd75c48 112 status --pidfile $PIDFILE $NAME
50a69960
ER
113 RETVAL=$?
114 ;;
af21cb3e 115 *)
7b2edca7 116 msg_usage "$0 {start|stop|restart|try-restart|force-reload|register|status}"
50a69960 117 exit 3
af21cb3e
ER
118esac
119
50a69960 120exit $RETVAL
This page took 0.092763 seconds and 4 git commands to generate.