ucentral-event: add unit boot-up event

This commit is contained in:
Satya-sc
2023-02-20 17:56:09 +05:30
committed by John Crispin
parent 9274c3a719
commit 3db254c306
3 changed files with 16 additions and 2 deletions

View File

@@ -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"
]

View File

@@ -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();

View File

@@ -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