浏览代码

Removing of bluetooth kernel module

Bob Mottram 8 年前
父节点
当前提交
90dc589eb9
共有 1 个文件被更改,包括 19 次插入4 次删除
  1. 19
    4
      src/freedombone-utils-setup

+ 19
- 4
src/freedombone-utils-setup 查看文件

151
 }
151
 }
152
 
152
 
153
 function remove_bluetooth {
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
     if [ -f /etc/default/bluetooth ]; then
165
     if [ -f /etc/default/bluetooth ]; then
157
         if grep -q "BLUETOOTH_ENABLED=" /etc/default/bluetooth; then
166
         if grep -q "BLUETOOTH_ENABLED=" /etc/default/bluetooth; then
158
             sed -i 's|BLUETOOTH_ENABLED=.*|BLUETOOTH_ENABLED=0|g' /etc/default/bluetooth
167
             sed -i 's|BLUETOOTH_ENABLED=.*|BLUETOOTH_ENABLED=0|g' /etc/default/bluetooth
159
         else
168
         else
160
             echo "BLUETOOTH_ENABLED=0" >> /etc/default/bluetooth
169
             echo "BLUETOOTH_ENABLED=0" >> /etc/default/bluetooth
161
         fi
170
         fi
171
+        bluetooth_changed=1
162
     fi
172
     fi
163
     if ! grep -q 'blacklist bnep' /etc/modprobe.d/bluetooth.conf; then
173
     if ! grep -q 'blacklist bnep' /etc/modprobe.d/bluetooth.conf; then
164
         echo 'blacklist bnep' >> /etc/modprobe.d/bluetooth.conf
174
         echo 'blacklist bnep' >> /etc/modprobe.d/bluetooth.conf
175
+        bluetooth_changed=1
165
     fi
176
     fi
166
     if ! grep -q 'blacklist btusb' /etc/modprobe.d/bluetooth.conf; then
177
     if ! grep -q 'blacklist btusb' /etc/modprobe.d/bluetooth.conf; then
167
         echo 'blacklist btusb' >> /etc/modprobe.d/bluetooth.conf
178
         echo 'blacklist btusb' >> /etc/modprobe.d/bluetooth.conf
179
+        bluetooth_changed=1
168
     fi
180
     fi
169
     if ! grep -q 'blacklist bluetooth' /etc/modprobe.d/bluetooth.conf; then
181
     if ! grep -q 'blacklist bluetooth' /etc/modprobe.d/bluetooth.conf; then
170
         echo 'blacklist bluetooth' >> /etc/modprobe.d/bluetooth.conf
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
     fi
188
     fi
172
-    update-initramfs -u -k `uname -r` -v
173
-    update-rc.d bluetooth remove
174
 }
189
 }
175
 
190
 
176
 function running_as_root {
191
 function running_as_root {