+dhcp_check() {
+ local ifname="$1"
+ local stamp="/var/run/dnsmasq.$ifname.dhcp"
+ local rv=0
+
+ [ -s "$stamp" ] && return $(cat "$stamp")
+
+ # If there's no carrier yet, skip this interface.
+ # The init script will be called again once the link is up
+ case "$(devstatus "$ifname" | jsonfilter -e @.carrier)" in
+ false) return 1;;
+ esac
+
+ udhcpc -n -q -s /bin/true -t 1 -i "$ifname" >&- && rv=1 || rv=0
+
+ [ $rv -eq 1 ] && \
+ logger -t dnsmasq \
+ "found already running DHCP-server on interface '$ifname'" \
+ "refusing to start, use 'option force 1' to override"
+
+ echo $rv > "$stamp"
+ return $rv
+}
+
+log_once() {
+ pidof dnsmasq >/dev/null || \
+ logger -t dnsmasq "$@"
+}
+