| 1 | #!/sbin/openrc-run |
| 2 | |
| 3 | : ${name:="$RC_SVCNAME"} |
| 4 | : ${cfgfile:="/etc/clsync/${RC_SVCNAME%%.*}.conf"} |
| 5 | |
| 6 | extra_started_commands="reload resync" |
| 7 | description_reload="Reread filter rules" |
| 8 | description_resync="Run full resync" |
| 9 | |
| 10 | command="/usr/bin/clsync" |
| 11 | command_background="yes" |
| 12 | pidfile="/run/$RC_SVCNAME.pid" |
| 13 | |
| 14 | if [ "$cfgfile" != '/NULL/' ]; then |
| 15 | required_files="$cfgfile" |
| 16 | fi |
| 17 | |
| 18 | start_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 | |
| 39 | reload() { |
| 40 | ebegin "Reloading $name filter rules" |
| 41 | start-stop-daemon --signal HUP --pidfile $pidfile |
| 42 | eend $? |
| 43 | } |
| 44 | |
| 45 | resync() { |
| 46 | ebegin "Executing $name full resync" |
| 47 | start-stop-daemon --signal 12 --pidfile $pidfile |
| 48 | eend $? |
| 49 | } |