Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postData.sh: use IMAGE_DIR #804

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"