Skip to content

Commit

Permalink
Merge pull request #804 from thomasjacquin/postData-IMAGE_DIR
Browse files Browse the repository at this point in the history
postData.sh: use IMAGE_DIR
  • Loading branch information
linuxkidd authored Nov 17, 2021
2 parents e6647cc + e1ed10e commit 138f650
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions scripts/postData.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# This script uploads a file to a website to tell the website when sunset is,
# so it knows when daytime and nighttime are.

# TODO Needs fixing when civil twilight happens after midnight

source "${ALLSKY_HOME}/variables.sh"
Expand All @@ -11,24 +14,19 @@ ME="$(basename "${BASH_ARGV0}")"
latitude=$(jq -r '.latitude' "${CAMERA_SETTINGS}")
longitude=$(jq -r '.longitude' "${CAMERA_SETTINGS}")
timezone=$(date "+%z")
streamDaytime=false

if [[ ${DAYTIME_CAPTURE} == "true" || ${DAYTIME} == "1" ]] ; then # xxxx DAYTIME is old name
streamDaytime="true"
fi

echo "${ME}: Posting Next Twilight Time"
today=`date +%Y-%m-%d`
today=$(date +%Y-%m-%d)
# TODO: should this use "angle" instead of "civil" since that's what the user specified?
time="$(sunwait list set civil ${latitude} ${longitude})"
timeNoZone=${time:0:5}
hhmm=${time:0:5}

FILE="data.json"
OUTPUT_FILE="${ALLSKY_TMP}/${FILE}"
(
echo {
echo \"sunset\": \"$today"T"$timeNoZone":00.000$timezone"\",
echo \"streamDaytime\": \"$streamDaytime\"
echo }
echo {
echo \"sunset\": \"${today}T${hhmm}:00.000${timezone}\",
echo \"streamDaytime\": \"${DAYTIME_CAPTURE}\"
echo }
) > "${OUTPUT_FILE}"

"${ALLSKY_SCRIPTS}/upload.sh" --silent "${OUTPUT_FILE}" "${IMGDIR}" "${FILE}" "PostData"
"${ALLSKY_SCRIPTS}/upload.sh" --silent "${OUTPUT_FILE}" "${IMAGE_DIR}" "${FILE}" "PostData"

0 comments on commit 138f650

Please sign in to comment.