Hi mate,
I think you're right about the SIP Protection. This script tries to write to the System folder and that's not possible anymore with El Capitan. I would recommend to disable the airport using a manage preference or even better, convert it to a Configuration Profile and then restrict access to System Preferences.
I hope it helps,
m
You can use the following command to disable airport
networksetup -setairportpower airport off
The network device name may alter the command a little. The device name could be airport, Wi-Fi, en0, en1, etc. Just adjust accordingly. My MacBook Pro uses en0.
networksetup -setairportpower en0 off
It is however able to be turned on again!
This is what we used, there is potential for it to trip up if there was more than one Wi-Fi adaptor... But that hasn't happened as yet. Also if you find other references other that Airport or Wi-Fi you could add them to the awk.
WFINT=$(networksetup -listallhardwareports | awk '/Airport|Wi-Fi/ {getline; print $NF }')
if [ "$WFINT" != "" ]; then
echo "Disabling Wi-Fi on $WFINT"
networksetup -setairportpower $WFINT off
fi
Hello All,
Thanks for your responses! Yeap it is SIP trying to protect me from myself.
Ended up using following script, based on my limited knowledge of scripting it will only turn off power on the WIFI (airport) interface if Ethernet is 'UP" - that takes care of never locking myself out , if the script ever gets scoped incorrectly, or when the script encounters MacBook or MacBook Air or MacBook Pro Retina w/o a real ethernet adapter. Did limited testing in our environment and i can say it works with 10.9, 10.10 and 10.11 fairly good.
#!/bin/sh
ACTIVEIF=`/usr/sbin/netstat -rn 2>&1 | /usr/bin/grep -m 1 'default' | /usr/bin/awk '{ print $6 }'`
WIFIIF=`/usr/sbin/networksetup -listallhardwareports | grep -A 1 Wi-Fi | awk '/Device/{ print $2 }'`
WIFIPWR=`/usr/sbin/networksetup -getairportpower $WIFIIF | sed 's/Wi-Fi Power.*: //g'`
if [ "$ACTIVEIF" == "$WIFIIF" ]; then
exit 0
else
if [ "$WIFIPWR" != "On" ]; then
exit 0
else
/usr/sbin/networksetup -setairportpower $WIFIIF off
fi
fi
Got this script from somewhere here on JAMFNation, and I apologize but don't know whose handiwork it it. - all borrowed work.
@ChicagoGuy1984 Am I mistaken, but does this script only turn off wifi?
I've attempted to create a script which 1) turns off wifi 2) disables the wifi network service and 3) removes the wifi symbol from the menubar. Parts 1 & 2 were relatively simple, but I wasn't able to programmatically remove the Wifi symbol from the menubar without doing it via System Preferences manually.
My programmatic method for the latter was to use defaults
to rewrite the com.apple.systemuiserver.plist file array to remove the "/System/Library/CoreServices/Menu Extras/AirPort.menu" string. But a killall SystemUIServer command doesn't actually apply the change and remove the Wifi symbol.
As anyone had any luck on this front on 10.11.5?