diff options
Diffstat (limited to 'community/clsync/clsync.initd')
-rw-r--r-- | community/clsync/clsync.initd | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/community/clsync/clsync.initd b/community/clsync/clsync.initd new file mode 100644 index 0000000000..97b9b50f94 --- /dev/null +++ b/community/clsync/clsync.initd @@ -0,0 +1,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 $? +} |