-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathdisableBluetooth.sh
More file actions
156 lines (147 loc) · 6.58 KB
/
disableBluetooth.sh
File metadata and controls
156 lines (147 loc) · 6.58 KB
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
#!/bin/bash
####################################################################################################
#
# Copyright (c) 2010, JAMF Software, LLC. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the JAMF Software, LLC nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
####################################################################################################
#
# SUPPORT FOR THIS PROGRAM
#
# This program is distributed "as is" by JAMF Software, LLC's Resource Kit team. For more
# information or support for the Resource Kit, please utilize the following resources:
#
# http://list.jamfsoftware.com/mailman/listinfo/resourcekit
#
# http://www.jamfsoftware.com/support/resource-kit
#
# Please reference our SLA for information regarding support of this application:
#
# http://www.jamfsoftware.com/support/resource-kit-sla
#
####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
# disableBluetooth.sh -- Disable the Bluetooth drivers.
#
# SYNOPSIS
# sudo disableBluetooth.sh
# sudo disableBluetooth.sh <mountPoint> <computerName> <currentUsername> <targetVolume>
# sudo disableBluetooth.sh <mountPoint> <computerName> <currentUsername> <kextid>
#
# DESCRIPTION
#
# If executed on OS X version 10.10 or prior this script disables the Bluetooth drivers
# thereby disabling all functionality of the Bluetooth receiver. After running the script
# the Bluetooth drivers will be moved to:
#
# /Library/Application\ Support/JAMF/DisabledExtensions/
#
# so that Bluetooth can be re-enabled in the future. After running this script the computer
# will need to be rebooted for the settings to take effect.
#
# If executed on OS X 10.11 or later this script attempts to locate the Broadcom Bluetooth
# kernel extension & safely unloads it using the kextunload binary thereby disabling the
# functionality of the Bluetooth receiver.
#
# (See: "man -k kext" for more information on kernel extension binaries.)
#
# On OS X 10.11 or later this script does not make a persistent change to Bluetooth function.
# Rebooting the computer will load all kernel extensions that are part of the default OS X
# install per Apple's System Integrity Protection. Kernel extensions may only be moved if
# System Integrity Protection is disabled.
#
# It is possible that this particular Bluetooth kernel extension may not be present. If so,
# the script will fail with an error message accordingly. To obtain the bundle identifier of
# the Bluetooth kernel extension in use should it be necessary use the following command:
#
# "sudo kextfind -B -i -s bluetooth"
#
# The kernel extension bundle identifier in use can then be hard coded into the "value" variable
# below, passed as the 4th argument on the command line when executing the script (see usage above)
# or as parameter 4 when deploying the script as a payload from the JSS.
#
####################################################################################################
#
# HISTORY
#
# Version: 2.0
#
# - Created by Nick Amundsen August 6 2008
# - Updated by Nick Amundsen June 11 2009
# - Updated by Nick Amundsen January 21 2010
# - Updated by Brock Walters November 14 2015
#
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
# HARDCODED VALUE FOR IS SET HERE (OS X 10.10 & PRIOR: targetVolume", OS X 10.11 & LATER: kextid)
# PASTE TEXT IN BETWEEN DOUBLE QUOTES (eg. value="Volumes/Macintosh HD")
value=""
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4
if [ "$4" != "" ] && [ "$value" == "" ]
then
value=$4
fi
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
if [ $EUID -ne 0 ]
then
>&2 /bin/echo $'\nThis script must be run as the root user!\n'
exit
fi
ref=$(/usr/bin/sw_vers -productVersion | awk '{print substr($1,4,2)}')
if [ "$ref" -le 10 ] && [ "$value" != "" ]
then
targetVolume="$value"
echo "Disabling the Bluetooth drivers on target volume $targetVolume..."
if [ -d "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/" ]
then
/bin/mv "$targetVolume/System/Library/Extensions/IOBluetooth"* "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
else
/bin/mkdir -p "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
/bin/mv "$targetVolume/System/Library/Extensions/IOBluetooth"* "$targetVolume/Library/Application Support/JAMF/DisabledExtensions/"
fi
elif [ "$ref" -ge 11 ]
then
kextid="$value"
if [ "$kextid" = "" ]
then
broadcomkextid=$(/usr/sbin/kextstat -l | /usr/bin/awk '/Broadcom/{print $6}')
/sbin/kextunload -b "$broadcomkextid"
else
>&2 /bin/echo $'\nerror: Broadcom Bluetooth kernel extension was not found.\n'
fi
if [ "$kextid" != "" ]
then
/sbin/kextunload -b "$kextid"
fi
fi