-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
374 additions
and
174 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,41 @@ | ||
#!/bin/bash | ||
|
||
if [ $# -ne 5 ]; then | ||
echo "Usage: $0 <broker> <port> <prefix> <start_date> <end_date>" | ||
exit 1 | ||
fi | ||
|
||
broker=$1 | ||
port=$2 | ||
prefix=$3 | ||
start_date=$4 | ||
end_date=$5 | ||
|
||
if ! [[ $port =~ ^[0-9]+$ ]]; then | ||
echo "Invalid port number. Please provide a positive integer." | ||
exit 1 | ||
fi | ||
if (($port < 1)) || (($port > 65535)); then | ||
echo "Invalid port number. Port must be between 1 and 65535." | ||
exit 1 | ||
fi | ||
if ! [[ $start_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || ! [[ $end_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then | ||
echo "Invalid date format. Please use YYYY-MM-DD." | ||
exit 1 | ||
fi | ||
if ! date -d "$start_date" &> /dev/null; then | ||
echo "Invalid start date: $start_date" | ||
exit 1 | ||
fi | ||
if ! date -d "$end_date" &> /dev/null; then | ||
echo "Invalid end date: $end_date" | ||
exit 1 | ||
fi | ||
|
||
end_date=$(date -d "$end_date + 1 day" +"%Y-%m-%d") | ||
|
||
while [[ $start_date < $end_date ]]; do | ||
echo "Requesting data for $start_date" | ||
mosquitto_pub -h $broker -p $port -t "$prefix/set/request/day" -m "$start_date" | ||
start_date=$(date -d "$start_date + 1 day" +"%Y-%m-%d") | ||
done |