]> git.pld-linux.org Git - packages/gitlab-runner.git/blame - gitlab-ci-multi-runner.init
add initscripts from upstream repo
[packages/gitlab-runner.git] / gitlab-ci-multi-runner.init
CommitLineData
af21cb3e
ER
1#! /bin/bash
2
3### BEGIN INIT INFO
4# Provides: gitlab-ci-multi-runner
5# Required-Start: $local_fs $remote_fs $network $syslog
6# Required-Stop: $local_fs $remote_fs $network $syslog
7# Default-Start: 2 3 4 5
8# Default-Stop: 0 1 6
9# Short-Description: GitLab CI-Multi Runner init.d script
10# Description: Enables automatic start of runners at boot time in the background.
11### END INIT INFO
12
13DESC="GitLab CI-Multi Runner"
14USER="gitlab_ci_multi_runner"
15GROUP="gitlab_ci_multi_runner"
16CHDIR="~$USER"
17NAME="gitlab-ci-multi-runner"
18DAEMON="/usr/bin/gitlab-ci-multi-runner"
19PIDFILE="/var/run/gitlab-ci-multi-runner.pid"
20LOGFILE="/var/log/gitlab-ci-multi-runner.log"
21
22# Exit if the package is not installed
23if [ ! -x "$DAEMON" ]; then
24 echo "$DAEMON not present or not executable"
25 exit 1
26fi
27
28# Read configuration variable file if it is present
29[ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
31# Define LSB log_* functions.
32. /lib/lsb/init-functions
33
34## Check to see if we are running as root first.
35if [ "$(id -u)" != "0" ]; then
36 echo "This script must be run as root"
37 exit 1
38fi
39
40eval CHDIR=$CHDIR
41
42do_start() {
43 start-stop-daemon --start \
44 --pidfile "$PIDFILE" \
45 --chdir "$CHDIR" \
46 --background \
47 --make-pidfile \
48 --chuid "$USER:$GROUP" \
49 --no-close \
50 --exec "$DAEMON" -- "run" &>> $LOGFILE
51}
52
53do_stop() {
54 start-stop-daemon --stop --pidfile "$PIDFILE" --user "$USER" --exec "$DAEMON" --quiet
55}
56
57case "$1" in
58 start)
59 log_daemon_msg "Starting $DESC"
60 do_start
61 log_end_msg $?
62 ;;
63 stop)
64 log_daemon_msg "Stopping $DESC"
65 do_stop
66 log_end_msg $?
67 ;;
68 restart)
69 $0 stop
70 $0 start
71 ;;
72 status)
73 status_of_proc -p "$PIDFILE" "$DAEMON" "$DESC"
74 ;;
75 *)
76 echo "Usage: sudo service gitlab-ci-multi-runner {start|stop|restart|status}" >&2
77 exit 1
78 ;;
79esac
80
81exit 0
This page took 0.101205 seconds and 4 git commands to generate.