aboutsummaryrefslogtreecommitdiffstats
path: root/community/clsync/clsync.initd
blob: 97b9b50f9491991d922ae16cf5dbef2b4b2a45cd (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
#!/sbin/openrc-run

: ${name:="$RC_SVCNAME"}
: ${cfgfile:="/etc/clsync/${RC_SVCNAME%%.*}.conf"}

extra_started_commands="reload resync"
description_reload="Reread filter rules"
description_resync="Run full resync"

command="/usr/bin/clsync"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"

if [ "$cfgfile" != '/NULL/' ]; then
	required_files="$cfgfile"
fi

start_pre() {
	local config_block output

	if grep -q '^background\s*=\s*1' "$cfgfile" 2>/dev/null; then
		ewarn "$cfgfile shouldn't set background = 1, it will make init script unreliable!"
	fi

	if [ -z "$config_block" ] && [ "${RC_SVCNAME#*.}" != "$RC_SVCNAME" ]; then
		config_block=${RC_SVCNAME#*.}
	fi
	if [ -z "$output_log$error_log" ]; then
		output='syslog'
	fi

	command_args="
		--config-file $cfgfile
		${config_block:+"--config-block $config_block"}
		${output:+"--output $output"}
		$command_args"
}

reload() {
	ebegin "Reloading $name filter rules"
	start-stop-daemon --signal HUP --pidfile $pidfile
	eend $?
}

resync() {
	ebegin "Executing $name full resync"
	start-stop-daemon --signal 12 --pidfile $pidfile
	eend $?
}