#!/bin/bash
set -e
sed -e '/^#/d' -e '/^$/d'  /etc/dnsmasq.conf | grep . && mv /etc/dnsmasq.conf /etc/dnsmasq.conf.dpkg-old

for f in dhcp.conf dnsmasq.conf servers; do
  [ -L /etc/dnsmasq.d/$f ] || ln -s /etc/omix/gw/conf/$f /etc/dnsmasq.d/$f
done
[ "$(readlink /etc/nftables.conf)" = /etc/omix/gw/conf/nftables.conf ] || \
  mv /etc/nftables.conf /etc/nftables.conf.dpkg-old
/usr/share/omix/mkconf
sed -i -e 's?^CONFIG_DIR=.*$?CONFIG_DIR=/etc/dnsmasq.d,\*.conf?' /etc/default/dnsmasq
systemctl restart dnsmasq
[ -L /etc/nftables.conf ] || ln -s /etc/omix/gw/conf/nftables.conf /etc/nftables.conf
systemctl restart nftables


