Browse Source

Removing of bluetooth kernel module

Bob Mottram 8 years ago
parent
commit
90dc589eb9
1 changed files with 19 additions and 4 deletions
  1. 19
    4
      src/freedombone-utils-setup

+ 19
- 4
src/freedombone-utils-setup View File

@@ -151,26 +151,41 @@ function proc_filesystem_settings {
151 151
 }
152 152
 
153 153
 function remove_bluetooth {
154
-    rmmod -f bnep
155
-    rmmod -f bluetooth
154
+    bluetooth_changed=
155
+    bnep_exists=$(lsmod | grep bnep)
156
+    if [[ "$bnep_exists" == "bnep"* ]]; then
157
+        rmmod -f bnep
158
+        bluetooth_changed=1
159
+    fi
160
+    bluetooth_exists=$(lsmod | grep bluetooth)
161
+    if [[ "$bluetooth_exists" == "bluetooth"* ]]; then
162
+        rmmod -f bluetooth
163
+        bluetooth_changed=1
164
+    fi
156 165
     if [ -f /etc/default/bluetooth ]; then
157 166
         if grep -q "BLUETOOTH_ENABLED=" /etc/default/bluetooth; then
158 167
             sed -i 's|BLUETOOTH_ENABLED=.*|BLUETOOTH_ENABLED=0|g' /etc/default/bluetooth
159 168
         else
160 169
             echo "BLUETOOTH_ENABLED=0" >> /etc/default/bluetooth
161 170
         fi
171
+        bluetooth_changed=1
162 172
     fi
163 173
     if ! grep -q 'blacklist bnep' /etc/modprobe.d/bluetooth.conf; then
164 174
         echo 'blacklist bnep' >> /etc/modprobe.d/bluetooth.conf
175
+        bluetooth_changed=1
165 176
     fi
166 177
     if ! grep -q 'blacklist btusb' /etc/modprobe.d/bluetooth.conf; then
167 178
         echo 'blacklist btusb' >> /etc/modprobe.d/bluetooth.conf
179
+        bluetooth_changed=1
168 180
     fi
169 181
     if ! grep -q 'blacklist bluetooth' /etc/modprobe.d/bluetooth.conf; then
170 182
         echo 'blacklist bluetooth' >> /etc/modprobe.d/bluetooth.conf
183
+        bluetooth_changed=1
184
+    fi
185
+    if [ $bluetooth_changed ]; then
186
+        update-initramfs -u -k `uname -r` -v
187
+        update-rc.d bluetooth remove
171 188
     fi
172
-    update-initramfs -u -k `uname -r` -v
173
-    update-rc.d bluetooth remove
174 189
 }
175 190
 
176 191
 function running_as_root {