OTA socat server
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 3 Aug 2016 23:49:26 +0000 (01:49 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 3 Aug 2016 23:49:26 +0000 (01:49 +0200)
ota-upgrade.sh [new file with mode: 0755]

diff --git a/ota-upgrade.sh b/ota-upgrade.sh
new file mode 100755 (executable)
index 0000000..52a5940
--- /dev/null
@@ -0,0 +1,9 @@
+mosquitto_sub -h rpi2 -t stat/sonoff/otaurl -C 2 &
+mosquitto_pub -h rpi2 -t cmnd/sonoff/otaurl -m ''
+mosquitto_pub -h rpi2 -t cmnd/sonoff/otaurl -m 'http://'`hostname -s`':8000'
+
+file=`ls -t /tmp/*.tmp/sonoff.ino.bin | head`
+
+socat -vv TCP-LISTEN:8000,crlf,reuseaddr,fork SYSTEM:"echo HTTP/1.0 200; echo Content-Type\: application/octet-stream; echo Content-Length\: `stat --format %s $file` ; echo ; cat $file"
+
+