Flow Système avec Shutdown
[
{
"id": "ce1fc82ec605926d",
"type": "tab",
"label": "System",
"disabled": false,
"info": "",
"env": []
},
{
"id": "0e22352e34bb4f7e",
"type": "group",
"z": "ce1fc82ec605926d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"dc22522215edcc6d",
"3d15ca3c0327f705",
"7ed5221292b93b7e",
"68b8b999e18fb009",
"8ef068a4ccec9f61",
"2f1fc41ee08ab11c",
"bee4ca5c3a2a0c0a"
],
"x": 34,
"y": 39,
"w": 932,
"h": 182
},
{
"id": "31f0029ded74155d",
"type": "group",
"z": "ce1fc82ec605926d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"a1f6898b.57ef18",
"1b18c49248687c8b",
"226440a77d1f6bf2"
],
"x": 34,
"y": 239,
"w": 452,
"h": 149.5
},
{
"id": "79cbc348476a8bcb",
"type": "group",
"z": "ce1fc82ec605926d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"79096672e2f7e12e",
"0530c582ac67d522",
"9a576d987182bfc2"
],
"x": 34,
"y": 419,
"w": 472,
"h": 149.5
},
{
"id": "dc22522215edcc6d",
"type": "udp in",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"name": "",
"iface": "",
"port": "30303",
"ipv": "udp4",
"multicast": "false",
"group": "",
"datatype": "buffer",
"x": 120,
"y": 160,
"wires": [
[
"2f1fc41ee08ab11c"
]
]
},
{
"id": "3d15ca3c0327f705",
"type": "exec",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"command": "sudo ifconfig",
"addpay": "",
"append": "",
"useSpawn": "false",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "",
"x": 430,
"y": 160,
"wires": [
[
"7ed5221292b93b7e"
],
[],
[]
]
},
{
"id": "7ed5221292b93b7e",
"type": "function",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"name": "Get IP",
"func": "let data = {};\nlet StartIndex,EndIndex;\n\n// Get IPV4 Index\nStartIndex = msg.payload.indexOf(\"inet \") + 5;\nEndIndex = msg.payload.indexOf(\"netmask\") - 2;\ndata.ipv4 = msg.payload.substring(StartIndex, EndIndex);\n\n// Get ipv6 Index\nStartIndex = msg.payload.indexOf(\"inet6\") + 6;\nEndIndex = msg.payload.indexOf(\"prefixlen\") - 2;\ndata.ipv6 = msg.payload.substring(StartIndex, EndIndex);\n\n// Get netmask Index\nStartIndex = msg.payload.indexOf(\"netmask\") + 8;\nEndIndex = msg.payload.indexOf(\"broadcast\") - 2;\ndata.netmask = msg.payload.substring(StartIndex, EndIndex);\n\n\n// Get mac Index\nStartIndex = msg.payload.indexOf(\"ether\") + 6;\nEndIndex = msg.payload.indexOf(\"txqueuelen\") - 2;\ndata.macaddr = msg.payload.substring(StartIndex, EndIndex);\n\nmsg.payload = data;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 120,
"wires": [
[
"68b8b999e18fb009"
]
]
},
{
"id": "68b8b999e18fb009",
"type": "function",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"name": "Parse and send annonce",
"func": "let string = \"\";\nlet annonceIP = global.get(\"AnnounceIP\");\n\n// Forge frame\nstring = \"NRX800\\r\\n\" + msg.payload.macaddr + \"\\r\\n1880\\r\\nNRX800\\r\\n\"\nmsg.payload = string;\n\n// Set IP from\nmsg.Adresse = annonceIP[0];\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 180,
"wires": [
[
"8ef068a4ccec9f61"
]
]
},
{
"id": "8ef068a4ccec9f61",
"type": "udp out",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"name": "",
"addr": "",
"iface": "",
"port": "30303",
"ipv": "udp4",
"outport": "",
"base64": false,
"multicast": "false",
"x": 870,
"y": 120,
"wires": []
},
{
"id": "2f1fc41ee08ab11c",
"type": "function",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"name": "Get message",
"func": "let ipFrom = \"\";\nlet annonceIP = global.get(\"AnnounceIP\");\n\nannonceIP = {};\n\n// Get ipfrom\nipFrom = msg.ip;\nannonceIP[0] = \"\";\nannonceIP[0] = ipFrom;\n// Save to global data\nglobal.set(\"AnnounceIP\", annonceIP);\n\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 270,
"y": 160,
"wires": [
[
"3d15ca3c0327f705"
]
]
},
{
"id": "bee4ca5c3a2a0c0a",
"type": "comment",
"z": "ce1fc82ec605926d",
"g": "0e22352e34bb4f7e",
"name": "GCE Scan Device service",
"info": "",
"x": 170,
"y": 80,
"wires": []
},
{
"id": "a1f6898b.57ef18",
"type": "exec",
"z": "ce1fc82ec605926d",
"g": "31f0029ded74155d",
"command": "sudo reboot #",
"addpay": false,
"append": "",
"useSpawn": "",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "Reboot NRX800",
"x": 380,
"y": 340,
"wires": [
[],
[],
[]
]
},
{
"id": "1b18c49248687c8b",
"type": "inject",
"z": "ce1fc82ec605926d",
"g": "31f0029ded74155d",
"name": "Send reboot",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 340,
"wires": [
[
"a1f6898b.57ef18"
]
]
},
{
"id": "226440a77d1f6bf2",
"type": "comment",
"z": "ce1fc82ec605926d",
"g": "31f0029ded74155d",
"name": "Reboot NRX800",
"info": "",
"x": 140,
"y": 280,
"wires": []
},
{
"id": "79096672e2f7e12e",
"type": "exec",
"z": "ce1fc82ec605926d",
"g": "79cbc348476a8bcb",
"command": "sudo shutdown #",
"addpay": false,
"append": "",
"useSpawn": "",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "Shutdown NRX800",
"x": 390,
"y": 520,
"wires": [
[],
[],
[]
]
},
{
"id": "0530c582ac67d522",
"type": "inject",
"z": "ce1fc82ec605926d",
"g": "79cbc348476a8bcb",
"name": "Send shutdown",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 520,
"wires": [
[
"79096672e2f7e12e"
]
]
},
{
"id": "9a576d987182bfc2",
"type": "comment",
"z": "ce1fc82ec605926d",
"g": "79cbc348476a8bcb",
"name": "Shutdown NRX800",
"info": "",
"x": 150,
"y": 460,
"wires": []
}
]```