add new olsrd init script and default config by Alina Friedrichsen

git-svn-id: svn://svn.openwrt.org/openwrt/packages@12553 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2008-09-08 12:42:13 +00:00
parent d429799665
commit eb3fc330bb
4 changed files with 512 additions and 313 deletions

View File

@ -107,7 +107,7 @@ endef
define Package/olsrd/install define Package/olsrd/install
$(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/olsr.config $(1)/etc/config/olsr $(INSTALL_DATA) ./files/olsrd.config $(1)/etc/config/olsrd
$(INSTALL_DATA) $(PKG_BUILD_DIR)/src/cfgparser/olsrd.conf.example $(1)/etc/olsrd.conf $(INSTALL_DATA) $(PKG_BUILD_DIR)/src/cfgparser/olsrd.conf.example $(1)/etc/olsrd.conf
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd $(1)/usr/sbin/

View File

@ -1,47 +0,0 @@
config "olsr" "general"
option DebugLevel '0'
option IpVersion '4'
option AllowNoInt 'yes'
option Pollrate '0.025'
option TcRedundancy '2'
option MprCoverage '3'
option LinkQualityFishEye '1'
option LinkQualityWinSize '100'
option LinkQualityDijkstraLimit '0 9.0'
option LinkQualityLevel '2'
option UseHysteresis 'no'
option FIBMetric "flat"
option ClearScreen "yes"
option Willingness "3"
option LinkQualityAging "0.1"
option LinkQualityAlgorithm "etx_fpm"
config "LoadPlugin" "arprefresh"
option Library 'olsrd_arprefresh.so.0.1'
config "LoadPlugin" "dyn_gw_plain"
option Library 'olsrd_dyn_gw_plain.so.0.4'
config "LoadPlugin" "nameservice"
option Library 'olsrd_nameservice.so.0.3'
option name 'sven-ola-gs'
option hosts_file '/var/etc/hosts'
option suffix '.olsr'
option latlon_infile '/var/run/latlon.txt'
config "LoadPlugin" "txtinfo"
option Library 'olsrd_txtinfo.so.0.1'
option Accept '127.0.0.1'
config "Interface"
option Interface "wlan"
option Ip4Broadcast "255.255.255.255"
option HelloInterval '2.0'
option HelloValidityTime '40.0'
option TcInterval '5.0'
option TcValidityTime '100.0'
option MidInterval '18.0'
option MidValidityTime '324.0'
option HnaInterval '18.0'
option HnaValidityTime '108.0'

View File

@ -0,0 +1,23 @@
config olsrd
option IpVersion '4'
config LoadPlugin
option library 'olsrd_arprefresh.so.0.1'
config LoadPlugin
option library 'olsrd_dyn_gw.so.0.4'
config LoadPlugin
option library 'olsrd_httpinfo.so.0.1'
option port '1978'
list Net '0.0.0.0 0.0.0.0'
config LoadPlugin
option library 'olsrd_nameservice.so.0.3'
config LoadPlugin
option library 'olsrd_txtinfo.so.0.1'
option accept ''
config Interface
list interface 'wlan'

View File

@ -1,331 +1,554 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# Copyright (C) 2008 Alina Friedrichsen <x-alina@gmx.net>
# Special thanks to bittorf wireless ))
START=50 START=50
BIN=olsrd OLSRD_OLSRD_SCHEMA='ignore:internal config_file:internal DebugLevel=0 IpVersion=4 AllowNoInt:bool=1 Pollrate=0.025 TcRedundancy=2 MprCoverage=3 LinkQualityFishEye=1 LinkQualityWinSize=100 LinkQualityDijkstraLimit=0+9.0 LinkQualityLevel=2 UseHysteresis:bool=0 FIBMetric=flat ClearScreen:bool=1 Willingness=3 LinkQualityAging=0.1 LinkQualityAlgorithm=etx_fpm'
CONF_F=/var/etc/olsrd.conf OLSRD_IPCCONNECT_SCHEMA='ignore:internal Host:list Net:list2'
USE_CONF_F= OLSRD_LOADPLUGIN_SCHEMA='ignore:internal library:internal Host:list Net:list2 Ping:list redistribute:list NonOlsrIf:list name:list lat lon latlon_infile HNA:list2 hosts:list2'
DEFAULT=/etc/default/olsrd OLSRD_INTERFACE_SCHEMA='ignore:internal interface:internal AutoDetectChanges:bool Ip4Broadcast=255.255.255.255 HelloInterval=2.0 HelloValidityTime=40.0 TcInterval=5.0 TcValidityTime=100.0 MidInterval=18.0 MidValidityTime=324.0 HnaInterval=18.0 HnaValidityTime=108.0'
RUN_D=/var/run
PID_F=$RUN_D/$BIN.pid
format_olsr_option() { T=' '
local str="$*" N='
echo -n "$str" | tr -d '\n\r\t\v ' '
validate_varname() {
local varname=$1
[ -z "$varname" -o "$varname" != "${varname%%[!A-Za-z0-9_]*}" ] && return 1
return 0
} }
format_olsr_value() { validate_ifname() {
local str="$*" local ifname=$1
echo -n "$str" | tr -d '\n\r\v' [ -z "$ifname" -o "$ifname" != "${ifname%%[!A-Za-z0-9.:_-]*}" ] && return 1
return 0
} }
format_olsr_param() { validate_olsrd_option() {
local str="$*" local str=$1
echo -n "$str" | tr -d '\n\r\v"' [ -z "$str" -o "$str" != "${str%%[! 0-9A-Za-z./:_-]*}" ] && return 1
return 0
} }
format_uci_varname() { get_ifname() {
local str="$*" IFNAME=
echo -n "$str" | sed -e 's/[^a-zA-Z0-9_]//g' local interface=$1
validate_varname "$interface" || return 1
local ifname
config_get ifname "$interface" ifname
validate_ifname "$ifname" || return 1
IFNAME=$ifname
return 0
} }
foreach_olsr() { system_config() {
local cfg="$1" local cfg=$1
local option local cfgt
local value local hostname
local latlon
for option in $CONFIG_OPTIONS config_get cfgt "$cfg" TYPE
do
config_get value "$cfg" "$option"
option=$(format_olsr_option "$option")
value=$(format_olsr_value "$value")
if [ -n "$value" -a "$option" != "ConfigFile" ]; then if [ "$cfgt" = "system" ]; then
echo "$option $value" >> "$CONF_F" config_get hostname "$cfg" hostname
hostname=${hostname:-OpenWrt}
SYSTEM_HOSTNAME=$hostname
fi
if [ -z "$SYSTEM_LAT" -o -z "$SYSTEM_LON" ]; then
config_get latlon "$cfg" latlon
IFS=" ${T}${N},"
set -- $latlon
unset IFS
SYSTEM_LAT=$1
SYSTEM_LON=$2
fi
}
olsrd_find_config_file() {
local cfg=$1
validate_varname "$cfg" || return 0
config_get_bool ignore "$cfg" ignore 0
[ "$ignore" -ne 0 ] && return 0
config_get OLSRD_CONFIG_FILE "$cfg" config_file
return 0
}
warning_invalid_value() {
local package=$1
validate_varname "$package" || package=
local config=$2
validate_varname "$config" || config=
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
fi
echo ", skipped" 1>&2
return 0
}
olsrd_write_option() {
local param=$1
local cfg=$2
validate_varname "$cfg" || return 1
local option=$3
validate_varname "$option" || return 1
local value=$4
local option_type=$5
if [ "$option_type" = bool ]; then
case "$value" in
1|on|true|enabled|yes) value=yes;;
0|off|false|disabled|no) value=no;;
*) warning_invalid_value olsrd "$cfg" "$option"; return 1;;
esac
fi
if ! validate_olsrd_option "$value"; then
warning_invalid_value olsrd "$cfg" "$option"
return 1
fi
if [ "$value" != "${value%%[G-Zg-z_-]*}" ]; then
if [ "$value" != "yes" -a "$value" != "no" ]; then
value="\"$value\""
fi fi
fi
echo -n "${N}$param$option $value"
return 0
}
olsrd_write_plparam() {
local param=$1
local cfg=$2
validate_varname "$cfg" || return 1
local option=$3
validate_varname "$option" || return 1
local value=$4
local option_type=$5
local _option
if [ "$option_type" = bool ]; then
case "$value" in
1|on|true|enabled|yes) value=yes;;
0|off|false|disabled|no) value=no;;
*) warning_invalid_value olsrd "$cfg" "$option"; return 1;;
esac
fi
if ! validate_olsrd_option "$value"; then
warning_invalid_value olsrd "$cfg" "$option"
return 1
fi
IFS='-_'
set -- $option
option="$*"
unset IFS
_option="$option"
if [ "$option" = 'hosts' ]; then
set -- $value
option=$1
shift
value="$*"
fi
echo -n "${N}${param}PlParam \"$option\" \"$value\""
return 0
}
config_update_schema() {
unset IFS
local schema_varname=$1
validate_varname "$schema_varname" || return 1
local command=$2
validate_varname "$command" || return 1
local option=$3
validate_varname "$option" || return 1
local value=$4
local schema
local cur_option
case "$varname" in
*_LENGTH) return 0;;
*_ITEM*) return 0;;
esac
eval "export -n -- \"schema=\${$schema_varname}\""
for cur_option in $schema; do
[ "${cur_option%%[:=]*}" = "$option" ] && return 0
done done
echo >> "$CONF_F"
}
foreach_Hna4() { if [ "$command" = list ]; then
local cfg="$1" set -- $value
local netaddr if [ "$#" -ge "3" ]; then
local netmask schema_entry="$option:list3"
elif [ "$#" -ge "2" ]; then
config_get netaddr "$cfg" NetAddr schema_entry="$option:list2"
config_get netmask "$cfg" NetMask else
netaddr=$(format_olsr_option "$netaddr") schema_entry="$option:list"
netmask=$(format_olsr_option "$netmask")
if [ -n "$netaddr" -a -n "$netmask" ]; then
if [ "$HNA4_COUNT" -le 0 ]; then
echo "Hna4" >> "$CONF_F"
echo "{" >> "$CONF_F"
fi fi
else
echo " $netaddr $netmask" >> "$CONF_F" schema_entry="$option"
HNA4_COUNT=$((HNA4_COUNT + 1))
fi fi
append "$schema_varname" "$schema_entry"
return 0
} }
write_Hna4() { config_write_options() {
if [ "$HNA4_COUNT" -gt 0 ]; then unset IFS
echo "}" >> "$CONF_F" local schema=$1
echo >> "$CONF_F" local cfg=$2
fi validate_varname "$cfg" || return 1
} local write_func=$3
[ -z "$write_func" ] && output_func=echo
foreach_Hna6() { local write_param=$4
local cfg="$1" local schema_entry
local netaddr
local netmask
config_get netaddr "$cfg" NetAddr
config_get prefix "$cfg" Prefix
netaddr=$(format_olsr_option "$netaddr")
prefix=$(format_olsr_option "$prefix")
if [ -n "$netaddr" -a -n "$prefix" ]; then
if [ "$HNA6_COUNT" -le 0 ]; then
echo "Hna6" >> "$CONF_F"
echo "{" >> "$CONF_F"
fi
echo " $netaddr $prefix" >> "$CONF_F"
HNA6_COUNT=$((HNA6_COUNT + 1))
fi
}
write_Hna6() {
if [ "$HNA6_COUNT" -gt 0 ]; then
echo "}" >> "$CONF_F"
echo >> "$CONF_F"
fi
}
foreach_IpcConnect() {
local cfg="$1"
local option local option
local option_length
local option_type
local default
local value local value
local c local list_size
local list_item
local list_value
local i
local position
echo "IpcConnect" >> "$CONF_F" for schema_entry in $schema; do
echo -n "{" >> "$CONF_F" default=${schema_entry#*[=]}
[ "$default" = "$schema_entry" ] && default=
for option in $CONFIG_OPTIONS option=${schema_entry%%[=]*}
do IFS=':'
set -- $option
unset IFS
option=$1
option_type=$2
validate_varname "$option" || continue
[ -z "$option_type" ] || validate_varname "$option_type" || continue
[ "$option_type" = internal ] && continue
config_get value "$cfg" "$option" config_get value "$cfg" "$option"
option=$(format_olsr_option "$option")
value=$(format_olsr_value "$value")
if [ -n "$value" ]; then if [ -z "$value" ]; then
if [ "$option" = "Host" ]; then IFS='+'
for item in $value set -- $default
do unset IFS
echo >> "$CONF_F" value=$*
echo -n " $option $item" >> "$CONF_F" elif [ "$value" = '-' -a -n "$default" ]; then
done continue
elif [ "$option" = "Net" ]; then fi
c=0
for item in $value [ -z "$value" ] && continue
do
if [ $((c % 2)) -eq 0 ]; then case "$option_type" in
echo >> "$CONF_F" list) list_size=1;;
echo -n " $option $item" >> "$CONF_F" list2) list_size=2;;
else list3) list_size=3;;
echo -n " $item" >> "$CONF_F" *) list_size=0;;
fi esac
c=$((c + 1))
if [ "$list_size" -gt 0 ]; then
config_get option_length "$cfg" "${option}_LENGTH"
if [ -n "$option_length" ]; then
i=1
while [ "$i" -le "$option_length" ]; do
config_get list_value "$cfg" "${option}_ITEM$i"
"$write_func" "$write_param" "$cfg" "$option" "$list_value" "$option_type" || break
i=$((i + 1))
done done
else else
echo >> "$CONF_F" list_value=
echo -n " $option $value" >> "$CONF_F" i=0
for list_item in $value; do
append "list_value" "$list_item"
i=$((i + 1))
position=$((i % list_size))
if [ "$position" -eq 0 ]; then
"$write_func" "$write_param" "$cfg" "$option" "$list_value" "$option_type" || break
list_value=
fi
done
[ "$position" -ne 0 ] && "$write_func" "$write_param" "$cfg" "$option" "$list_value" "$option_type"
fi fi
else
"$write_func" "$write_param" "$cfg" "$option" "$value" "$option_type"
fi fi
done done
echo >> "$CONF_F" return 0
echo "}" >> "$CONF_F"
echo >> "$CONF_F"
} }
foreach_LoadPlugin() { olsrd_write_olsrd() {
local cfg="$1" local cfg=$1
local library validate_varname "$cfg" || return 0
local option local ignore
local value
local is_ip_addr
local item
local c
config_get library "$cfg" Library config_get_bool ignore "$cfg" ignore 0
library=$(format_olsr_param "$library") [ "$ignore" -ne 0 ] && return 0
if [ -n "$library" ]; then [ "$OLSRD_COUNT" -gt 0 ] && return 0
echo "LoadPlugin \"$library\"" >> "$CONF_F"
echo -n "{" >> "$CONF_F"
for option in $CONFIG_OPTIONS config_write_options "$OLSRD_OLSRD_SCHEMA" "$cfg" olsrd_write_option
do echo
config_get value "$cfg" "$option" OLSRD_COUNT=$((OLSRD_COUNT + 1))
option=$(format_olsr_param "$option")
value=$(format_olsr_param "$value")
if [ -n "$value" ]; then return 0
option=$(echo "$option" | sed -e y/[_]/[-]/) }
is_ip_addr=$(echo "$option" | sed -e 's/[^-]//g') olsrd_write_ipcconnect() {
if [ "$is_ip_addr" = "---" ]; then local cfg=$1
option=$(echo "$option" | sed -e y/[-]/[.]/) validate_varname "$cfg" || return 0
fi local ignore
if [ "$option" = "Ping" -o "$option" = "redistribute" -o "$option" = "Host" -o "$option" = "NonOlsrIf" -o "$option" = "name" -o "$is_ip_addr" = "---" ]; then config_get_bool ignore "$cfg" ignore 0
for item in $value [ "$ignore" -ne 0 ] && return 0
do
echo >> "$CONF_F" [ "$IPCCONNECT_COUNT" -gt 0 ] && return 0
echo -n " PlParam \"$option\" \"$item\"" >> "$CONF_F"
done echo -n "${N}IpcConnect${N}{"
elif [ "$option" = "Net" -o "$option" = "HNA" ]; then config_write_options "$OLSRD_IPCCONNECT_SCHEMA" "$cfg" olsrd_write_option "${T}"
c=0 echo "${N}}"
for item in $value IPCCONNECT_COUNT=$((IPCCONNECT_COUNT + 1))
do
if [ $((c % 2)) -eq 0 ]; then return 0
echo >> "$CONF_F" }
echo -n " PlParam \"$option\" \"$item" >> "$CONF_F"
else olsrd_write_hna4() {
echo -n " $item\"" >> "$CONF_F" local cfg=$1
fi validate_varname "$cfg" || return 0
c=$((c + 1)) local ignore
done
elif [ "$option" != "Library" ]; then config_get_bool ignore "$cfg" ignore 0
echo >> "$CONF_F" [ "$ignore" -ne 0 ] && return 0
echo -n " PlParam \"$option\" \"$value\"" >> "$CONF_F"
config_get netaddr "$cfg" netaddr
if ! validate_olsrd_option "$netaddr"; then
warning_invalid_value olsrd "$cfg" "netaddr"
return 0
fi
config_get netmask "$cfg" netmask
if ! validate_olsrd_option "$netmask"; then
warning_invalid_value olsrd "$cfg" "netmask"
return 0
fi
[ "$HNA4_COUNT" -le 0 ] && echo -n "${N}Hna4${N}{"
echo -n "${N}${T}$netaddr $netmask"
HNA4_COUNT=$((HNA4_COUNT + 1))
return 0
}
olsrd_write_hna6() {
local cfg=$1
validate_varname "$cfg" || return 0
local ignore
config_get_bool ignore "$cfg" ignore 0
[ "$ignore" -ne 0 ] && return 0
config_get netaddr "$cfg" netaddr
if ! validate_olsrd_option "$netaddr"; then
warning_invalid_value olsrd "$cfg" "netaddr"
return 0
fi
config_get prefix "$cfg" prefix
if ! validate_olsrd_option "$prefix"; then
warning_invalid_value olsrd "$cfg" "prefix"
return 0
fi
[ "$HNA6_COUNT" -le 0 ] && echo -n "${N}Hna6${N}{"
echo -n "${N}${T}$netaddr $prefix"
HNA6_COUNT=$((HNA6_COUNT + 1))
return 0
}
olsrd_write_loadplugin() {
local cfg=$1
validate_varname "$cfg" || return 0
local ignore
local name
local suffix
local lat
local lon
local latlon_infile
config_get_bool ignore "$cfg" ignore 0
[ "$ignore" -ne 0 ] && return 0
config_get library "$cfg" library
if ! validate_olsrd_option "$library"; then
warning_invalid_value olsrd "$cfg" "library"
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
return 0
fi
case "$library" in
olsrd_nameservice.*)
config_get name "$cfg" name
[ -z "$name" ] && config_set "$cfg" name $SYSTEM_HOSTNAME
config_get suffix "$cfg" suffix
[ -z "$suffix" ] && config_set "$cfg" suffix '.olsr'
config_get lat "$cfg" lat
config_get lon "$cfg" lon
config_get latlon_infile "$cfg" latlon_infile
if [ \( -z "$lat" -o -z "$lat" \) -a -z "$latlon_infile" ]; then
if [ -f '/var/run/latlon.txt' ]; then
config_set "$cfg" lat ''
config_set "$cfg" lon ''
config_set "$cfg" latlon_infile '/var/run/latlon.txt'
else
config_set "$cfg" lat "$SYSTEM_LAT"
config_set "$cfg" lon "$SYSTEM_LON"
fi fi
fi fi
done
echo >> "$CONF_F" config_get latlon_file "$cfg" latlon_file
echo "}" >> "$CONF_F" [ -z "$latlon_file" ] && config_set "$cfg" latlon_file '/var/run/latlon.js'
echo >> "$CONF_F" ;;
fi esac
echo -n "${N}LoadPlugin \"$library\"${N}{"
config_write_options "$OLSRD_LOADPLUGIN_SCHEMA" "$cfg" olsrd_write_plparam "${T}"
echo "${N}}"
return 0
} }
foreach_Interface() { olsrd_write_interface() {
local cfg="$1" local cfg=$1
validate_varname "$cfg" || return 0
local ignore
local interfaces local interfaces
local interface local interface
local ifname local ifnames
local option
local value
local item
local c
config_get interfaces "$cfg" Interface config_get_bool ignore "$cfg" ignore 0
[ "$ignore" -ne 0 ] && return 0
if [ -n "$interfaces" ]; then ifnames=
echo -n "Interface" >> "$CONF_F" config_get interfaces "$cfg" interface
for interface in $interfaces; do
for interface in $interfaces if validate_varname "$interface"; then
do if get_ifname "$interface"; then
interface=$(format_uci_varname "$interface") ifnames="$ifnames \"$IFNAME\""
config_get ifnames "$interface" ifname else
for ifname in $ifnames echo "Warning: Interface '$interface' not found, skipped" 1>&2
do
ifname=$(format_olsr_param "$ifname")
echo -n " \"$ifname\"" >> "$CONF_F"
done
done
echo >> "$CONF_F"
echo -n "{" >> "$CONF_F"
for option in $CONFIG_OPTIONS
do
config_get value "$cfg" "$option"
option=$(format_olsr_option "$option")
value=$(format_olsr_value "$value")
if [ -n "$value" ]; then
if [ "$option" = "LinkQualityMult" ]; then
c=0
for item in $value
do
if [ $((c % 2)) -eq 0 ]; then
echo >> "$CONF_F"
echo -n " $option $item" >> "$CONF_F"
else
echo -n " $item" >> "$CONF_F"
fi
c=$((c + 1))
done
elif [ "$option" != "Interface" ]; then
echo >> "$CONF_F"
echo -n " $option $value" >> "$CONF_F"
fi
fi fi
done else
warning_invalid_value olsrd "$cfg" "interface"
fi
done
echo >> "$CONF_F" [ -z "$ifnames" ] && return 0
echo "}" >> "$CONF_F"
fi echo -n "${N}Interface$ifnames${N}{"
config_write_options "$OLSRD_INTERFACE_SCHEMA" "$cfg" olsrd_write_option "${T}"
echo "${N}}"
INTERFACES_COUNT=$((INTERFACES_COUNT + 1))
return 0
} }
write_config() { olsrd_update_schema() {
include /lib/network local command="$1"
scan_interfaces validate_varname "$command" || return 0
config_load /var/state/network local varname="$2"
validate_varname "$varname" || return 0
local value="$3"
local cfg="$CONFIG_SECTION"
local cfgt
local cur_varname
config_cb() { config_get cfgt "$cfg" TYPE
local cfgtype="$1" case "$cfgt" in
local name="$2" olsrd) config_update_schema OLSRD_OLSRD_SCHEMA "$command" "$varname" "$value";;
CONFIG_TYPE="$cfgtype" IpcConnect) config_update_schema OLSRD_IPCCONNECT_SCHEMA "$command" "$varname" "$value";;
} LoadPlugin) config_update_schema OLSRD_LOADPLUGIN_SCHEMA "$command" "$varname" "$value";;
Interface) config_update_schema OLSRD_INTERFACE_SCHEMA "$command" "$varname" "$value";;
esac
option_cb() { return 0
local varname="$1" }
local value="$2"
if [ "$CONFIG_TYPE" = "OLSR" -a "$varname" = "ConfigFile" ]; then olsrd_write_config() {
USE_CONF_F="$value" OLSRD_COUNT=0
fi config_foreach olsrd_write_olsrd olsrd
IPCCONNECT_COUNT=0
if ! echo "$CONFIG_OPTIONS" | grep " $varname " > /dev/null; then config_foreach olsrd_write_ipcconnect IpcConnect
CONFIG_OPTIONS="$CONFIG_OPTIONS $varname "
fi
}
CONFIG_OPTIONS=""
config_load olsr
if [ -n "$USE_CONF_F" ]; then
return 0
else
USE_CONF_F="$CONF_F"
fi
mkdir -p $(dirname "$CONF_F")
> "$CONF_F"
config_foreach foreach_olsr olsr
HNA4_COUNT=0 HNA4_COUNT=0
config_foreach foreach_Hna4 Hna4 config_foreach olsrd_write_hna4 Hna4
write_Hna4 [ "$HNA4_COUNT" -gt 0 ] && echo "${N}}"
HNA6_COUNT=0 HNA6_COUNT=0
config_foreach foreach_Hna6 Hna6 config_foreach olsrd_write_hna6 Hna6
write_Hna6 [ "$HNA6_COUNT" -gt 0 ] && echo "${N}}"
config_foreach foreach_IpcConnect IpcConnect config_foreach olsrd_write_loadplugin LoadPlugin
config_foreach foreach_LoadPlugin LoadPlugin INTERFACES_COUNT=0
config_foreach foreach_Interface Interface config_foreach olsrd_write_interface Interface
echo
return 0
} }
start() { start() {
[ -z "$USE_CONF_F" ] && write_config SYSTEM_HOSTNAME=
SYSTEM_LAT=
SYSTEM_LON=
config_load system
config_foreach system_config system
[ -f $DEFAULT ] && . $DEFAULT option_cb() {
$BIN -f "$USE_CONF_F" -nofork $OPTIONS & olsrd_update_schema "option" "$@"
}
# write pid file (but strip out own pid ($$)) list_cb() {
mkdir -p $RUN_D olsrd_update_schema "list" "$@"
PID=`pidof $BIN` }
echo ${PID%$$} > $PID_F
include /lib/network
scan_interfaces
config_load olsrd
reset_cb
OLSRD_CONFIG_FILE=
config_foreach olsrd_find_config_file olsrd
if [ -z "$OLSRD_CONFIG_FILE" ]; then
mkdir -p -- /var/etc/
olsrd_write_config > /var/etc/olsrd.conf
if [ "$INTERFACES_COUNT" -gt 0 -a "$OLSRD_COUNT" -gt 0 ]; then
OLSRD_CONFIG_FILE=/var/etc/olsrd.conf
fi
fi
[ -z "$OLSRD_CONFIG_FILE" ] && return 1
olsrd -f "$OLSRD_CONFIG_FILE" -nofork < /dev/null > /dev/null &
} }
stop() { stop() {