multiple invocation of dnsmasq script (e.g. by procd and hotplugd)
might cause procd to restart dnsmasq with an incomplete config file.
Config file generation might take quite a long time on larger configs
due ubus calls for each listening interface...
Signed-off-by: Ulrich Weber <ulrich.weber@riverbed.com>
ADD_LOCAL_HOSTNAME=1
CONFIGFILE="/var/etc/dnsmasq.conf"
ADD_LOCAL_HOSTNAME=1
CONFIGFILE="/var/etc/dnsmasq.conf"
+CONFIGFILE_TMP="/var/etc/dnsmasq.conf.$$"
HOSTFILE="/tmp/hosts/dhcp"
TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf"
TIMESTAMPFILE="/etc/dnsmasq.time"
HOSTFILE="/tmp/hosts/dhcp"
TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf"
TIMESTAMPFILE="/etc/dnsmasq.time"
xappend() {
local value="$1"
xappend() {
local value="$1"
- echo "${value#--}" >> $CONFIGFILE
+ echo "${value#--}" >> $CONFIGFILE_TMP
xappend "--user=dnsmasq"
xappend "--group=dnsmasq"
xappend "--user=dnsmasq"
xappend "--group=dnsmasq"
+ echo >> $CONFIGFILE_TMP
config_get_bool enable_tftp "$cfg" enable_tftp 0
[ "$enable_tftp" -gt 0 ] && {
config_get_bool enable_tftp "$cfg" enable_tftp 0
[ "$enable_tftp" -gt 0 ] && {
[ -f "$TIMESTAMPFILE" ] && rm -f "$TIMESTAMPFILE"
[ -f "$TIMESTAMPFILE" ] && rm -f "$TIMESTAMPFILE"
- echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE
+ echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE_TMP
echo "# auto-generated config file from /etc/config/dhcp" > $HOSTFILE
# if we did this last, we could override auto-generated config
echo "# auto-generated config file from /etc/config/dhcp" > $HOSTFILE
# if we did this last, we could override auto-generated config
args=""
config_foreach dnsmasq dnsmasq
config_foreach dhcp_host_add host
args=""
config_foreach dnsmasq dnsmasq
config_foreach dhcp_host_add host
+ echo >> $CONFIGFILE_TMP
config_foreach dhcp_boot_add boot
config_foreach dhcp_mac_add mac
config_foreach dhcp_tag_add tag
config_foreach dhcp_boot_add boot
config_foreach dhcp_mac_add mac
config_foreach dhcp_tag_add tag
+ echo >> $CONFIGFILE_TMP
config_foreach dhcp_srv_add srvhost
config_foreach dhcp_mx_add mxhost
config_foreach dhcp_srv_add srvhost
config_foreach dhcp_mx_add mxhost
+ echo >> $CONFIGFILE_TMP
config_get odhcpd_is_active odhcpd maindhcp
if [ "$odhcpd_is_active" != "1" ]; then
config_foreach dhcp_add dhcp
fi
config_get odhcpd_is_active odhcpd maindhcp
if [ "$odhcpd_is_active" != "1" ]; then
config_foreach dhcp_add dhcp
fi
+ echo >> $CONFIGFILE_TMP
config_foreach dhcp_cname_add cname
config_foreach dhcp_cname_add cname
+ echo >> $CONFIGFILE_TMP
+ mv -f $CONFIGFILE_TMP $CONFIGFILE
rm -f /tmp/resolv.conf
[ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
rm -f /tmp/resolv.conf
[ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {