-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1073 from thomasjacquin/post-camera-top-allsky-map
Added script to post your location automatically on the allsky map
- Loading branch information
Showing
6 changed files
with
777 additions
and
689 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC2034 | ||
ME="$(basename "${BASH_ARGV0}")" | ||
|
||
# Allow this script to be executed manually, which requires several variables to be set. | ||
if [ -z "${ALLSKY_HOME}" ] ; then | ||
ALLSKY_HOME=$(realpath "$(dirname "${BASH_ARGV0}")"/..) | ||
export ALLSKY_HOME | ||
fi | ||
|
||
# This script uploads various information relative to the camera setup to the allsky map. | ||
# https://www.thomasjacquin.com/allsky-map/ | ||
# Information is gathered automatically from the settings file | ||
|
||
# Disabling shellcheck to force CI to compile - May need to find a better way to deal with this | ||
# shellcheck disable=SC1090 | ||
source "${ALLSKY_HOME}/variables.sh" | ||
# shellcheck disable=SC1090 | ||
source "${ALLSKY_CONFIG}/config.sh" | ||
|
||
LOCATION=$(jq -r '.location' "$CAMERA_SETTINGS") | ||
OWNER=$(jq -r '.owner' "$CAMERA_SETTINGS") | ||
LATITUDE=$(jq -r '.latitude' "$CAMERA_SETTINGS") | ||
LONGITUDE=$(jq -r '.longitude' "$CAMERA_SETTINGS") | ||
WEBSITE_URL=$(jq -r '.websiteurl' "$CAMERA_SETTINGS") | ||
IMAGE_URL=$(jq -r '.imageurl' "$CAMERA_SETTINGS") | ||
CAMERA=$(jq -r '.camera' "$CAMERA_SETTINGS") | ||
LENS=$(jq -r '.lens' "$CAMERA_SETTINGS") | ||
COMPUTER=$(jq -r '.computer' "$CAMERA_SETTINGS") | ||
MAC_ADDRESS="$(sudo cat /sys/class/net/"$(ip route show default | awk '/default/ {print $5}')"/address)" | ||
|
||
generate_post_data() | ||
{ | ||
cat <<EOF | ||
{ | ||
"location": "$LOCATION", | ||
"owner": "$OWNER", | ||
"latitude": "$LATITUDE", | ||
"longitude": "$LONGITUDE", | ||
"website_url": "$WEBSITE_URL", | ||
"image_url": "$IMAGE_URL", | ||
"camera": "$CAMERA", | ||
"lens": "$LENS", | ||
"computer": "$COMPUTER", | ||
"mac_address": "$MAC_ADDRESS" | ||
} | ||
EOF | ||
} | ||
|
||
# Extract last character of mac address and find its parity | ||
digit="${MAC_ADDRESS: -1}" | ||
decimal=$(( 16#$digit )) | ||
parity="$(( decimal % 2 ))" | ||
|
||
# Only upload every other day to save on server bandwidth | ||
if (( $(date +%d) % 2 == parity )) | ||
then | ||
echo "Week day matches Mac Address ending - upload" | ||
curl -i \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type:application/json" \ | ||
--data "$(generate_post_data)" "https://www.thomasjacquin.com/allsky-map/postToMap.php" | ||
else | ||
echo "Week day doesn't match Mac Address ending - don't upload" | ||
fi |
Oops, something went wrong.