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

View File

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

View File

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