Mac OS

Turn off Wi-Fi via shell script

Need to send a Shell Script to disable the wi-fi network?  No problem!  Have multiple types of machines that may have different device ID’s for the wi-fi?  No problem!

#!/bin/bash

# By Chris
## This will send a power-down to the Wi-Fi Device.
## Tested on 10.8.2 with single Wi-Fi device/hardware.

## First we get the Wi-Fi device name.  We are not assuming it is en1.
# We do this by listing all the hardware on the device, then only showing the line of and immediately following "Wi-Fi".
# Then do a quick second grep to only show the line of the Wi-Fi setting with the "Device" tag.
# We then cut out the first part of the entries and keep with is on the right side (of the ":".
# And finaly we strip out the extra space (to be neat).

WiFiDev="`networksetup -listallhardwareports | grep -A 1 "Wi-Fi" | grep -C 0 "Device" | cut -d ":" -f 2 | tr -d " "`"

# echo $WiFiDev

## Now turn it off.

networksetup -setairportpower $WiFiDev off

echo "Turning off the port at $WiFiDev"

exit 0
till next time
Advertisements

Set Proxy on all available network services

When you want to set the proxy on all available network services (say with JAMF’s Casper Suite at imaging time?)

#!/bin/bash

## A few variables we'll need for later

ProxyURL=http\:\/\/foo\/bar\.pac
declare -a NetServs

# Dealing with IFS as we need to alter it to avoid space issues.
OrigIFS=$IFS
IFS=$'\n'

#Define what Network Services are available.
NetServs=( `networksetup -listallnetworkservices | cut -d "." -f 2-` )

# Go through each network service and set the autoproxy.

for NetServ in ${NetServs[*]}; do
networksetup -setautoproxyurl "$NetServ" $ProxyURL
echo "$NetServ" is now set to use the proxy at $ProxyURL
done

exit 0

Enjoy.

till next time

What version is my Mac OS X installer?

One of the things that I do for Mac imaging is use InstaDMG to make my master image.  Part of the InstaDMG imaging process requires the build version of the installer OS to match a specified key in the catalog.  I figured out where this was, months ago, but as time has passed I forgot it.

Luckily, I didn’t need to use it for a while.  But now I do.  We’re having to go to Lion for a few months to get the Mac Book Airs out the door.  I can’t put an unsupported OS on a production machine.  So, we’ll brave new waters for a few months and try to keep that momentum up for a quick adoption to Mountain Lion.

Anyways!  Back to the point of this post!!!!

To find out what version of Lion your installer is (for use with InstaDMG), simply mount the InstallESD.dmg, and open

MacOSXInstallESD/System/Library/CoreServices/SystemVersion.plist.

Now look at the value for ProductBuildVersion.  That is your version number.

I’m posting this, so if I ever need it again, I know where to look.  Thanks to Allister on AFP548.com’s InstaDMG forum for pointing this one out!

Till next time.