/
bumblebee-uninstall
executable file
·305 lines (254 loc) · 8.2 KB
/
bumblebee-uninstall
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/bin/bash
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <mj@casalogic.dk> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return Martin Juhl
# ----------------------------------------------------------------------------
#
# This file is part of bumblebee.
#
# bumblebee is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# bumblebee is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bumblebee. If not, see <http://www.gnu.org/licenses/>.
#
ROOT_UID=0
if [ `cat /etc/issue | grep -nir fedora | wc -l` -gt 0 ] ; then
DISTRO=FEDORA
BASHRC=/etc/bashrc
elif [ `cat /etc/issue | grep -nir ubuntu | wc -l` -gt 0 ] ; then
DISTRO=UBUNTU
BASHRC=/etc/bash.bashrc
elif [ `cat /etc/issue | grep -nir opensuse | wc -l` -gt 0 ] ; then
DISTRO=OPENSUSE
BASHRC=/etc/bash.bashrc
if [ "$SUDO_USER" != "" ] ; then
HOME=`cat /etc/passwd | grep $SUDO_USER | cut -f6 -d':'`
fi
elif [ `cat /etc/issue | grep -nir debian | wc -l` -gt 0 ] ; then
DISTRO=DEBIAN
BASHRC=/etc/bash.bashrc
fi
if [ "$UID" != "$ROOT_UID" ] ; then
echo "You don't have sufficient privileges to run this script."
echo
echo "Please run the script with: sudo bumblebee-uninstall"
exit 1
fi
if [ "$HOME" == "/root" ] && [ "$DISTRO" != OPENSUSE ] ; then
echo "Do not run this script as the root user"
echo
echo "Please run the script with: sudo bumblebee-uninstall"
exit 2
fi
ARCH=`uname -m`
MODPROBE=`which modprobe`
echo "Welcome to the bumblebee uninstallation"
echo "Licensed under BEER-WARE License and GPL"
echo
echo "This script will remove bumblebee completely"
echo "and also clean up after earlier versions"
echo
if [ "$DISTRO" == OPENSUSE ] && [ -f /usr/bin/nvidia-uninstall ] ; then
if [ `ps -ea | grep X | wc -l` -gt 0 ] ; then
echo "X server is still active. Please go to runlevel 3 and try again."
echo "( Login as root and run \"init 3\". Use \"init 5\" to activate the X server again )"
exit 1
fi
fi
if [ $DISTRO = FEDORA ] && [ "$ARCH" = "x86_64" ] ; then
echo "Uninstalling will most likely kill your X-session"
echo "please make sure that all your data is saved"
echo
fi
echo "Are you sure you want to proceed?? (Y/N)"
echo
read answer
case "$answer" in
y | Y )
;;
*)
exit 0
;;
esac
sleep 5
echo
if [ $DISTRO = UBUNTU ] || [ $DISTRO = DEBIAN ]; then
# Kill the nvidia X server
/etc/init.d/bumblebee disable
# Make sure the card is enabled
if [ -x /usr/local/bin/bumblebee-enablecard ]; then
/usr/local/bin/bumblebee-enablecard
fi
echo "Removing nVidia driver package"
echo
apt-get -y --purge remove nvidia-current
echo "Removing VirtualGL package"
echo
dpkg -r VirtualGL
update-rc.d -f bumblebee remove
rm /etc/pm/power.d/bumblebee-disablecard-on-powerup
elif [ $DISTRO = OPENSUSE ]; then
# Kill the nvidia X server
/etc/init.d/bumblebee disable
chkconfig bumblebee off
echo "Removing VirtualGL package"
echo
zypper --no-refresh --non-interactive remove VirtualGL
# Make sure the card is enabled
if [ -x /usr/local/bin/bumblebee-enablecard ]; then
/usr/local/bin/bumblebee-enablecard
fi
if [ -f /usr/bin/nvidia-uninstall ] ; then
echo "Uninstalling nVidia package"
#
# Cleanup 3D hack for the nVidia package part 1
#
if [ "$ARCH" == "i686" ] ; then
rm -f /usr/lib/libGL.so.*
mv -f /usr/X11R6/nvidia/lib/libnvidia-wfb.* /usr/X11R6/nvidia/lib/xorg/modules
pushd /usr/X11R6/nvidia/lib/xorg/modules > /dev/null
ln -sf libnvidia-wfb.so.1 libwfb.so
popd > /dev/null
else
rm -f /usr/lib/libGL.so.*
rm -f /usr/lib64/libGL.so.*
mv -f /usr/X11R6/nvidia/lib64/libnvidia-wfb.* /usr/X11R6/nvidia/lib64/xorg/modules
pushd /usr/X11R6/nvidia/lib64/xorg/modules > /dev/null
ln -sf libnvidia-wfb.so.1 libwfb.so
popd > /dev/null
fi
#
# Uninstall nVidia package
#
/usr/bin/nvidia-uninstall -s
#
# Cleanup 3D hack for the nVidia package part 2
#
rm -rf /usr/X11R6/lib-nvidia
rm -rf /usr/X11R6/lib64-nvidia
rm -rf /usr/lib/xorg-nvidia
rm -rf /usr/lib64/xorg-nvidia
rm -rf /usr/X11R6/nvidia
fi
rm /etc/pm/power.d/bumblebee-disablecard-on-powerup 2>/dev/null
elif [ $DISTRO = FEDORA ]; then
# Stop the nvidia X server
service bumblebee stop
chkconfig bumblebee off
echo "Removing VirtualGL package"
echo
yum -y remove VirtualGL
if [ -f /etc/profile.d/virtualgl.sh ]; then
rm /etc/profile.d/virtualgl.sh
fi
# Make sure the card is enabled
if [ -x /usr/local/bin/bumblebee-enablecard ]; then
/usr/local/bin/bumblebee-enablecard
fi
# New method for x86_64 but still the old one for i686
if [ "$ARCH" = "x86_64" ]; then
echo "Removing nVidia driver package"
${MODPROBE} -r nvidia
/usr/lib64/nvidia-current/bin/nvidia-installer -s --uninstall
fi
fi
#Unload the nvidia module
${MODPROBE} -r nvidia
echo
echo "Restoring old configuration"
if [ -f ${BASHRC}.optiorig ]; then
mv $BASHRC.optiorig $BASHRC
fi
if [ -f /etc/modprobe.d/blacklist.conf.optiorig ]; then
mv /etc/modprobe.d/blacklist.conf.optiorig /etc/modprobe.d/blacklist.conf
fi
if [ -f /etc/modules.optiorig ]; then
mv /etc/modules.optiorig /etc/modules
fi
if [ -f /etc/X11/xorg.conf.optiorig ]; then
mv -f /etc/X11/xorg.conf.optiorig /etc/X11/xorg.conf
fi
rm /etc/X11/xorg.conf.nvidia
rm -rf /etc/X11/xdm-optimus
rm -rf /etc/X11/bumblebee
if [ -f /etc/init.d/xdm-optimus ]; then
rm /etc/init.d/xdm-optimus
fi
rm /etc/init.d/bumblebee
if [ -f /etc/modprobe.d/virtualgl.conf ]; then
rm /etc/modprobe.d/virtualgl.conf
fi
if [ -f /usr/local/bin/optimusXserver ]; then
rm /usr/local/bin/optimusXserver
fi
rm /usr/local/bin/bumblebee-bugreport
if [ -f /usr/bin/xdm-optimus ]; then
rm /usr/bin/xdm-optimus
fi
rm -rf /usr/lib64/nvidia-current
rm -rf /usr/lib/nvidia-current
rm -rf /usr/lib/bumblebee
rm -f /usr/local/bin/optirun*
rm -f /usr/local/bin/bumblebee-disablecard-on-powerup
rm -f /usr/bin/vglclient-service
rm -f /etc/modprobe.d/nouveau-blacklist.conf
rm -rf /usr/share/doc/bumblebee
rm -rf /usr/share/doc/packages/bumblebee
rm -f /usr/local/bin/bumblebee*
rm -f /etc/default/bumblebee*
if [ -d /opt/prime-ng ]; then
rm -rf /opt/prime-ng
fi
if [ -d /opt/bumblebee ]; then
rm -rf /opt/bumblebee
fi
if [ -d /usr/lib/bumblebee ]; then
rm -rf /usr/lib/bumblebee
fi
if [ `dkms status |grep acpi_call | wc -l` -gt 0 ]; then
dkms uninstall -m acpi_call -v `dkms status |grep acpi_call |cut -f2 -d,`
dkms remove -m acpi_call -v `dkms status |grep acpi_call |cut -f2 -d,` --all
fi
if [ -f /etc/alternatives/xorg_extra_modules-bumblebee ] ; then
rm -f /etc/alternatives/xorg_extra_modules-bumblebee
fi
if [ "$DISTRO" != "OPENSUSE" ] ; then
ln -s /usr/lib/nvidia-current/xorg /etc/alternatives/xorg_extra_modules
fi
ldconfig
if [ -f $HOME/.kde/Autostart/vglclient-service ]; then
rm -f $HOME/.kde/Autostart/vglclient-service
fi
if [ -f $HOME/.config/autostart/vglclient-service ]; then
rm -f $HOME/.config/autostart/vglclient-service
fi
if [ -f $HOME/.config/autostart/vglclient.desktop ]; then
rm $HOME/.config/autostart/vglclient.desktop
fi
if [ -f $HOME/.bashrc ] ; then
grep -Ev 'VGL|optirun' $HOME/.bashrc > $HOME/.oldbashrc
mv -f $HOME/.oldbashrc $HOME/.bashrc
chown $SUDO_UID:$SUDO_GID $HOME/.bashrc
fi
grep -Ev 'bumblebee' /etc/sudoers > /etc/sudoers.optiorig
mv -f /etc/sudoers.optiorig /etc/sudoers
chmod 0440 /etc/sudoers
if [ "$DISTRO" != "UBUNTU" ] && [ "$DISTRO" != "OPENSUSE" ] ; then
killall -9 vglclient
fi
rm -rf /etc/bash_completion.d/optirun*
echo
echo "bumblebee has been uninstalled :("
echo
rm /etc/bumblebee