1 Reply Latest reply: Apr 12, 2014 12:24 AM by tausifkhan1324
John Lockwood Level 5 Level 5 (6,715 points)

It is possible in Mountain Lion or Mavericks to turn on location services via a shell script as might be used via Apple Remote Desktop or DeployStudio or similar. An example script to do this is listed below.

 

#!/bin/sh
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
uuid=`/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep "Hardware UUID" | /usr/bin/cut -c22-57`
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
exit 0

 

The script turns location services off, finds the Macs unique hardware UUID number, sets the preference file for this Mac which has a file name unique to this Mac because the file name includes the UUID number, restores ownership of the file as the defaults command will have possibly changed the owner, and then turns location services back on.

 

As mentioned the above will work for Mountain Lion and Mavericks. Unfortunately Lion even though it also has location services its method of confuguring is totally different.

 

Does anyone have a similar command line solution to enable location services for Lion (aka OS X 10.7).