From 96e8a08214815928b0b61f3a83a754821a9bb535 Mon Sep 17 00:00:00 2001 From: starcalc Date: Tue, 30 Aug 2022 21:04:57 +0200 Subject: [PATCH] =?UTF-8?q?image=20build=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 13 ++++++++----- configureandupload.sh => configurefs.sh | 4 +++- uploadfs.sh | 7 +++++++ 3 files changed, 18 insertions(+), 6 deletions(-) rename configureandupload.sh => configurefs.sh (62%) create mode 100644 uploadfs.sh diff --git a/.drone.yml b/.drone.yml index 385eb94..4b847ef 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,8 +18,11 @@ steps: - name: build image: suculent/platformio-docker-build commands: - # Build image + # Build images - platformio run --environment d1_mini + - | + chmod u+x ./configurefs.sh + ./configurefs.sh - name: upload image image: curlimages/curl commands: @@ -35,12 +38,12 @@ steps: # Upload file system image with espota-gateway, leave it to espota-gateway to retry often enough #- | # curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$lastknownip" --form spiffs=@.pio/build/d1_mini/spiffs.bin --no-buffer - - name: build configs - image: suculent/platformio-docker-build + - name: upload configs + image: curlimages/curl commands: - | - chmod u+x ./configureandupload.sh - ./configureandupload.sh + chmod u+x ./uploadfs.sh + ./uploadfs.sh environment: IOTSSID: from_secret: iotssid diff --git a/configureandupload.sh b/configurefs.sh similarity index 62% rename from configureandupload.sh rename to configurefs.sh index ec6a53b..d80792b 100644 --- a/configureandupload.sh +++ b/configurefs.sh @@ -9,8 +9,10 @@ do sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json # Build image with these parameters platformio run --target buildfs --environment d1_mini + # Save this image + cp .pio/build/d1_mini/spiffs.bin .pio/build/d1_mini/spiffs_${curhost}.bin # Upload this image - curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$curip" --form spiffs=@.pio/build/d1_mini/spiffs.bin --no-buffer + # curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$curip" --form spiffs=@.pio/build/d1_mini/spiffs.bin --no-buffer # Revert config.json cp data/homie/config.json.sample data/homie/config.json done < <(cat lastknownhostips) \ No newline at end of file diff --git a/uploadfs.sh b/uploadfs.sh new file mode 100644 index 0000000..6828c6a --- /dev/null +++ b/uploadfs.sh @@ -0,0 +1,7 @@ +#!/bin/bash +while IFS="," read -r curhost curip +do + echo "Host ${curhost} and IP ${curip}" + # Upload this image + curl --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$curip" --form spiffs=@.pio/build/d1_mini/spiffs_${curhost}.bin --no-buffer +done < <(cat lastknownhostips) \ No newline at end of file