#!/bin/sh
#
# chkconfig: 2345 11 90
# description: Connects to ADSL provider

# Source function library if it exists
test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions

# From AUTOCONF
prefix=/usr
exec_prefix=${prefix}

# Paths to programs
START=${exec_prefix}/sbin/adsl-start
STOP=${exec_prefix}/sbin/adsl-stop
STATUS=${exec_prefix}/sbin/adsl-status

case "$1" in
	start)
		ifconfig eth2 up
		echo -n "Bringing up ADSL link"
		$START
		if [ $? = 0 ]
		then
			touch /var/lock/subsys/adsl
			echo_success
		else
			echo_failure
		fi
		sleep 1; /etc/rc.d/init.d/route adsl
		echo
		;;

	stop)
		echo -n "Shutting down ADSL link"
		$STOP > /dev/null 2>&1
		if [ $? = 0 ]
		then
			rm -f /var/lock/subsys/adsl
			echo_success
		else
			echo_failure
		fi
		echo ""
		;;

	restart)
		$0 stop
		$0 start
		;;

	status)
		$STATUS
		;;

	dns)
		/opt/ddclient/bin/ddclient \
			-file /opt/ddclient/etc/default.conf \
			-cache /opt/ddclient/etc/default.cache \
			-server members.dyndns.org -ip 64.39.178.10 \
			-mx zappa.dyndns.org -backupmx -wildcard -refresh

		/opt/tzoperl/bin/tzoperl.pl -o -I 64.39.178.10
		;;
    *)
		echo "Usage: adsl {start|stop|restart|status}"
		exit 1
esac

exit 0
