From b99cfb7fc990580a573e578134ec73edae1dbe6a Mon Sep 17 00:00:00 2001 From: "Kevin M. Cox" Date: Mon, 19 Oct 2020 17:48:52 -0500 Subject: [PATCH 1/4] Bug fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Quoted "$resultcode" to prevent `line 175: [: too many arguments` error • Changed LS_Enabled from a boolean to an integer to fix MunkiReport error: `Server Error: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'ls_enabled' at row 1` See @bochoven comment, "The database implementation that MR uses does not have boolean as a storage type" in discussion at https://macadmins.slack.com/archives/C066NK3K5/p1580221740182600\ --- pinpoint.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pinpoint.sh b/pinpoint.sh index 61fd034..71b5678 100644 --- a/pinpoint.sh +++ b/pinpoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright John E. Lockwood (2018-2019) +# Copyright John E. Lockwood (2018-2020) # # pinpoint a script to find your Mac's location # @@ -10,7 +10,7 @@ # Script name scriptname=$(basename -- "$0") # Version number -versionstring="3.0.3" +versionstring="3.0.4" # get date and time in UTC hence timezone offset is zero rundate=`date -u +%Y-%m-%d\ %H:%M:%S\ +0000` #echo "$rundate" @@ -172,7 +172,7 @@ echo "$result" # A 400 or 404 error might mean none of your detect WiFi BSSIDs are known to Google resultcode=`echo "$result" | grep "HTTP" | awk '{print $2}'` echo "Result code = $resultcode" -if [ $resultcode != "200" ]; then +if [ "$resultcode" != "200" ]; then if [ -e "$resultslocation" ]; then reason=`echo "$result" | grep "HTTP" | awk -F ": " '{print $2}'` defaults write "$resultslocation" CurrentStatus -string "Error $resultcode - $reason" @@ -258,9 +258,9 @@ else ls_enabled=`defaults read "/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd" LocationServicesEnabled` echo "ls_enabled = $ls_enabled" if [ "$ls_enabled" == "True" ]; then - defaults write "$resultslocation" LS_Enabled -bool TRUE + defaults write "$resultslocation" LS_Enabled -int 1 else - defaults write "$resultslocation" LS_Enabled -bool FALSE + defaults write "$resultslocation" LS_Enabled -int 0 fi defaults write "$resultslocation" LastLocationRun -string "$rundate" defaults write "$resultslocation" LastRun -string "$rundate" From 83d22aff7ed8688d14f45ca0de8b0a0d3d6ca808 Mon Sep 17 00:00:00 2001 From: "Kevin M. Cox" Date: Mon, 19 Oct 2020 19:34:57 -0500 Subject: [PATCH 2/4] Additional changes around line 175 My original changes fixed one error but caused another. Stole these fixes from ofirgalcon. --- pinpoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pinpoint.sh b/pinpoint.sh index 71b5678..2d24039 100644 --- a/pinpoint.sh +++ b/pinpoint.sh @@ -170,11 +170,11 @@ echo "$result" # # Get HTTP result code, if 400 it implies it failed, if 200 it succeeded # A 400 or 404 error might mean none of your detect WiFi BSSIDs are known to Google -resultcode=`echo "$result" | grep "HTTP" | awk '{print $2}'` +resultcode=`echo "$result" | grep "HTTP/2" | awk '{print $2}'` echo "Result code = $resultcode" if [ "$resultcode" != "200" ]; then if [ -e "$resultslocation" ]; then - reason=`echo "$result" | grep "HTTP" | awk -F ": " '{print $2}'` + reason=`echo "$result" | grep "reason" | awk -F ": " '{print $2}'` defaults write "$resultslocation" CurrentStatus -string "Error $resultcode - $reason" defaults write "$resultslocation" LastRun -string "$rundate" defaults write "$resultslocation" StaleLocation -string "Yes" From 4bf53c3aa39159a2adce6d486bc1de8c672b46bd Mon Sep 17 00:00:00 2001 From: "Kevin M. Cox" Date: Mon, 19 Oct 2020 19:55:59 -0500 Subject: [PATCH 3/4] Update pinpoint.sh LocationServicesEnabled is stored as an integer, changed Line 260 to match. --- pinpoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinpoint.sh b/pinpoint.sh index 2d24039..b24b3b4 100644 --- a/pinpoint.sh +++ b/pinpoint.sh @@ -257,7 +257,7 @@ else # This is done in order to be backwards compatible with the previous Location Services based version of pinpoint ls_enabled=`defaults read "/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd" LocationServicesEnabled` echo "ls_enabled = $ls_enabled" - if [ "$ls_enabled" == "True" ]; then + if [ "$ls_enabled" == "1" ]; then defaults write "$resultslocation" LS_Enabled -int 1 else defaults write "$resultslocation" LS_Enabled -int 0 From 2252c7740c7ab35452a1e935bf0118d41a2012da Mon Sep 17 00:00:00 2001 From: "Kevin M. Cox" Date: Mon, 19 Oct 2020 20:44:25 -0500 Subject: [PATCH 4/4] Bumped package version to 3.0.4 --- installer_package/installer_package.pkgproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer_package/installer_package.pkgproj b/installer_package/installer_package.pkgproj index ad08ffc..2b05008 100644 --- a/installer_package/installer_package.pkgproj +++ b/installer_package/installer_package.pkgproj @@ -540,7 +540,7 @@ USE_HFS+_COMPRESSION VERSION - 3.0.2 + 3.0.4 TYPE 0