Skip to content

Commit 5983aae

Browse files
committed
Tagging support
1 parent e222bec commit 5983aae

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

example/tools/ota/ota_mass_upload.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@ checkExecutable "paste"
2121

2222
# Default wait time for OTA process to complete
2323
waittime=600
24+
newtagversion=""
2425

2526
while getopts t:v:f:o: flag
2627
do
2728
case "${flag}" in
2829
t) tag=${OPTARG};;
29-
v) version=${OPTARG};;
30+
v) newtagversion=${OPTARG};;
3031
f) firmwarefile=${OPTARG};;
3132
o) waittime=${OPTARG};;
3233
esac
3334
done
3435

3536
if [[ "$firmwarefile" == "" || "$tag" == "" || "$waittime" == "" ]]; then
36-
echo "Usage: $0 -t <tag> -f <firmwarefile> [-o <waittime>] [-v <new firmware version>]"
37+
echo "Usage: $0 -t <tag> -f <firmwarefile> [-o <waittime>] [-v <new firmware version for tagging>]"
3738
exit 1
3839
fi
3940

@@ -87,6 +88,7 @@ while [ $waittime -gt 0 ]; do
8788
otastatuslines=$(arduino-cloud-cli ota status --ota-ids $otaids --format json)
8889
otastatusinpcnt=$(echo $otastatuslines | grep in_progress | wc -l)
8990
otastatuspencnt=$(echo $otastatuslines | grep pending | wc -l)
91+
otasucceeded=$(echo $otastatuslines | jq -r '.[] | select (.status | contains("succeeded")) | .device_id' | uniq | paste -sd "," -)
9092
if [[ $otastatusinpcnt -eq 0 && $otastatuspencnt -eq 0 ]]; then
9193
correctlyfinished=1
9294
break
@@ -97,11 +99,15 @@ echo ""
9799
echo "Status report:"
98100
arduino-cloud-cli ota status --ota-ids $otaids
99101

100-
if [ $correctlyfinished -eq 1 ]; then
102+
if [ $correctlyfinished -eq 0 ]; then
101103
echo "OTA process did not complete within the specified time for some boards"
102104
exit 1
103105
else
104106
echo "OTA process completed successfully for all boards"
107+
if [ "$newtagversion" != "" ]; then
108+
echo "Tagging updated devices with tag: $newtagversion"
109+
arduino-cloud-cli device create-tags --ids $otasucceeded --tags $newtagversion
110+
fi
105111
exit 0
106112
fi
107113

0 commit comments

Comments
 (0)