From f58e5b5e5c605f19fe3dffa789e08e281139bc29 Mon Sep 17 00:00:00 2001 From: starcalc Date: Tue, 30 Aug 2022 20:47:29 +0200 Subject: [PATCH] configureandupload.sh --- .drone.yml | 17 ++--------------- configureandupload.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 configureandupload.sh diff --git a/.drone.yml b/.drone.yml index 66fa566..385eb94 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,21 +39,8 @@ steps: image: suculent/platformio-docker-build commands: - | - while IFS="," read -r curhost, curip - do - echo "Host ${curhost} and IP ${curip}" - cp data/homie/config.json data/homie/config.json.sample - sed -i "s/WIFISSID/$IOTSSID/" data/homie/config.json - sed -i "s/WIFIPASS/$iotpwd/" data/homie/config.json - sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json - sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json - # Build image with these parameters - platformio run --target buildfs --environment d1_mini - # 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 - # Revert config.json - cp data/homie/config.json.sample data/homie/config.json - done < <(cat lastknownhostips) + chmod u+x ./configureandupload.sh + ./configureandupload.sh environment: IOTSSID: from_secret: iotssid diff --git a/configureandupload.sh b/configureandupload.sh new file mode 100644 index 0000000..d19b570 --- /dev/null +++ b/configureandupload.sh @@ -0,0 +1,16 @@ +#!/bin/bash +while IFS="," read -r curhost, curip +do + echo "Host ${curhost} and IP ${curip}" + cp data/homie/config.json data/homie/config.json.sample + sed -i "s/WIFISSID/$IOTSSID/" data/homie/config.json + sed -i "s/WIFIPASS/$iotpwd/" data/homie/config.json + sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json + sed -i "s/HOSTNAME/${curhost}/g" data/homie/config.json + # Build image with these parameters + platformio run --target buildfs --environment d1_mini + # 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 + # Revert config.json + cp data/homie/config.json.sample data/homie/config.json +done < <(cat lastknownhostips) \ No newline at end of file