Automatic update all hosts
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
b09717595a
commit
50b37674ff
71
.drone.yml
71
.drone.yml
|
@ -1,54 +1,47 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: default
|
name: default
|
||||||
steps:
|
steps:
|
||||||
- name: fetch ip
|
- name: fetch ips
|
||||||
image: cburki/mosquitto-clients
|
image: cburki/mosquitto-clients
|
||||||
commands:
|
commands:
|
||||||
- echo "$hostname"
|
- rm -f lastknownhostips
|
||||||
- mosquitto_sub -h raum.ctdo.de -t "homie/$hostname/\$localip" -C 1 | tr -d '\n'
|
- cat hosts
|
||||||
- mosquitto_sub -h raum.ctdo.de -t "homie/$hostname/\$localip" -C 1 | tr -d '\n' >lastknownip
|
- for h in $(cat hosts); do echo $h; echo $h; done
|
||||||
- cat "lastknownip"
|
- for h in $(cat hosts); do mosquitto_sub -h raum.ctdo.de -t "homie/$h/\$localip" -C 1; done >lastknownips
|
||||||
environment:
|
- for h in $(cat hosts); do echo -n "$h," >>lastknownhostips; mosquitto_sub -h raum.ctdo.de -t "homie/$h/\$localip" -C 1 >>lastknownhostips; done
|
||||||
hostname:
|
- cat lastknownhostips
|
||||||
from_secret: hostname
|
- cat lastknownips
|
||||||
- name: configure
|
|
||||||
image: alpine
|
|
||||||
commands:
|
|
||||||
- sed -i "s/WIFISSID/$IOTSSID/" data/homie/config.json
|
|
||||||
- sed -i "s/WIFIPASS/$iotpwd/" data/homie/config.json
|
|
||||||
- sed -i "s/HOSTNAME/$hostname/g" data/homie/config.json
|
|
||||||
- sed -i "s/HOSTNAME/$hostname/g" data/homie/config.json
|
|
||||||
- lastknownip=$(cat lastknownip)
|
|
||||||
- sed -i "s/HOSTNAME/$lastknownip/g" platformio.ini
|
|
||||||
environment:
|
|
||||||
hostname:
|
|
||||||
from_secret: hostname
|
|
||||||
IOTSSID:
|
|
||||||
from_secret: iotssid
|
|
||||||
iotpwd:
|
|
||||||
from_secret: iotpwd
|
|
||||||
- name: build
|
- name: build
|
||||||
image: suculent/platformio-docker-build
|
image: suculent/platformio-docker-build
|
||||||
commands:
|
commands:
|
||||||
# - pip install -U platformio
|
# Build images
|
||||||
# Build image
|
|
||||||
- platformio run --environment d1_mini
|
- platformio run --environment d1_mini
|
||||||
# Build file system image
|
- |
|
||||||
- platformio run --target buildfs --environment d1_mini
|
chmod u+x ./configurefs.sh
|
||||||
- name: upload
|
chmod u+x ./uploadfs.sh
|
||||||
|
./configurefs.sh
|
||||||
|
- name: upload image
|
||||||
image: curlimages/curl
|
image: curlimages/curl
|
||||||
commands:
|
commands:
|
||||||
- lastknownip=$(cat lastknownip)
|
|
||||||
- echo "$lastknownip"
|
|
||||||
# Upload image with espota-gateway
|
# Upload image with espota-gateway
|
||||||
|
# All hosts receive the identical image
|
||||||
- |
|
- |
|
||||||
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 firmware=@.pio/build/d1_mini/firmware.bin --no-buffer
|
cat lastknownips
|
||||||
# TODO: Upload file system image with espota-gateway, if the device is available again (or leave it to espota-gateway to retry often enough)
|
for thisip in $(cat lastknownips)
|
||||||
- |
|
do
|
||||||
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
|
echo "Current IP to upload is $thisip"
|
||||||
|
curl -m 180 --insecure --no-progress-meter --fail-with-body --request POST --url "https://espota.ctdo.de/" --header "Content-Type: multipart/form-data" --form ip="$thisip" --form firmware=@.pio/build/d1_mini/firmware.bin --no-buffer
|
||||||
### matrix-builds? - for multiple volumeknobs?
|
done
|
||||||
### https://0-8-0.docs.drone.io/matrix-builds/
|
- name: upload configs
|
||||||
###
|
image: curlimages/curl
|
||||||
|
commands:
|
||||||
|
- ls -lA .
|
||||||
|
- /bin/sh ./uploadfs.sh
|
||||||
|
environment:
|
||||||
|
IOTSSID:
|
||||||
|
from_secret: iotssid
|
||||||
|
iotpwd:
|
||||||
|
from_secret: iotpwd
|
||||||
|
|
|
@ -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
|
||||||
|
# Save this image
|
||||||
|
cp .pio/build/d1_mini/spiffs.bin .pio/build/d1_mini/spiffs_${curhost}.bin
|
||||||
|
# Revert config.json
|
||||||
|
cp data/homie/config.json.sample data/homie/config.json
|
||||||
|
done < <(cat lastknownhostips)
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
echo "Running"
|
||||||
|
while read line
|
||||||
|
do
|
||||||
|
echo "Line is ${line}"
|
||||||
|
curhost=$(echo ${line} | cut -d ',' -f1)
|
||||||
|
curip=$(echo ${line} | cut -d ',' -f2)
|
||||||
|
echo "Host ${curhost} and IP ${curip}"
|
||||||
|
# Upload this image
|
||||||
|
curl -m 180 --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)
|
Loading…
Reference in New Issue