jelockwood / pinpoint Goto Github PK
View Code? Open in Web Editor NEWA script for finding your Mac
License: GNU General Public License v3.0
A script for finding your Mac
License: GNU General Public License v3.0
The original launchdaemon plist forgot to specify the binary was a .sh script. It also had the startinterval wrong at 10 minutes instead of 60 minutes i.e. one hour.
@kevinmcox
As brought to my attention by @ofirgalcon, Apple have deprecated the -
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport
binary in macOS Sonoma 14.4. When executed it now only produces the following.
WARNING: The airport command line tool is deprecated and will be removed in a future release.
For diagnosing Wi-Fi related issues, use the Wireless Diagnostics app or wdutil command line tool.
I have already determined that the following Python script can be used as the basis of an alternative to the Apple airport binary.
#!/usr/bin/env pythonw
import objc
objc.loadBundle(
"CoreWLAN",
bundle_path="/System/Library/Frameworks/CoreWLAN.framework",
module_globals=globals()
)
from CoreWLAN import CWNetwork, CWWiFiClient
client = CWWiFiClient.sharedWiFiClient()
iface = client.interfaceWithName_("en0")
networks, error = iface.scanForNetworksWithName_error_(
None,
None,
)
for i in networks:
if i.ssid() is None:
continue
print({'SSID_STR': i.ssid(), 'BSSID': i.bssid(), 'RSSI': i.rssiValue(), 'CHANNEL': i.channel()})
The above Python script however needs a lot more work to get it to format the results in the same way that the airport binary did. (Feel free to contribute improvements to this Python script.) It also needs improving to automatically pick the correct network interface.
Apple is removing python2 in macOS 12.3 next month. Pinpoint will need an update to read preferences in a different way if the goal is to continue to allow them to be set via configuration profile or defaults write
:
https://github.com/jelockwood/pinpoint/blob/master/pinpoint.sh#L139
EDIT: Found a few other uses of python as well:
https://github.com/jelockwood/pinpoint/blob/master/pinpoint.sh#L201
https://github.com/jelockwood/pinpoint/blob/master/pinpoint.sh#L326
https://github.com/jelockwood/pinpoint/blob/master/pinpoint.sh#L327
MunkiReport 5.7.0 now requires MunkiReport-Python2 and changing Line 139 to use /usr/local/munkireport/munkireport-python2
does work.
However while this might be a solution for MunkiReport users, it'll only be temporary as MR version 6 will switch to Python 3 later this year.
I was trying to install the current 3.0.4 pkg and realized the postinstall script was failing from what looks like a missing 'fi' in the if statement? I was able to update the postinstall manually and seems to fix it.
Thanks!
Discovered I did not have a license to use the original image/logo.
@ofirgalcon
This is a different problem so I have opened a new issue.
Yes I have - it's working ok, returning co-ordinates, but a blank address.
sudo defaults write /Library/Preferences/com.jelockwood.pinpoint.plist YOUR_API_KEY xxxxxx
sudo defaults write /Library/Preferences/com.jelockwood.pinpoint.plist USE_ALTITUDE -bool FALSE
sudo defaults write /Library/Preferences/com.jelockwood.pinpoint.plist USE_GEOCODE -bool TRUE
/Library/Application\ Support/pinpoint/bin/pinpoint.sh
HTTP/2 200
cache-control: no-cache, no-store, max-age=0, must-revalidate
pragma: no-cache
expires: Mon, 01 Jan 1990 00:00:00 GMT
date: Wed, 20 Feb 2019 09:19:34 GMT
vary: X-Origin
vary: Origin,Accept-Encoding
content-type: application/json; charset=UTF-8
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
server: GSE
alt-svc: quic=":443"; ma=2592000; v="44,43,39"
accept-ranges: none
"location": {
"lat": xx.xxxxx,
"lng": xx.xxxxx
},
"accuracy": 27.0
}
Result code = 200
ls_enabled = 1
This is what gets returned
sudo defaults read "/Library/Application Support/pinpoint/location.plist"
{
Address = "";
Altitude = 0;
CurrentStatus = Successful;
GoogleMap = "https://www.google.com/maps/place/xxxxxxxxxxx";
"LS_Enabled" = 0;
LastLocationRun = "2019-02-20 09:11:35 +0000";
LastRun = "2019-02-20 09:11:35 +0000";
Latitude = "xx.xxxxx";
LatitudeAccuracy = 23;
Longitude = "xx.xxxxxx";
LongitudeAccuracy = 23;
StaleLocation = No;
Originally posted by @ofirgalcon in #3 (comment)
John, what would you think about adding the RunAtLoad
key to the LaunchDaemon so it triggers a location check right when the computer boots up?
I'd be happy to add it to my existing PR #13 if you are OK with it.
~ Kevin
Thank you for checking on this very fast. Yes, I did the installation for client portion prior to adding JSS extension.
So , in JSS extension, /Library/Application\ Support/pinpoint/bin/pinpoint.sh
is added to force generated the location data. However, the new location data was not reflecting in plist after JAMF Inventory Update. I noticed that the time stamp for LastLocationRun was not same as LastRun. For LastRun's timestamp, it tallied with the time stamp for JAMF Inventory Update.
I changed the command to /Library/Application\ Support/pinpoint/bin/pinpoint.sh -g
to see how it goes and , to my surprise, it did update the new location data in plist now.
This was tested on the laptops which are currently away from Singapore and their new locations are reflected correctly.
Really appreciate for your work and help, John.
Originally posted by @myoaungchit in #2 (comment)
iMac with 10.13.6, had pinpoint v2 installed
Feb 19 03:56:04 Thin Installer[76682]: @(#)PROGRAM:Install PROJECT:Install-1000
Feb 19 03:56:04 Thin Installer[76682]: @(#)PROGRAM:Installer PROJECT:Installer-920
Feb 19 03:56:04 Thin Installer[76682]: Hardware: iMac14,2 @ 3.20 GHz (x 4), 16384 MB RAM
Feb 19 03:56:04 Thin Installer[76682]: Running OS Build: Mac OS X 10.13.6 (17G6009)
Feb 19 03:56:04 Thin Installer[76682]: pinpoint Installation Log
Feb 19 03:56:04 Thin Installer[76682]: Opened from: /Users/ofir/Downloads/pinpoint-3.0.1.pkg
Feb 19 03:56:06 Thin deleted[969]: diskmanagement: [DMManager(PrivateMethods) clientConforms:error:]: currentThread=78051=0x130e3 expectedThread=10759=0x2a07
Feb 19 03:56:11 Thin deleted[969]: diskmanagement: [DMManager(PrivateMethods) clientConforms:error:]: currentThread=52771=0xce23 expectedThread=10759=0x2a07
Feb 19 03:56:11 Thin Installer[76682]: InstallerStatusNotifications plugin loaded
Feb 19 03:56:15 Thin Installer[76682]: ================================================================================
Feb 19 03:56:15 Thin Installer[76682]: User picked Standard Install
Feb 19 03:56:15 Thin Installer[76682]: Choices selected for installation:
Feb 19 03:56:15 Thin Installer[76682]: Upgrade: "pinpoint"
Feb 19 03:56:15 Thin Installer[76682]: Upgrade: "pinpoint"
Feb 19 03:56:15 Thin Installer[76682]: ================================================================================
Feb 19 03:56:15 Thin deleted[969]: diskmanagement: [DMManager(PrivateMethods) clientConforms:error:]: currentThread=78051=0x130e3 expectedThread=10759=0x2a07
Feb 19 03:56:16 Thin Installer[76682]: Configuring volume "Macintosh HD"
Feb 19 03:56:16 Thin Installer[76682]: Free space on "Macintosh HD": 197.94 GB (197937045504 bytes).
Feb 19 03:56:16 Thin Installer[76682]: Create temporary directory "/var/folders/39/n4jn4q556ln07yd5v531rr_h0000gx/T//Install.76682zEu3mU"
Feb 19 03:56:16 Thin Installer[76682]: IFPKInstallElement (1 packages)
Feb 19 03:56:16 Thin Installer[76682]: PackageKit: Enqueuing install with framework-specified quality of service (utility)
Feb 19 03:56:16 Thin installd[14937]: PackageKit: ----- Begin install -----
Feb 19 03:56:16 Thin installd[14937]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “pinpoint-3.0.1.pkg”." UserInfo={NSFilePath=./postinstall, NSURL=file://localhost/Users/ofir/Downloads/pinpoint-3.0.1.pkg#pinpoint.pkg, PKInstallPackageIdentifier=com.jelockwood.pinpoint.pkg., NSLocalizedDescription=An error occurred while running scripts from the package “pinpoint-3.0.1.pkg”.} {
NSFilePath = "./postinstall";
NSLocalizedDescription = "An error occurred while running scripts from the package \U201cpinpoint-3.0.1.pkg\U201d.";
NSURL = "file://localhost/Users/ofir/Downloads/pinpoint-3.0.1.pkg#pinpoint.pkg";
PKInstallPackageIdentifier = "com.jelockwood.pinpoint.pkg.";
}
Feb 19 03:56:17 Thin Installer[76682]: Install failed: The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.
Feb 19 03:56:17 Thin Installer[76682]: IFDInstallController 1C00 state = 8
Feb 19 03:56:17 Thin Installer[76682]: Displaying 'Install Failed' UI.
Feb 19 03:56:17 Thin Installer[76682]: 'Install Failed' UI displayed message:'The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.