projects/aports·blob master · refs

49 lines · 1.1 KiB

1#!/sbin/openrc-run
2
3: ${name:="$RC_SVCNAME"}
4: ${cfgfile:="/etc/clsync/${RC_SVCNAME%%.*}.conf"}
5
6extra_started_commands="reload resync"
7description_reload="Reread filter rules"
8description_resync="Run full resync"
9
10command="/usr/bin/clsync"
11command_background="yes"
12pidfile="/run/$RC_SVCNAME.pid"
13
14if [ "$cfgfile" != '/NULL/' ]; then
15 required_files="$cfgfile"
16fi
17
18start_pre() {
19 local config_block output
20
21 if grep -q '^background\s*=\s*1' "$cfgfile" 2>/dev/null; then
22 ewarn "$cfgfile shouldn't set background = 1, it will make init script unreliable!"
23 fi
24
25 if [ -z "$config_block" ] && [ "${RC_SVCNAME#*.}" != "$RC_SVCNAME" ]; then
26 config_block=${RC_SVCNAME#*.}
27 fi
28 if [ -z "$output_log$error_log" ]; then
29 output='syslog'
30 fi
31
32 command_args="
33 --config-file $cfgfile
34 ${config_block:+"--config-block $config_block"}
35 ${output:+"--output $output"}
36 $command_args"
37}
38
39reload() {
40 ebegin "Reloading $name filter rules"
41 start-stop-daemon --signal HUP --pidfile $pidfile
42 eend $?
43}
44
45resync() {
46 ebegin "Executing $name full resync"
47 start-stop-daemon --signal 12 --pidfile $pidfile
48 eend $?
49}