-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.sh
executable file
·197 lines (167 loc) · 5.26 KB
/
uninstall.sh
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#by zhuhaiyan 20130629, for linux datacard CM uninstallation.
#ROOT=./kernel
killall pppd
if [ ! -f $ROOT/etc/cm.version ]; then
echo "the CM is not found."
exit 0
fi
echo "the CM has beed installed:"
echo "------------------------------------------"
cat $ROOT/etc/cm.version
echo "------------------------------------------"
echo -n "continue to uninstall(yes/no)?[yes]"
read UNINSALL_CONTINUE
if [ "$UNINSALL_CONTINUE" = "" -o "$UNINSALL_CONTINUE" = "yes" -o "$UNINSALL_CONTINUE" = "no" ]; then
if [ "$UNINSALL_CONTINUE" = "" ]; then
UNINSALL_CONTINUE="yes"
fi
else
echo "invalid choice($UNINSALL_CONTINUE)! exit."
exit 0
fi
if [ "$UNINSALL_CONTINUE" = "no" ]; then
echo "cancel uninstallation!"
exit 0
fi
echo -n "uninstall driver..."
DRIVER_UNINSTALL="[OK]"
OS_REBOOT=0
if [ "$(cat $ROOT/proc/tty/drivers | grep usbserial)" != "" ]; then
if [ -f $ROOT/lib/modules/$(uname -r)/kernel/drivers/usb/serial/usbserial.ko ]; then
modprobe -r usbserial
else
MAGIC_ID=$(echo `grep MagicId $ROOT/etc/device.conf | awk -F= '{print $2}'`)
if [ -f $ROOT/boot/grub2/grub.cfg.org.$MAGIC_ID ]; then
cp $ROOT/boot/grub2/grub.cfg.org.$MAGIC_ID $ROOT/boot/grub2/grub.cfg
OS_REBOOT=1
else
if [ -f $ROOT/boot/grub2/grub.cfg.bak.$MAGIC_ID ]; then
cp $ROOT/boot/grub2/grub.cfg.bak.$MAGIC_ID $ROOT/boot/grub2/grub.cfg
OS_REBOOT=1
else
DRIVER_UNINSTALL="[FAIL]"
fi
fi
fi
fi
echo "$DRIVER_UNINSTALL"
if [ "$DRIVER_UNINSTALL" = "[FAIL]" ]; then
echo "!!!!grub.cfg backup is missing!!!"
echo "$ROOT/boot/grub2/grub.cfg can not be resotred!"
else
rm $ROOT/boot/grub2/grub.cfg.bak.$MAGIC_ID
#rm $ROOT/boot/grub2/grub.cfg.org.$MAGIC_ID
fi
echo -n "uninstall rules file..."
if [ -f $ROOT/lib/udev/rules.d/20-modemswitch-3g.rules ]; then
rm $ROOT/lib/udev/rules.d/20-modemswitch-3g.rules
fi
echo "[OK]"
echo -n "uninstall ppp config..."
if [ -f $ROOT/etc/ppp/chap-secrets.template ]; then
rm $ROOT/etc/ppp/chap-secrets.template
fi
if [ -f $ROOT/etc/ppp/pap-secrets.template ]; then
rm $ROOT/etc/ppp/pap-secrets.template
fi
if [ -f $ROOT/etc/ppp/ip-down.local ]; then
rm $ROOT/etc/ppp/ip-down.local
fi
if [ -f $ROOT/etc/ppp/peers/3g.template ]; then
rm $ROOT/etc/ppp/peers/3g.template
fi
echo "[OK]"
echo -n "uninstall APN and dial script..."
if [ -d $ROOT/etc/3g_modem_connection ]; then
rm -r $ROOT/etc/3g_modem_connection
fi
echo "[OK]"
echo -n "uninstall main app..."
if [ -f $ROOT/usr/bin/3g_connect.sh ]; then
rm $ROOT/usr/bin/3g_connect.sh
fi
if [ -f $ROOT/usr/bin/3g_connect_proc.sh ]; then
rm $ROOT/usr/bin/3g_connect_proc.sh
fi
if [ -f $ROOT/usr/bin/connect.sh ]; then
rm $ROOT/usr/bin/connect.sh
fi
if [ -f $ROOT/usr/bin/atinit ]; then
rm $ROOT/usr/bin/atinit
fi
if [ -f $ROOT/usr/bin/salestracking ]; then
rm $ROOT/usr/bin/salestracking
fi
if [ -f $ROOT/usr/bin/salestracking.sh ]; then
rm $ROOT/usr/bin/salestracking.sh
fi
if [ -f $ROOT/usr/bin/modemtoatmode ]; then
rm $ROOT/usr/bin/modemtoatmode
fi
if [ -f $ROOT/usr/bin/eject.sh ]; then
rm $ROOT/usr/bin/eject.sh
echo "rm eject"
fi
#Delet install
if [ -f $ROOT/home/install.sh ];then
rm -fr $ROOT/home/install.sh
echo "rm install"
fi
#Delet uninstall
if [ -f $ROOT/home/uninstall.sh ];then
rm -fr $ROOT/home/uninstall.sh
echo "rm uninstall"
fi
#Delet package
if [ -f $ROOT/home/*.tar.gz ];then
rm -fr $ROOT/home/*.tar.gz
echo "rm *.tar.gz"
fi
#Delet ndis drivers
if [ -f $ROOT/lib/modules/$(uname -r)/kernel/drivers/net/usb/GobiNet.ko ] ; then
rm -fr /lib/modules/$(uname -r)/kernel/drivers/net/usb/GobiNet.ko
echo "rm ndis dirvers"
fi
#Delet linux files
rm -fr $ROOT/home/linux
echo "rm linux floder"
echo "[OK]"
if [ -f /usr/share/dbus-1/system-services/org.freedesktop.ModemManager.service.disabled ]; then
mv /usr/share/dbus-1/system-services/org.freedesktop.ModemManager.service.disabled /usr/share/dbus-1/system-services/org.freedesktop.ModemManager.service
echo -n "restore modem-manager service..."
fi
if [ -f /usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service.disabled ]; then
mv /usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service.disabled /usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service
echo -n "restore modem-manager service..."
fi
echo "[OK]"
if [ -f /usr/sbin/modem-manager.disabled ]; then
mv /usr/sbin/modem-manager.disabled /usr/sbin/modem-manager
echo -n "restore modem-manager service..."
fi
if [ -f /usr/sbin/ModemManager.disabled ]; then
mv /usr/sbin/ModemManager.disabled /usr/sbin/ModemManager
echo -n "restore modem-manager service..."
fi
echo "[OK]"
echo "Unintallation Done!!"
echo "------------------------------"
cat $ROOT/etc/cm.version
rm $ROOT/etc/cm.version
echo "------------------------------"
if [ "$OS_REBOOT" = "1" ]; then
echo -n "os need reboot now(yes/no)?[yes]"
read OS_REBOOT_REQUIRE
if [ "$OS_REBOOT_REQUIRE" = "" -o "$OS_REBOOT_REQUIRE" = "yes" -o "$OS_REBOOT_REQUIRE" = "no" ]; then
if [ "$OS_REBOOT_REQUIRE" = "" ]; then
OS_REBOOT_REQUIRE="yes"
fi
else
echo "invalid choice($OS_REBOOT_REQUIRE)! exit."
exit 0
fi
if [ "$OS_REBOOT_REQUIRE" = "yes" ]; then
reboot
fi
fi
#done!!!