summaryrefslogtreecommitdiff
path: root/devel/gitea-act_runner/files/act_runner.in
blob: 119b92aca30090236eb012f2a499c80d3e1ec765 (plain) (blame)
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
#!/bin/sh

# PROVIDE: act_runner
# REQUIRE: NETWORKING SYSLOG
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable act_runner:
#
# act_runner_enable (bool):   Set to "NO" by default.
#                       Set it to "YES" to enable act_runner.

. /etc/rc.subr

name="act_runner"
rcvar="act_runner_enable"

load_rc_config "${name}"

: ${act_runner_user:="act_runner"}
: ${act_runner_enable:="NO"}
: ${act_runner_facility:="daemon"}
: ${act_runner_priority:="debug"}
: ${act_runner_config:="%%ETCDIR%%/act_runner.conf"}
: ${act_runner_cache_dir:="%%DATADIR%%"}
: ${act_runner_log_dir:="/var/log/act_runner"}
: ${act_runner_log_file:="${act_runner_log_dir}/act_runner.log"}
: ${act_runner_flags:="-c ${act_runner_config} daemon"}

procname="%%PREFIX%%/bin/act_runner"
command="/usr/sbin/daemon"

pidfile="/var/run/${name}.pid"

required_files=${act_runner_config}
command_args=" -r -S -l ${act_runner_facility} -s ${act_runner_priority} \
    -T ${name} \
    -u ${act_runner_user} -p ${pidfile} \
    -o ${act_runner_log_file} \
    ${procname} ${act_runner_flags}"

prestart_cmd="${name}_prestart"
sig_stop=TERM

act_runner_prestart() {
  #  ensure the log directories are owned by the unprivileged user
  for d in "${act_runner_log_dir}"; do
    if [ ! -e "$d" ]; then
      mkdir "$d"
      chown "${act_runner_user}" "$d"
    fi
  done
}

run_rc_command "$1"