-if [ -z ${MCUHOST:-} ]; then
- # Uses LUATOOL to push init and dependencies to the device; bootstrap!
+luafile () {
+ if [ -z "${LUADIET:-}" ]; then
+ echo "No diet for lua" >&2
+ LUAFILE=$1
+ else
+ DF=$(mktemp -p /tmp esp-pushcommon-XXXXX)
+ if [ -n "${luafilefd:-}" ]; then exec {luafilefd}<&-; fi
+ exec {luafilefd}<>${DF}
+
+ echo "Lua diet ${LUADIET}" >&2
+ lua5.1 \
+ -e 'package.path=package.path..";_external/luasrcdiet/?.lua"' \
+ ./_external/luasrcdiet/bin/luasrcdiet $1 -o ${DF} \
+ --quiet ${=LUADIET} 2>/dev/null
+ rm ${DF}
+ LUAFILE=/dev/fd/${luafilefd}
+ fi
+}
+
+if [ -z "${MCUHOST:-}" ]; then
+ if [ -z "${LUATOOL:-}" ]; then echo "Need LUATOOL or MCUHOST"; exit 1; fi
+ if [ -z "${MCUPORT:-}" ]; then echo "Need MCUPORT or MCUHOST"; exit 1; fi
+ if [ -z "${MCUBAUD:-}" ]; then echo "Need MCUBAUD or MCUHOST"; exit 1; fi
PUSHCMD="${LUATOOL} --delay 0.1 -p ${MCUPORT} -b ${MCUBAUD}"
- dopush() { ${=PUSHCMD} -f $1 -t ${2:-`basename $1`}; }
- dopushcompile() { ${=PUSHCMD} -f $1 -t ${2:-`basename $1`} -c; }
+ dopushtext() { ${=PUSHCMD} -f $1 -t ${2:-`basename $1`} ; }
+ dopushlua() { luafile ${1} ; ${=PUSHCMD} -f ${LUAFILE} -t ${2:-`basename $1`} ; }
+ dopushcompile() { luafile ${1} ; ${=PUSHCMD} -f ${LUAFILE} -t ${2:-`basename $1`} -c ; }
else
- # Uses host/pushvia to push everything if MCUHOST is set
PUSHCMD="./host/pushvia.expect ${MCUHOST} ${PORT:-23}"
- dopush() { ${=PUSHCMD} ${2:-`basename $1`} $1; }
- dopushcompile() { ${=PUSHCMD} ${2:-`basename $1`} $1 compile; }
+ dopushtext() { ${=PUSHCMD} ${2:-`basename $1`} $1 ; }
+ dopushlua() { luafile ${1} ; ${=PUSHCMD} ${2:-`basename $1`} ${LUAFILE} ; }
+ dopushcompile() { luafile ${1} ; ${=PUSHCMD} ${2:-`basename $1`} ${LUAFILE} compile ; }
fi
dopushcompile net/nwfnet-sntp.lua
dopushcompile net/nwfnet-go.lua
dopushcompile net/nwfnet-diag.lua
-#dopush net/conf/nwfnet.conf
-#dopush net/conf/nwfnet.cert
-#dopush net/conf/nwfnet.conf2
+#dopushtext net/conf/nwfnet.conf
+#dopushtext net/conf/nwfnet.cert
+#dopushtext net/conf/nwfnet.conf2
dopushcompile net/fifosock.lua
dopushcompile telnetd/telnetd.lua
dopushcompile telnetd/telnetd-file.lua
dopushcompile telnetd/telnetd-diag.lua
-dopush init.lua
+dopushlua init.lua
echo "SUCCESS"