302 lines
7.1 KiB
Plaintext
302 lines
7.1 KiB
Plaintext
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
|
|
# zf200704.2310
|
|
|
|
|
|
Todo à faire pour ce projet !
|
|
|
|
???
|
|
|
|
# si luatool ne marche pas sur le MAC, il faut lire ceci:
|
|
# https://docs.google.com/document/d/1q64uK3IMOgEDdKaIAttbYuFt4GuLQ06k3FLeyfCsWLg/edit#heading=h.bmefcu67uwj0
|
|
|
|
# raccourcis clavier
|
|
# CTRL+ALT+ENTER envoie au terminal la ligne de l'éditeur
|
|
# SHIT+CTRL+` ouvre le terminal (attention, ne pas oublier de copier le *path* dans le *tree* et le changer)
|
|
# ALT+CMD+F bascule entre le terminal et l'éditeur
|
|
|
|
# définitions à faire AVANT !
|
|
#export luatool_tty="/dev/cu.wchusbserial1410"
|
|
|
|
#export zIP="192.168.0.182"
|
|
#export zport="23"
|
|
|
|
export zIP="localhost"
|
|
export zport="23000"
|
|
|
|
|
|
# ouvrir et fermer (ALT+N+.) une session telnet sur le NodeMCU avec l'adresse zIP)
|
|
telnet -rN $zIP $zport
|
|
~.
|
|
--node.restart()
|
|
collectgarbage()
|
|
=node.heap()
|
|
for k,v in pairs(_G) do print(k,v) end
|
|
|
|
|
|
################################
|
|
# commandes lua pour ce projet #
|
|
################################
|
|
# pour les tests en direct sur la gateway
|
|
ssh ubuntu@www.zuzu-test.ml
|
|
socat TCP-LISTEN:23069,fork,reuseaddr STDIO
|
|
################################
|
|
# pour les tests en remote
|
|
killall -9 ssh
|
|
ssh ubuntu@www.zuzu-test.ml killall -9 socat
|
|
|
|
ssh ubuntu@www.zuzu-test.ml socat TCP-LISTEN:23069,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 &
|
|
# SHIFT+CMD+K SHIFT+CMD+K ALT+CMD+F
|
|
|
|
watch -n 1 'ssh ubuntu@www.zuzu-test.ml netstat -nat |grep 230'
|
|
|
|
# ALT+CMD+F CTRL+C ALT+CMD+F
|
|
|
|
export zIP="localhost"
|
|
export zport="23000"
|
|
|
|
ssh -N -L 23000:localhost:23000 ubuntu@www.zuzu-test.ml &
|
|
|
|
telnet -rN $zIP $zport
|
|
|
|
verbose=false
|
|
~.
|
|
|
|
=node.heap()
|
|
verbose=true
|
|
node.restart()
|
|
|
|
dofile("head.lua")
|
|
zhead("0_ultra_son.lua")
|
|
|
|
./luatool.py --ip $zIP:$zport -f boot.lua
|
|
./luatool.py --ip $zIP:$zport -f 0_get_power.lua
|
|
./luatool.py --ip $zIP:$zport -f 0_cron.lua
|
|
./luatool.py --ip $zIP:$zport -f 0_http_post.lua
|
|
./luatool.py --ip $zIP:$zport -f 0_tst5_socat.lua
|
|
./luatool.py --ip $zIP:$zport -f 0_ultra_son.lua
|
|
|
|
./luatool.py --ip $zIP:$zport --zrestart
|
|
|
|
|
|
= node.bootreason()
|
|
# https://nodemcu.readthedocs.io/en/master/modules/node/#nodebootreason
|
|
|
|
for k,v in pairs(_G) do print(k,v) end
|
|
verbose=true
|
|
#zdyn
|
|
|
|
|
|
|
|
|
|
./luatool.py --ip $zIP:$zport -f api_sonoff.html
|
|
http://192.168.0.182
|
|
|
|
./luatool.py --ip $zIP:$zport -f dir.lua
|
|
|
|
telnet -rN $zIP $zport
|
|
verbose=false
|
|
verbose=true
|
|
~.
|
|
|
|
=node.heap()
|
|
collectgarbage()
|
|
=node.heap()
|
|
|
|
|
|
dofile("dir.lua")
|
|
dir()
|
|
for k,v in pairs(_G) do print(k,v) end
|
|
dofile("wifi_info.lua")
|
|
|
|
node.restart()
|
|
|
|
~.
|
|
./luatool.py --ip $zIP:$zport -f head.lua
|
|
telnet -rN $zIP $zport
|
|
dofile("head.lua")
|
|
zhead("boot.lua")
|
|
|
|
|
|
|
|
verbose=true
|
|
verbose=false
|
|
zsort_rssi() zshow()
|
|
|
|
|
|
#commandes luatool pour ce projet le .137 est à jour avec la nouvelle version du wifi !
|
|
~.
|
|
./luatool.py --ip $zIP:$zport -l
|
|
./luatool.py --ip $zIP:$zport -f wifi_init.lua
|
|
|
|
|
|
./luatool.py --ip $zIP:$zport -f secrets_wifi.lua
|
|
./luatool.py --ip $zIP:$zport -f initz.lua -t init.lua
|
|
./luatool.py --ip $zIP:$zport -f boot.lua
|
|
./luatool.py --ip $zIP:$zport -f boot2.lua
|
|
./luatool.py --ip $zIP:$zport -f wifi_init.lua
|
|
./luatool.py --ip $zIP:$zport -f set_time.lua
|
|
./luatool.py --ip $zIP:$zport -f wifi_info.lua
|
|
./luatool.py --ip $zIP:$zport -f c.lua
|
|
./luatool.py --ip $zIP:$zport -f cat.lua
|
|
./luatool.py --ip $zIP:$zport -f flash_led_xfois.lua
|
|
./luatool.py --ip $zIP:$zport -f head.lua
|
|
|
|
./luatool.py --ip $zIP:$zport -f b.lua
|
|
./luatool.py --ip $zIP:$zport -f web_srv2.lua
|
|
./luatool.py --ip $zIP:$zport -f z_index.html
|
|
|
|
|
|
./luatool.py --ip $zIP:$zport -f wifi_get_conf.html
|
|
./luatool.py --ip $zIP:$zport -f wifi_set_conf.html
|
|
|
|
|
|
./luatool.py --ip $zIP:$zport -f z_page1.html
|
|
./luatool.py --ip $zIP:$zport -f z_page2.html
|
|
./luatool.py --ip $zIP:$zport -f z_page3.html
|
|
./luatool.py --ip $zIP:$zport -f z_page4.html
|
|
|
|
./luatool.py --ip $zIP:$zport --delete wifi_ap_start.lua
|
|
./luatool.py --ip $zIP:$zport --delete wifi_cli_conf.lua
|
|
./luatool.py --ip $zIP:$zport --delete wifi_cli_start.lua
|
|
./luatool.py --ip $zIP:$zport --delete dir.lua
|
|
./luatool.py --ip $zIP:$zport --delete initz.lua
|
|
./luatool.py --ip $zIP:$zport --delete wifi_conf.lua
|
|
|
|
|
|
|
|
dofile("wifi_info.lua")
|
|
--node.restart()
|
|
for k,v in pairs(_G) do print(k,v) end
|
|
t=12
|
|
t=nil
|
|
print(pcall(function () print("2"..t) end))
|
|
|
|
|
|
|
|
# ici c'est maintenant ;-)
|
|
~.
|
|
./luatool.py --ip $zIP:$zport -f b.lua
|
|
#./luatool.py --ip $zIP:$zport --zrestart
|
|
telnet -rN $zIP $zport
|
|
zsort_rssi() zshow()
|
|
print(ztrig_rssi)
|
|
ztrig_rssi=-1000
|
|
ztrig_rssi=-90
|
|
|
|
|
|
|
|
# test de la gestion des erreurs
|
|
~.
|
|
./luatool.py --ip $zIP:$zport -f c.lua
|
|
#./luatool.py --ip $zIP:$zport --zrestart
|
|
telnet -rN $zIP $zport
|
|
status, err = pcall(function () dofile("c.lua") end) if status==false then print("Error: ",err) end
|
|
zerr=nil
|
|
zerr=1
|
|
ztmr_tst_err:unregister()
|
|
|
|
|
|
|
|
|
|
ztmr_tst_err:unregister()
|
|
for k,v in pairs(_G) do print(k,v) end
|
|
|
|
./luatool.py --ip $zIP --zrestart
|
|
|
|
|
|
# faire un cat d'un fichier sur le NodeMCU
|
|
dofile("cat.lua")
|
|
cat("boot2.lua")
|
|
|
|
|
|
# commandes luatool
|
|
./luatool.py -h
|
|
./luatool.py --ip $zIP:$zport -i
|
|
./luatool.py --ip $zIP:$zport -l
|
|
./luatool.py --ip $zIP:$zport -f toto.lua -d
|
|
./luatool.py --ip $zIP:$zport --delete toto.lua
|
|
|
|
|
|
|
|
****************************************************************************
|
|
|
|
|
|
# création des tunnels ssh
|
|
ATTENTION: dans un premier terminal !
|
|
Pour Bolo à Ruchonnet:
|
|
ssh -t -L 2323:localhost:2323 ubuntu@www.zuzu-test.ml ssh -N -L 2323:192.168.8.102:23 ubuntu@localhost -p 20223
|
|
|
|
Pour le Crêt
|
|
ssh -N -L 2323:192.168.0.137:23 admin@z.zufferey.com -p 1822
|
|
ssh -N -L 2323:192.168.0.122:23 admin@z.zufferey.com -p 1822
|
|
ssh -N -L 2323:192.168.0.118:23 admin@z.zufferey.com -p 1822
|
|
|
|
ATTENTION: dans un deuxième terminal !
|
|
export zIP="localhost"
|
|
export zport="2323"
|
|
telnet -rN $zIP $zport
|
|
~.
|
|
=node.heap()
|
|
|
|
verbose=false
|
|
verbose=true
|
|
|
|
dofile("dir2.lua")
|
|
dir()
|
|
filec("head.lua")
|
|
|
|
dofile("head.lua")
|
|
zhead("dir2.lua")
|
|
|
|
dofile("cat.lua")
|
|
cat("head.lua")
|
|
|
|
~.
|
|
--node.restart()
|
|
=node.heap()
|
|
|
|
|
|
status, err = pcall(function () fonction_a_tester() end) if status==false then print("Error: ",err) end
|
|
status, err = pcall(function () toto() end) if status==false then print("Error: ",err) end
|
|
|
|
|
|
|
|
Gestion de la passerelle SSH reverse
|
|
Puis depuis une autre console on peut faire directement pour aller sur l'OpiZ (ici le 20223):
|
|
ssh -t ubuntu@www.zuzu-test.ml ssh ubuntu@localhost -p 20223
|
|
|
|
ou
|
|
|
|
1ère console
|
|
On établit le tunnel local avec l'OpiZ
|
|
ssh -N -L 20223:localhost:20223 ubuntu@www.zuzu-test.ml
|
|
|
|
|
|
2ème console, on utilise le tunnel OpiZ en local sur sa machine
|
|
pour aller sur l'OpiZ
|
|
ssh ubuntu@localhost -p 20223
|
|
|
|
pour copier sa clef SSH depuis un MAC
|
|
./ssh-copy-id -i ~/.ssh/id_rsa.pub 'ubuntu@localhost -p 20223'
|
|
après on devrait pouvoir se connecter sans devoir entrer son password à chaque fois
|
|
ssh ubuntu@localhost -p 20223
|
|
|
|
ou, on établit un tunnel pour telnet sur un NodeMCU
|
|
ssh -L 2323:192.168.0.137:23 ubuntu@localhost -p 20223
|
|
puis
|
|
telnet -rN localhost 2323
|
|
|
|
ou, on établit un tunnel pour le rpimonotor sur l'OpiZ
|
|
ssh -N -L 8888:192.168.0.113:8888 ubuntu@localhost -p 20223
|
|
puis
|
|
http://localhost:8888
|
|
|
|
ou, on établit un tunnel proxy Socket 5 pour le modem 4G HUAWEI sur l'OpiZ
|
|
ssh -N -D 8080 ubuntu@localhost -p 20223
|
|
puis depuis le browser FireFox avec le plugin FoxyProxy Socket 5 sur localhost port 8080
|
|
http://192.168.8.1
|
|
|
|
|
|
|
|
.
|