Files
NodeMCU_Lua/Mesures/humidity/bolo/_zremote_cmd.txt

267 lines
6.9 KiB
Plaintext

# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
# zf200619.1626
Todo à faire pour ce projet !
- mettre le nouveau système socat
# 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
# ALT+N+. fermer une session telnet sur le NodeMCU
# définitions à faire si le NodeMCU est connecté en USB !
export luatool_tty="/dev/cu.wchusbserial1410"
###################################
# A faire pour pouvoir manager les NodeMCU de ruru depuis la maison
###################################
# dans une 1ère console
#th1, juste en face du déshumidificateur
ssh -t -L 2323:localhost:2323 ubuntu@www.zuzu-test.ml ssh -N -L 2323:192.168.8.101:23 ubuntu@localhost -p 20223
#th2, à l'étage en face du déshumidificateur
ssh -t -L 2323:localhost:2323 ubuntu@www.zuzu-test.ml ssh -N -L 2323:192.168.8.102:23 ubuntu@localhost -p 20223
#th3, dans la zone revues sur un rayon
ssh -t -L 2323:localhost:2323 ubuntu@www.zuzu-test.ml ssh -N -L 2323:192.168.8.103:23 ubuntu@localhost -p 20223
#th4, proche de la porte du local des archives
ssh -t -L 2323:localhost:2323 ubuntu@www.zuzu-test.ml ssh -N -L 2323:192.168.8.104:23 ubuntu@localhost -p 20223
###################################
# les autres en local à la maison, attention, les adresses ip ne sont peut-être plus justes !
#th0, banc test sur la planche à pain
192.168.0.118
#th5, chambre à coucher
192.168.0.178
#th6, buanderie
192.168.0.162
#th7, cave
192.168.0.199
#th8, salon
192.168.0.124
###############################
# commandes lua pour ce projet
###############################
# dans une 2e console
export zIP="localhost"
export zport="2323"
telnet -rN $zIP $zport
verbose=false
=node.heap()
=node_id
=influxdb_url
for k,v in pairs(_G) do print(k,v) end
dofile("dir.lua")
dir()
dofile("head.lua")
zhead("secrets_project.lua")
~.
./luatool.py --ip $zIP:$zport -f dir.lua
./luatool.py --ip $zIP:$zport -f secrets_project.lua
./luatool.py --ip $zIP:$zport --zrestart
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()
~.
./luatool.py --ip $zIP:$zport -f head.lua
telnet -rN $zIP $zport
dofile("head.lua")
zhead("c.lua")
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
.