jelockwood / pinpoint

A script for finding your Mac
GNU General Public License v3.0
28 stars 5 forks source link

LaunchDaemon not updating result #5

Closed jelockwood closed 5 years ago

jelockwood commented 5 years ago

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.

screenshot_2019-02-25_at_8_39_42_am

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.

screenshot 2019-02-25 at 4 49 45 pm

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 https://github.com/jelockwood/pinpoint/issues/2#issuecomment-466924630

jelockwood commented 5 years ago

@myoaungchit If it works with -g aka --geocode but not without then it might be related to this now fixed bug #4 (comment) that is the installer was originally not correctly setting the default value of the USE_GEOCODE preference to TRUE.

If you run the 3.0.3 installer it should in theory set this to TRUE even for existing installs but check it afterwards by doing

defaults read /Library/Preferences/com.jelockwood.pinpoint

Can you check what version of pinpoint you have installed, the current version is now 3.0.3. The version number is in the installer package but also in the pinpoint.sh script, you can also do

/Library/Application\ Support/pinpoint/bin/pinpoint.sh -V

myoaungchit commented 5 years ago

@jelockwood

I am using version 3.03 installer and the following is the result of /Library/Application\ Support/pinpoint/bin/pinpoint.sh -V

pinpoint.sh version = 3.0.3

The following is the result of defaults read /Library/Preferences/com.jelockwood.pinpoint

home_ _-bash_ _90x35

I am not sure it is happening because of the way I pasted API keys in pinpoint.sh. When I pasted API Key with Validate API key section, I always get "Invalid Google API key" Error for running pinpoint.sh. So I commented out that section.

screenshot_26_2_19__2_14_pm

i also pasted API key in posintall.sh as well.

screenshot_26_2_19__2_20_pm

jelockwood commented 5 years ago

@myoaungchit Your plist looks fine, the format and length (of API key) matches mine.

After modifying the postinstall.sh you would need to use Packages to 'build' a new version to include that although you could manually run the postinstall.sh which I suspect you have done.

As a further test of your API key you could try the following command directly in Terminal.

curl -s "https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY"

Obviously paste in to the above your actual API key value. The above latitude and longitude are the examples given in Google API documentation for an address in the US. If this test still fails it suggests your API key is not enabled either for the APIs you need, or you have put a restriction on for example what TCP/IP addresses can use these APIs. Since you will be running this on multiple Mac clients with varying IP addresses putting a restriction on like that will not work.

Go to https://console.cloud.google.com/google/maps-apis?_ga=2.92543134.2011857138.1551173358-608455772.1550654142 and check your API key settings, in particular the restrictions and which APIs you have enabled for this key. You need GeoCoding, GeoLocation and Maps Elevation to be enabled.

Let me know the results.

myoaungchit commented 5 years ago

@jelockwood

Thanks for the reply. The result of the curl command is here

