#! /bin/sh
# ************************************************************************
# *                                                                      *
# *      remove_dabusb v0.1 - dabusb destroyer script                    *
# *                           by FlashCode and Crevetor (c) 14/04/2002   *
# *                                                                      *
# *          For any support, contact one of us :                        *
# *           - FlashCode: flashcode@free.fr  http://flashcode.free.fr   *
# *           - Crevetor : ziva@caramail.com                             *
# *                                                                      *
# *          License : GPL                                               *
# *                                                                      *
# ************************************************************************

# 30/12/2002 Benoit PAPILLAULT <benoit.papillault@free.fr>
#
#            Since depmod -a generate the file 
#            /lib/modules/`uname -r`/modules.usbmap and since this file is used
#            by USB hotplug, simply renaming dabusb.o do not work, the file
#            must be deleted (since it can no longer be used).

# <CONFIG>
BIN_DIR="/usr/bin"
ETC_DIR="/etc"
CONF_DIR="/etc/eciadsl"
PPPD_DIR="/etc/ppp"
VERSION="0.8-pre1"
# </CONFIG>

if [ "$1" == "--version" -o "$1" == "-v" ]
then
	echo "$VERSION"
	exit 0
fi

if [ $UID -ne 0 ]
then
	echo "you must be root to run this script"
	exit 0
fi

lsmod | grep dabusb
if [ $? -eq 0 -o "$1" == "--force" ]
then
	module=$(modprobe -l | grep dabusb)
	if [ -n "$module" ]
	then
	    rm -f "$module"
	    if [ $? -eq 0 ]
		then
			echo -e "\n${module} removed"
			depmod -a
		else
			echo -e "\n${module} cannot be removed"
		fi
	else
		echo -e "\ncouldn't find dabusb module file"
	fi
    modprobe -r dabusb
	sleep 1
    lsmod | grep dabusb
    if [ $? -ne 0 ]
	then
        echo "dabusb successfully unloaded"
    else
        echo "couldn't unload dabusb module, unplug your modem first"
    fi
else
    echo "dabusb is not loaded"
fi
