-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheciadsl-remove-dabusb.in
executable file
·96 lines (90 loc) · 2.96 KB
/
eciadsl-remove-dabusb.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /bin/bash
# ************************************************************************
# * *
# * eciadsl-remove-dabusb v0.1 - dabusb destroyer script *
# by FlashCode and Crevetor (c) 14/04/2002 *
# * *
# * For any support, contact one of us : *
# * - FlashCode: [email protected] *
# * - Crevetor : [email protected] *
# * *
# * License : GPL - http://eciadsl.flashtux.org *
# * *
# ************************************************************************
# 30/12/2002 Benoit PAPILLAULT <[email protected]>
#
# 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).
#
# 2003/10/03 If hotplug has support for blacklist, simply tell it to ignore dabusb
# <CONFIG>
BIN_DIR="@bindir@"
ETC_DIR="@sysconfdir@"
CONF_DIR="@sysconfdir@/eciadsl"
PPPD_DIR="@sysconfdir@/ppp"
VERSION="@PACKAGE_VERSION@"
# </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 -q 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 a dabusb module to remove"
fi
module=$(lsmod | grep dabusb)
if [ -n "$module" ]
then
modprobe -r $module && \
sleep 1
lsmod | grep -q dabusb && \
echo "dabusb successfully unloaded" || \
echo "couldn't unload dabusb module, unplug your modem first"
else
echo "dabusb module not loaded"
fi
else
echo "dabusb is not loaded"
fi
# check if vanilla hotplug is installed,
# and if blacklist support is enabled (>=2002)
HOTPLUG=/etc/hotplug
HOTPLUG_HAS_BLACKLIST=0
test -f $HOTPLUG/blacklist && \
HOTPLUG_HAS_BLACKLIST=$(($HOTPLUG_HAS_BLACKLIST+1))
grep -q blacklist $HOTPLUG/hotplug.functions 2>/dev/null && \
HOTPLUG_HAS_BLACKLIST=$(($HOTPLUG_HAS_BLACKLIST+1))
if [ $HOTPLUG_HAS_BLACKLIST -gt 0 ]
then
grep -q "^dabusb$" $HOTPLUG/blacklist
if [ $? -eq 0 ]
then
echo "dabusb already in hotplug's blacklist"
else
echo -e "\n#dabusb disabled: avoids conflict w/ eciadsl usermode driver\ndabusb" >> $HOTPLUG/blacklist
echo "dabusb added to hotplug's blacklist"
fi
else
echo "no hotplug blacklist support detected or hotplug not installed?"
fi