overload init-skript's olsrd_write_loadplugin() with new function
find_most_recent_plugin_libary() - so now we can mix 'exact' and lazy
names. This change is backward compatible and now we have a better
migration strategy. This topic was hot again, after the latest updates
of a lot of plugins, resulting in non-working configs...
-olsrd_write_loadplugin() {
- local funcname="olsrd_write_loadplugin"
+find_most_recent_plugin_libary()
+{
+ local library="$1"
+ local file unixtime
+
+ for file in "/lib/$library"* "/usr/lib/$library"* "/usr/local/lib/$library"*; do {
+ [ -f "$file" ] && {
+ unixtime="$( date +%s -r "$file" )"
+ echo "$unixtime $file"
+ }
+ } done | sort -n | tail -n1 | cut -d' ' -f2
+}
+
+olsrd_write_loadplugin()
+{
+ local funcname='olsrd_write_loadplugin'
+ local ignore name suffix lat lon latlon_infile
+
validate_varname "$cfg" || return 0
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_bool ignore "$cfg" ignore 0
[ "$ignore" -ne 0 ] && return 0
+ # e.g. olsrd_txtinfo.so.1.1 or 'olsrd_txtinfo'
config_get library "$cfg" library
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
+
+ library="$( find_most_recent_plugin_libary "$library" )"
+ if [ -z "$library" ]; then
log "$funcname() Warning: Plugin library '$library' not found, skipped"
return 0
log "$funcname() Warning: Plugin library '$library' not found, skipped"
return 0
+ else
+ library="$( basename "$library" )"
+ validate_olsrd_option "$library" || {
+ warning_invalid_value olsrd "$cfg" 'library'
+ return 0
+ }
+
config_get name "$cfg" name
[ -z "$name" ] && config_set "$cfg" name $SYSTEM_HOSTNAME
config_get name "$cfg" name
[ -z "$name" ] && config_set "$cfg" name $SYSTEM_HOSTNAME
[ -z "$latlon_file" ] && config_set "$cfg" latlon_file '/var/run/latlon.js'
;;
[ -z "$latlon_file" ] && config_set "$cfg" latlon_file '/var/run/latlon.js'
;;
config_get wd_file "$cfg" file
;;
esac
config_get wd_file "$cfg" file
;;
esac
echo -n "${N}LoadPlugin \"$library\"${N}{"
config_write_options "$OLSRD_LOADPLUGIN_SCHEMA" "$cfg" olsrd_write_plparam "${T}"
echo "${N}}"
echo -n "${N}LoadPlugin \"$library\"${N}{"
config_write_options "$OLSRD_LOADPLUGIN_SCHEMA" "$cfg" olsrd_write_plparam "${T}"
echo "${N}}"
}
olsrd_write_interface() {
}
olsrd_write_interface() {