mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +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",
|
||||
"client", "client.join", "client.leave", "client.key-mismatch",
|
||||
"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 wan_ports;
|
||||
let carrier = {};
|
||||
let boot_file = "/tmp/booted";
|
||||
|
||||
function config_load() {
|
||||
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 = {
|
||||
event: {
|
||||
call: function(req) {
|
||||
@@ -331,5 +341,8 @@ ubus.publish("event", ubus_methods);
|
||||
nl80211.listener(nl_cb, [ nl80211.const.NL80211_CMD_DEL_STATION ]);
|
||||
rtnl.listener(rtnl_cb, null, [ rtnl.const.RTNLGRP_LINK ]);
|
||||
|
||||
if (is_reboot())
|
||||
event('unit', 'boot-up', { cause:"" });
|
||||
|
||||
uloop.run();
|
||||
uloop.done();
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
"types": [ "ssh", "health", "wifi" ]
|
||||
},
|
||||
"realtime": {
|
||||
"types": [ "client.join", "client.leave", "client.key-mismatch", "wired" ]
|
||||
"types": [ "client.join", "client.leave", "client.key-mismatch", "wired", "unit.boot-up" ]
|
||||
},
|
||||
"health": {
|
||||
"interval": 120
|
||||
|
||||
Reference in New Issue
Block a user