Skip to content

Instantly share code, notes, and snippets.

@inverse
Last active October 9, 2018 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inverse/ebea0e04db4d27f76cd8a9c21dd46d5a to your computer and use it in GitHub Desktop.
Save inverse/ebea0e04db4d27f76cd8a9c21dd46d5a to your computer and use it in GitHub Desktop.
Update espurna
#!/bin/bash
declare -a devices=(
""
)
USER=""
PASS=""
# Environment you're deploying
BUILD=""
# Leave empty if no local domain
LOCAL_DOMAIN=""
FIRMWARE_FILE=".pioenvs/$BUILD/firmware.bin"
if [ ! -f $FIRMWARE_FILE ]; then
echo "Firmware file does not exist"
exit
fi
for device in "${devices[@]}"
do
HOST="$device$LOCAL_DOMAIN"
if ping -c 1 $HOST &> /dev/null
then
echo "Updating $device"
UPGRADE_URL="http://$HOST/upgrade"
RESULT=$(curl -s -XPOST --digest -u$USER:$PASS -H "Content-Type: multipart/form-data" -F "filename=@$FIRMWARE_FILE" $UPGRADE_URL)
if [ "$RESULT" == "OK" ]
then
echo "Updated $device"
else
echo "Failed to update $device"
fi
else
echo "Failed to update $device as unreacable"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment