mirror of
https://github.com/openwrt/packages.git
synced 2025-02-12 03:28:07 +00:00
31ae85bca9
Makefile changes include: * Remove USE_UCLIBC, as uclibc is no longer supported * Package output modules * Move main binary (back) to /usr/sbin, as it is system administration related and requires superuser privileges New patches: * 003-add-space-for-null-byte.patch - from374cfd2cab
* 004-more-specific-library-linking.patch - from27b57d9da3
* 005-use-c99-format-macro-constants.patch - from https://github.com/fln/addrwatch/pull/28 Init script changes include: * Change from explicit disable to explicit enable, so that the service is disabled by default and on first install * Set config option default values to default values of the main binary * Fix command-line option names and format (from https://forum.openwrt.org/t/cant-start-addrwatch-service/60499/3) * Always use the --quiet command-line option, as the procd instance is not configured to capture stdout/stderr * Change the syslog config option to start the syslog output module Signed-off-by: Jeffery To <jeffery.to@gmail.com>
81 lines
2.1 KiB
Bash
81 lines
2.1 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2016 OpenWrt.org
|
|
|
|
START=50
|
|
USE_PROCD=1
|
|
|
|
validate_section_addrwatch() {
|
|
uci_load_validate addrwatch addrwatch "$1" "$2" \
|
|
'enabled:bool:0' \
|
|
'interface:list(string):lan' \
|
|
'syslog:bool:0' \
|
|
'output:string' \
|
|
'verbose:bool:0' \
|
|
'ipv4only:bool:0' \
|
|
'ipv6only:bool:0' \
|
|
'blacklist:list(or(ip4addr,ip6addr))' \
|
|
'hashsize:range(1,65536):1'\
|
|
'ratelimit:integer:0'
|
|
}
|
|
|
|
start_instance() {
|
|
local cfg="$1"
|
|
local netdevs=""
|
|
|
|
[ "$2" = 0 ] || {
|
|
echo "validation of config $cfg failed"
|
|
return 1
|
|
}
|
|
[ $enabled -eq 1 ] || return 1
|
|
|
|
for iface in $interface; do
|
|
local netdev
|
|
network_get_physdev netdev "$iface"
|
|
append netdevs "$netdev"
|
|
done
|
|
|
|
procd_open_instance
|
|
procd_set_param command /usr/sbin/addrwatch --quiet
|
|
[ -n "$output" ] && procd_append_param command "--output=$output"
|
|
[ "$verbose" -eq 1 ] && procd_append_param command "--verbose"
|
|
[ "$ipv4only" -eq 1 ] && procd_append_param command "--ipv4-only"
|
|
[ "$ipv6only" -eq 1 ] && procd_append_param command "--ipv6-only"
|
|
[ -n "$hashsize" ] && procd_append_param command "--hashsize=$hashsize"
|
|
[ -n "$ratelimit" ] && procd_append_param command "--ratelimit=$ratelimit"
|
|
for blitem in $blacklist; do
|
|
procd_append_param command "--blacklist=$blitem"
|
|
done
|
|
procd_append_param command $netdevs
|
|
procd_set_param netdev $netdevs
|
|
procd_set_param respawn
|
|
procd_open_trigger
|
|
for iface in $interface; do
|
|
procd_add_interface_trigger "interface.*" $iface /etc/init.d/addrwatch reload
|
|
done
|
|
procd_close_trigger
|
|
procd_close_instance
|
|
|
|
[ "$syslog" -eq 1 ] && {
|
|
if [ -x /usr/sbin/addrwatch_syslog ]; then
|
|
procd_open_instance
|
|
procd_set_param command /usr/sbin/addrwatch_syslog
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
else
|
|
echo "Cannot find /usr/sbin/addrwatch_syslog" >&2
|
|
echo "Install the addrwatch-syslog package to enable syslog output" >&2
|
|
fi
|
|
}
|
|
}
|
|
|
|
start_service() {
|
|
. /lib/functions/network.sh
|
|
config_load 'addrwatch'
|
|
config_foreach validate_section_addrwatch 'addrwatch' start_instance
|
|
}
|
|
|
|
service_triggers() {
|
|
procd_add_reload_trigger 'addrwatch'
|
|
procd_add_validation validate_section_addrwatch
|
|
}
|