mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 19:07:47 +00:00
ucentral-event: add unit boot-up event
This commit is contained in:
@@ -3,5 +3,6 @@
|
|||||||
"health","health.dns", "health.dhcp", "health.radius", "health.memory",
|
"health","health.dns", "health.dhcp", "health.radius", "health.memory",
|
||||||
"client", "client.join", "client.leave", "client.key-mismatch",
|
"client", "client.join", "client.leave", "client.key-mismatch",
|
||||||
"wifi", "wifi.start", "wifi.stop",
|
"wifi", "wifi.start", "wifi.stop",
|
||||||
"wired", "wired.carrier-up", "wired.carrier-down"
|
"wired", "wired.carrier-up", "wired.carrier-down",
|
||||||
|
"unit", "unit.boot-up"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ let ratelimit = false;
|
|||||||
let config;
|
let config;
|
||||||
let wan_ports;
|
let wan_ports;
|
||||||
let carrier = {};
|
let carrier = {};
|
||||||
|
let boot_file = "/tmp/booted";
|
||||||
|
|
||||||
function config_load() {
|
function config_load() {
|
||||||
uci.load('event');
|
uci.load('event');
|
||||||
@@ -287,6 +288,15 @@ function rtnl_cb(msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_reboot() {
|
||||||
|
if (fs.access(boot_file, "f"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
let file = fs.open(boot_file, "w");
|
||||||
|
if (file)
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
let ubus_methods = {
|
let ubus_methods = {
|
||||||
event: {
|
event: {
|
||||||
call: function(req) {
|
call: function(req) {
|
||||||
@@ -331,5 +341,8 @@ ubus.publish("event", ubus_methods);
|
|||||||
nl80211.listener(nl_cb, [ nl80211.const.NL80211_CMD_DEL_STATION ]);
|
nl80211.listener(nl_cb, [ nl80211.const.NL80211_CMD_DEL_STATION ]);
|
||||||
rtnl.listener(rtnl_cb, null, [ rtnl.const.RTNLGRP_LINK ]);
|
rtnl.listener(rtnl_cb, null, [ rtnl.const.RTNLGRP_LINK ]);
|
||||||
|
|
||||||
|
if (is_reboot())
|
||||||
|
event('unit', 'boot-up', { cause:"" });
|
||||||
|
|
||||||
uloop.run();
|
uloop.run();
|
||||||
uloop.done();
|
uloop.done();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
"types": [ "ssh", "health", "wifi" ]
|
"types": [ "ssh", "health", "wifi" ]
|
||||||
},
|
},
|
||||||
"realtime": {
|
"realtime": {
|
||||||
"types": [ "client.join", "client.leave", "client.key-mismatch", "wired" ]
|
"types": [ "client.join", "client.leave", "client.key-mismatch", "wired", "unit.boot-up" ]
|
||||||
},
|
},
|
||||||
"health": {
|
"health": {
|
||||||
"interval": 120
|
"interval": 120
|
||||||
|
|||||||
Reference in New Issue
Block a user