{
   "error_message" : "This API project is not authorized to use this API.",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

Let me check with my Google Admin since I do not have access to Google Cloud Console. I will get back to you soonest.

myoaungchit commented 5 years ago

My Google Admin has enabled GeoLocation and Maps Elevation APIs and I tested the curl command and here is the output.

{
   "plus_code" : {
      "compound_code" : "P27Q+MC New York, NY, USA",
      "global_code" : "87G8P27Q+MC"
   },
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "279",
               "short_name" : "279",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Bedford Avenue",
               "short_name" : "Bedford Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Williamsburg",
               "short_name" : "Williamsburg",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "11211",
               "short_name" : "11211",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "279 Bedford Ave, Brooklyn, NY 11211, USA",
         "geometry" : {
            "location" : {
               "lat" : 40.7142484,
               "lng" : -73.9614103
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.71559738029149,
                  "lng" : -73.9600613197085
               },
               "southwest" : {
                  "lat" : 40.71289941970849,
                  "lng" : -73.96275928029151
               }
            }
         },
         "place_id" : "ChIJT2x8Q2BZwokRpBu2jUzX3dE",
         "plus_code" : {
            "compound_code" : "P27Q+MC New York, United States",
            "global_code" : "87G8P27Q+MC"
         },
         "types" : [
            "bakery",
            "cafe",
            "establishment",
            "food",
            "point_of_interest",
            "store"
         ]
      },
      {
         "address_components" : [
            {
               "long_name" : "281",
               "short_name" : "281",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Bedford Avenue",
               "short_name" : "Bedford Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Williamsburg",
               "short_name" : "Williamsburg",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "11211",
               "short_name" : "11211",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "4230",
               "short_name" : "4230",
               "types" : [ "postal_code_suffix" ]
            }
         ],
         "formatted_address" : "281 Bedford Ave, Brooklyn, NY 11211, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.7142009,
                  "lng" : -73.96120789999999
               },
               "southwest" : {
                  "lat" : 40.7140632,
                  "lng" : -73.9614302
               }
            },
            "location" : {
               "lat" : 40.71412429999999,
               "lng" : -73.96130769999999
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.7154810302915,
                  "lng" : -73.95997006970849
               },
               "southwest" : {
                  "lat" : 40.7127830697085,
                  "lng" : -73.9626680302915
               }
            }
         },
         "place_id" : "ChIJiYRKQWBZwokR10UtO7vMvr0",
         "types" : [ "premise" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "277",
               "short_name" : "277",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Bedford Avenue",
               "short_name" : "Bedford Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Williamsburg",
               "short_name" : "Williamsburg",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "11211",
               "short_name" : "11211",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "277 Bedford Ave, Brooklyn, NY 11211, USA",
         "geometry" : {
            "location" : {
               "lat" : 40.7142205,
               "lng" : -73.9612903
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.71556948029149,
                  "lng" : -73.95994131970849
               },
               "southwest" : {
                  "lat" : 40.7128715197085,
                  "lng" : -73.9626392802915
               }
            }
         },
         "place_id" : "ChIJd8BlQ2BZwokRAFUEcm_qrcA",
         "plus_code" : {
            "compound_code" : "P27Q+MF New York, United States",
            "global_code" : "87G8P27Q+MF"
         },
         "types" : [ "street_address" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "279",
               "short_name" : "279",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Bedford Avenue",
               "short_name" : "Bedford Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Williamsburg",
               "short_name" : "Williamsburg",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "11211",
               "short_name" : "11211",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "279 Bedford Ave, Brooklyn, NY 11211, USA",
         "geometry" : {
            "location" : {
               "lat" : 40.7142546,
               "lng" : -73.9614527
            },
            "location_type" : "RANGE_INTERPOLATED",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.71560358029149,
                  "lng" : -73.96010371970848
               },
               "southwest" : {
                  "lat" : 40.71290561970849,
                  "lng" : -73.96280168029151
               }
            }
         },
         "place_id" : "EigyNzkgQmVkZm9yZCBBdmUsIEJyb29rbHluLCBOWSAxMTIxMSwgVVNBIhsSGQoUChIJ8ThWRGBZwokR3E1zUisk3LUQlwI",
         "types" : [ "street_address" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "11211",
               "short_name" : "11211",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "New York",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Brooklyn, NY 11211, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.7280089,
                  "lng" : -73.9207299
               },
               "southwest" : {
                  "lat" : 40.7008331,
                  "lng" : -73.9644697
               }
            },
            "location" : {
               "lat" : 40.7093358,
               "lng" : -73.9565551
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.7280089,
                  "lng" : -73.9207299
               },
               "southwest" : {
                  "lat" : 40.7008331,
                  "lng" : -73.9644697
               }
            }
         },
         "place_id" : "ChIJvbEjlVdZwokR4KapM3WCFRw",
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Williamsburg",
               "short_name" : "Williamsburg",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Williamsburg, Brooklyn, NY, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.7251773,
                  "lng" : -73.936498
               },
               "southwest" : {
                  "lat" : 40.6979329,
                  "lng" : -73.96984499999999
               }
            },
            "location" : {
               "lat" : 40.7081156,
               "lng" : -73.9570696
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.7251773,
                  "lng" : -73.936498
               },
               "southwest" : {
                  "lat" : 40.6979329,
                  "lng" : -73.96984499999999
               }
            }
         },
         "place_id" : "ChIJQSrBBv1bwokRbNfFHCnyeYI",
         "types" : [ "neighborhood", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Kings County, Brooklyn, NY, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.739446,
                  "lng" : -73.83336509999999
               },
               "southwest" : {
                  "lat" : 40.551042,
                  "lng" : -74.05663
               }
            },
            "location" : {
               "lat" : 40.6528762,
               "lng" : -73.95949399999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.739446,
                  "lng" : -73.83336509999999
               },
               "southwest" : {
                  "lat" : 40.551042,
                  "lng" : -74.05663
               }
            }
         },
         "place_id" : "ChIJOwE7_GTtwokRs75rhW4_I6M",
         "types" : [ "administrative_area_level_2", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Brooklyn",
               "short_name" : "Brooklyn",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Kings County",
               "short_name" : "Kings County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Brooklyn, NY, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.739446,
                  "lng" : -73.83336509999999
               },
               "southwest" : {
                  "lat" : 40.551042,
                  "lng" : -74.05663
               }
            },
            "location" : {
               "lat" : 40.6781784,
               "lng" : -73.94415789999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.739446,
                  "lng" : -73.83336509999999
               },
               "southwest" : {
                  "lat" : 40.551042,
                  "lng" : -74.05663
               }
            }
         },
         "place_id" : "ChIJCSF8lBZEwokRhngABHRcdoI",
         "types" : [ "political", "sublocality", "sublocality_level_1" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "New York",
               "short_name" : "New York",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "New York, NY, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.9175771,
                  "lng" : -73.70027209999999
               },
               "southwest" : {
                  "lat" : 40.4773991,
                  "lng" : -74.25908989999999
               }
            },
            "location" : {
               "lat" : 40.7127753,
               "lng" : -74.0059728
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.9175771,
                  "lng" : -73.70027209999999
               },
               "southwest" : {
                  "lat" : 40.4773991,
                  "lng" : -74.25908989999999
               }
            }
         },
         "place_id" : "ChIJOwg_06VPwokRYv534QaPC8g",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "New York, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 45.015865,
                  "lng" : -71.777491
               },
               "southwest" : {
                  "lat" : 40.4773991,
                  "lng" : -79.7625901
               }
            },
            "location" : {
               "lat" : 43.2994285,
               "lng" : -74.21793260000001
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 45.015865,
                  "lng" : -71.777491
               },
               "southwest" : {
                  "lat" : 40.4773991,
                  "lng" : -79.7625901
               }
            }
         },
         "place_id" : "ChIJqaUj8fBLzEwRZ5UY3sHGz90",
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "United States",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 71.5388001,
                  "lng" : -66.885417
               },
               "southwest" : {
                  "lat" : 18.7763,
                  "lng" : 170.5957
               }
            },
            "location" : {
               "lat" : 37.09024,
               "lng" : -95.712891
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 71.5388001,
                  "lng" : -66.885417
               },
               "southwest" : {
                  "lat" : 18.7763,
                  "lng" : 170.5957
               }
            }
         },
         "place_id" : "ChIJCzYy5IS16lQRQrfeQ5K5Oxw",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}

I also removed "-g" from /Library/Application\ Support/pinpoint/bin/pinpoint.sh command from jss extension attribute and did inventory update on test computers. Following is the result of location.plist.

screenshot_27_2_19__11_44_am

I believe it is working well already. Thank you very much. 💯 👍

jelockwood commented 5 years ago

@myoaungchit Yes it now looks like it is working fine. I would judge that both the GeoCode and GeoLocation APIs are working now but that you have not enabled using the Elevation API - which is for most people a waste of time and why I made the default not to use it.

I am now closing this issue.