Last active
December 20, 2016 22:26
-
-
Save temp3l/e9cc06258f07462bb658580d888d9fd0 to your computer and use it in GitHub Desktop.
sync esp8266 files on change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
nmcut="node ../node_modules/nodemcu-tool/bin/nodemcu-tool.js" | |
terminal="xfce4-terminal --geometry=120x20+300+200" | |
$terminal -e "$nmcut --connection-delay 200 terminal </dev/null &>/dev/null &" | |
killSessions () | |
{ | |
pid=$(ps fax | grep nodemcu-tool | grep terminal|awk -F " " '{print $1}' ) | |
echo "PID was: $pid" | |
if [ ! -z "$pid" ]; then | |
echo "killing" | |
kill $pid; | |
fi | |
} | |
inotifywait -mq -e close_write --format %w%f *.lua | while read FILE | |
do | |
killSessions | |
sleep 1 | |
nodemcu-tool upload $FILE | |
if [ "$FILE" = "init.lua" ]; then | |
sleep 1 | |
nodemcu-tool reset | |
fi | |
$terminal -e "$nmcut --connection-delay 200 terminal </dev/null &>/dev/null &" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment