From aff20e272c783b9ab07654ee50e64b40b1b647a6 Mon Sep 17 00:00:00 2001 From: Mimoja Date: Tue, 4 Jul 2023 20:17:42 +0200 Subject: [PATCH] Add updateRemote.sh script to update the contentFs on multiple APs at once As flashing a new LittleFS in case of e.g. a changed main.js is taking time and the provided web interface is not the fastest to navigate we are introducing a small script to upload the whole data folder to the esp. It can also be sourced into a shell allowing for manual file uploads to the esp. In addition we are also adding a "push_ota.sh" script designed to show its use as well as uploading the recenty build firmware to the esp where future commits will allow of SDCard based updates. Signed-off-by: Mimoja --- ESP32_AP-Flasher/push_ota.sh | 19 ++++++++++++ ESP32_AP-Flasher/updateRemote.sh | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 ESP32_AP-Flasher/push_ota.sh create mode 100755 ESP32_AP-Flasher/updateRemote.sh diff --git a/ESP32_AP-Flasher/push_ota.sh b/ESP32_AP-Flasher/push_ota.sh new file mode 100755 index 00000000..8afa7792 --- /dev/null +++ b/ESP32_AP-Flasher/push_ota.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +source updateRemote.sh > /dev/null + +if [ -z "$IP" ] + then + echo "ERROR: Empty IP variable" + exit 1 +fi + +if [ -z "$PIOENV" ] + then + echo "ERROR: Empty PIOENV variable" + exit 1 +fi + +md5sum .pio/build/$PIOENV/firmware.bin | tee .pio/build/$PIOENV/firmware.md5 +upload_file .pio/build/$PIOENV/firmware.md5:ota_md5.txt +upload_file .pio/build/$PIOENV/firmware.bin:ota.bin diff --git a/ESP32_AP-Flasher/updateRemote.sh b/ESP32_AP-Flasher/updateRemote.sh new file mode 100755 index 00000000..f79eb419 --- /dev/null +++ b/ESP32_AP-Flasher/updateRemote.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +(return 0 2>/dev/null) && sourced=1 || sourced=0 + +if [ $sourced -eq 0 ]; then + if [ $# -eq 0 ] + then + echo "No IP address provided" + exit 1 + fi + + IP=$1 + + if [ -z "$IP" ] + then + echo "ERROR: Empty IP" + exit 1 +fi +fi +upload_file () { + for file in "$@" + do + split=( $(echo $file | tr ":" " ") ) + echo $split + filename=${split[0]} + if [ -z ${split[1]} ]; then + filepath=$(echo ${filename} | cut -d'/' -f2-) + else + filepath=${split[1]} + fi + echo $filename "-->" $filepath + + curl "http://${IP}/edit" -X POST \ + -H "Origin: http://${IP}" \ + -H 'Connection: keep-alive' \ + -H "Referer: http://${IP}/edit" \ + -F "data=@${filename};filename=\"${filepath}\"" + echo "" + done +} + +export -f upload_file + +if [ $sourced -eq 0 ]; then + export IP + find data -type f -exec bash -c "upload_file {} $IP" \; +else + echo "You can now call " + echo "IP=1.2.3.4 upload_file data/file1.txt data/file2.txt:target.txt" +fi