}
append_rev_server() {
- xappend "--rev-server=$1"
+ xappend "--rev-server=$1"
}
append_address() {
append_bool "$cfg" noresolv "--no-resolv"
append_bool "$cfg" localise_queries "--localise-queries"
append_bool "$cfg" readethers "--read-ethers"
- append_bool "$cfg" dbus "--enable-dbus"
- append_bool "$cfg" ubus "--enable-ubus" 1
+
+ local instance_name="dnsmasq.$cfg"
+ if [ "$cfg" = "$DEFAULT_INSTANCE" ]; then
+ instance_name="dnsmasq"
+ fi
+ config_get_bool dbus "$cfg" "dbus" 0
+ [ $dbus -gt 0 ] && xappend "--enable-dbus=uk.org.thekelleys.$instance_name"
+ config_get_bool ubus "$cfg" "ubus" 1
+ [ $ubus -gt 0 ] && xappend "--enable-ubus=$instance_name"
+
append_bool "$cfg" expandhosts "--expand-hosts"
config_get tftp_root "$cfg" "tftp_root"
[ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp"
start_service() {
local instance="$1"
local instance_found=0
+ local first_instance=""
. /lib/functions/network.sh
if [ -n "$instance" ] && [ "$instance" = "$name" ]; then
instance_found=1
fi
+ if [ -z "$DEFAULT_INSTANCE" ]; then
+ local disabled
+ config_get_bool disabled "$name" disabled 0
+ if [ "$disabled" -eq 0 ]; then
+ # First enabled section will be assigned default instance name.
+ # Unnamed sections get precedence over named sections.
+ if expr "$cfg" : 'cfg[0-9a-f]*$' >/dev/null = "9"; then # See uci_fixup_section.
+ DEFAULT_INSTANCE="$name" # Unnamed config section.
+ elif [ -z "$first_instance" ]; then
+ first_instance="$name"
+ fi
+ fi
+ fi
fi
}
+ DEFAULT_INSTANCE=""
config_load dhcp
+ if [ -z "$DEFAULT_INSTANCE" ]; then
+ DEFAULT_INSTANCE="$first_instance" # No unnamed config section was found.
+ fi
if [ -n "$instance" ]; then
[ "$instance_found" -gt 0 ] || return