Last active
October 9, 2018 19:04
-
-
Save inverse/ebea0e04db4d27f76cd8a9c21dd46d5a to your computer and use it in GitHub Desktop.
Update espurna
This file contains hidden or 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
#!/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