@@ -21,19 +21,20 @@ checkExecutable "paste"
21
21
22
22
# Default wait time for OTA process to complete
23
23
waittime=600
24
+ newtagversion=" "
24
25
25
26
while getopts t:v:f:o: flag
26
27
do
27
28
case " ${flag} " in
28
29
t) tag=${OPTARG} ;;
29
- v) version =${OPTARG} ;;
30
+ v) newtagversion =${OPTARG} ;;
30
31
f) firmwarefile=${OPTARG} ;;
31
32
o) waittime=${OPTARG} ;;
32
33
esac
33
34
done
34
35
35
36
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 >]"
37
38
exit 1
38
39
fi
39
40
@@ -87,6 +88,7 @@ while [ $waittime -gt 0 ]; do
87
88
otastatuslines=$( arduino-cloud-cli ota status --ota-ids $otaids --format json)
88
89
otastatusinpcnt=$( echo $otastatuslines | grep in_progress | wc -l)
89
90
otastatuspencnt=$( echo $otastatuslines | grep pending | wc -l)
91
+ otasucceeded=$( echo $otastatuslines | jq -r ' .[] | select (.status | contains("succeeded")) | .device_id' | uniq | paste -sd " ," -)
90
92
if [[ $otastatusinpcnt -eq 0 && $otastatuspencnt -eq 0 ]]; then
91
93
correctlyfinished=1
92
94
break
@@ -97,11 +99,15 @@ echo ""
97
99
echo " Status report:"
98
100
arduino-cloud-cli ota status --ota-ids $otaids
99
101
100
- if [ $correctlyfinished -eq 1 ]; then
102
+ if [ $correctlyfinished -eq 0 ]; then
101
103
echo " OTA process did not complete within the specified time for some boards"
102
104
exit 1
103
105
else
104
106
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
105
111
exit 0
106
112
fi
107
113
0 commit comments