#!/bin/sh
. /etc/ppp/ip-function

FW_SCRIPT="/usr/syno/etc/rc.d/S01iptables.sh"
RELAYDAEMON="/usr/syno/sbin/synorelayd"

if [ -x "${FW_SCRIPT}" ]; then
	${FW_SCRIPT} restart /etc/firewall
fi
${RELAYDAEMON} -U

check_is_pppoe ${PPPD_PID}
if [ 0 -eq $? ]; then
	if [ -d /initrd ]; then
		if test -n "$DNS1" ; then
			echo "nameserver $DNS1" > /etc/ppp/resolv.conf.pppoe
		fi
		if test -n "$DNS2" ; then
			echo "nameserver $DNS2" >> /etc/ppp/resolv.conf.pppoe
		fi
		if [ -n "$DNS1" ]; then
			/bin/chmod 644 /etc/ppp/resolv.conf.pppoe 2>&1
			/usr/syno/sbin/synonet --dns_update > /dev/null 2>&1
		fi
		if test -n "$IPREMOTE" ; then
			echo "$IPREMOTE" > /tmp/pppoe_gw_backup
		fi
	else
		if test -n "$DNS1" ; then
			echo "nameserver $DNS1" > /etc/resolv.conf
		fi
		if test -n "$DNS2" ; then
			echo "nameserver $DNS2" >> /etc/resolv.conf
		fi
		/bin/chmod 644 /etc/resolv.conf 2>&1
	fi

fi
