#!/bin/sh

# eciadsl-stop: stop EciAdsl connection
#
# returns: 0 = ok, driver is stopped
#          1 = failed, driver is not running
#          2 = failed, can't kill pppd or eciadsl-pppoeci
#
# 2004-04-23, by FlashCode <flashcode@flashtux.org>
#             http://eciadsl.flashtux.org
#

echo -e "EciAdsl: shutting down..."
ps ax | grep "eciadsl-pppoeci" | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]; then
	eciadsl-ctrlui --disconnect
	sleep 1
 	ps ax | grep "pppd" | grep -v grep > /dev/null 2>&1
	if [ $? -eq 0 ]; then
    	killall pppd
	    if [ $? -eq 0 ]; then
	        echo -e "stopped."
	    else
	        echo -e "failed to stop"
	        exit 2
	    fi
	fi
else
    echo -e "failed (not running)"
    exit 1
fi
exit 0
