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
|
||||
type: docker
|
||||
name: default
|
||||
steps:
|
||||
- name: fetch ip
|
||||
- name: fetch ips
|
||||
image: cburki/mosquitto-clients
|
||||
commands:
|
||||
- echo "$hostname"
|
||||
- mosquitto_sub -h raum.ctdo.de -t "homie/$hostname/\$localip" -C 1 | tr -d '\n'
|
||||
- mosquitto_sub -h raum.ctdo.de -t "homie/$hostname/\$localip" -C 1 | tr -d '\n' >lastknownip
|
||||
- cat "lastknownip"
|
||||
environment:
|
||||
hostname:
|
||||
from_secret: hostname
|
||||
- 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
|
||||
- rm -f lastknownhostips
|
||||
- cat hosts
|
||||
- for h in $(cat hosts); do echo $h; echo $h; done
|
||||
- for h in $(cat hosts); do mosquitto_sub -h raum.ctdo.de -t "homie/$h/\$localip" -C 1; done >lastknownips
|
||||
- for h in $(cat hosts); do echo -n "$h," >>lastknownhostips; mosquitto_sub -h raum.ctdo.de -t "homie/$h/\$localip" -C 1 >>lastknownhostips; done
|
||||
- cat lastknownhostips
|
||||
- cat lastknownips
|
||||
- name: build
|
||||
image: suculent/platformio-docker-build
|
||||
commands:
|
||||
# - pip install -U platformio
|
||||
# Build image
|
||||
# Build images
|
||||
- platformio run --environment d1_mini
|
||||
# Build file system image
|
||||
- platformio run --target buildfs --environment d1_mini
|
||||
- name: upload
|
||||
- |
|
||||
chmod u+x ./configurefs.sh
|
||||
chmod u+x ./uploadfs.sh
|
||||
./configurefs.sh
|
||||
- name: upload image
|
||||
image: curlimages/curl
|
||||
commands:
|
||||
- lastknownip=$(cat lastknownip)
|
||||
- echo "$lastknownip"
|
||||
# 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
|
||||
# TODO: Upload file system image with espota-gateway, if the device is available again (or 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
|
||||
|
||||
### matrix-builds? - for multiple volumeknobs?
|
||||
### https://0-8-0.docs.drone.io/matrix-builds/
|
||||
###
|
||||
cat lastknownips
|
||||
for thisip in $(cat lastknownips)
|
||||
do
|
||||
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
|
||||
done
|
||||
- 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