N='
'
+log()
+{
+ logger -t olsrd -p daemon.info -s "$1"
+}
+
validate_varname() {
local varname="$1"
[ -z "$varname" -o "$varname" != "${varname%%[!A-Za-z0-9_]*}" ] && return 1
}
warning_invalid_value() {
+ local funcname="warning_invalid_value"
local package="$1"
validate_varname "$package" || package=
local config="$2"
local option="$3"
validate_varname "$option" || option=
- echo -n "Warning: Invalid value" 1>&2
-
if [ -n "$package" -a -n "$config" ]; then
- echo -n " in option '$package.$config${option:+.}$option'" 1>&2
+ log "$funcname() in option '$package.$config${option:+.}$option', skipped"
+ else
+ log "$funcname() skipped"
fi
- echo ", skipped" 1>&2
-
return 0
}
}
olsrd_write_plparam() {
+ local funcname="olsrd_write_plparam"
local param="$1"
local cfg="$2"
validate_varname "$cfg" || return 1
if [ "$option" = 'NonOlsrIf' ]; then
if validate_varname "$value"; then
if network_get_device ifname "$value"; then
- echo "Info: mdns Interface '$value' ifname '$ifname' found" 1>&2
+ log "$funcname() Info: mdns Interface '$value' ifname '$ifname' found"
else
- echo "Warning: mdns Interface '$value' not found, skipped" 1>&2
+ log "$funcname() Warning: mdns Interface '$value' not found, skipped"
fi
else
warning_invalid_value olsrd "$cfg" "NonOlsrIf"
}
olsrd_write_loadplugin() {
+ local funcname="olsrd_write_loadplugin"
local cfg="$1"
validate_varname "$cfg" || return 0
local ignore
return 0
fi
if ! [ -x "/lib/$library" -o -x "/usr/lib/$library" -o -x "/usr/local/lib/$library" ]; then
- echo "Warning: Plugin library '$library' not found, skipped" 1>&2
+ log "$funcname() Warning: Plugin library '$library' not found, skipped"
return 0
fi
}
olsrd_write_interface() {
+ local funcname="olsrd_write_interface"
local cfg="$1"
validate_varname "$cfg" || return 0
local ignore
ifnames="$ifnames \"$IFNAME\""
ifsglobal="$ifsglobal $IFNAME"
else
- echo "Warning: Interface '$interface' not found, skipped" 1>&2
+ log "$funcname() Warning: Interface '$interface' not found, skipped"
fi
else
warning_invalid_value olsrd "$cfg" "interface"
}
olsrd_setup_smartgw_rules() {
+ local funcname="olsrd_setup_smartgw_rules"
# Check if ipip is installed
- [ ! -e /etc/modules.d/[0-9]*-ipip ] && echo "Warning: kmod-ipip is missing. SmartGateway will not work until you install it."
+ [ -e /etc/modules.d/[0-9]*-ipip ] || {
+ log "$funcname() Warning: kmod-ipip is missing. SmartGateway will not work until you install it."
+ }
wanifnames=$(ip r l e 0/0 t all | sed -e 's/^.* dev //' |cut -d " " -f 1 | sort | uniq)
nowan=0
while $IP4T -t nat -D postrouting_rule -o tnl_+ -j MASQUERADE 2> /dev/null; do :;done
if [ "$smartgateway" == "yes" ]; then
- echo "Notice: Inserting firewall rules for SmartGateway"
+ log "$funcname() Notice: Inserting firewall rules for SmartGateway"
if [ ! "$smartgatewayuplink" == "none" ]; then
if [ "$smartgatewayuplink" == "ipv4" ]; then
# Allow everything to be forwarded to tnl_+ and use NAT for it
}
error() {
- echo "${initscript}:" "$@" 1>&2
+ log "error() ${initscript}: $@"
}
start() {
SERVICE_PID_FILE="$PID6"
if service_check /usr/sbin/olsrd; then
- error "there already is an IPv6 instance of olsrd running ($(cat $PID6)), not starting."
+ error "there is already an IPv6 instance of olsrd running (pid: '$(cat $PID6)'), not starting."
else
service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv6 -nofork
fi
SERVICE_PID_FILE="$PID"
if service_check /usr/sbin/olsrd; then
- error "there already is an IPv4 instance of olsrd running ($(cat $PID)), not starting."
+ error "there is already an IPv4 instance of olsrd running (pid: '$(cat $PID)'), not starting."
else
service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv4 -nofork
fi
SERVICE_PID_FILE="$PID"
if service_check /usr/sbin/olsrd; then
- error "there already is an IPv4 instance of olsrd running ($(cat $PID)), not starting."
+ error "there is already an IPv4 instance of olsrd running (pid: '$(cat $PID)'), not starting."
return 1
else
service_start /usr/sbin/olsrd -f "$OLSRD_CONFIG_FILE" -nofork