#!/usr/bin/lua --! Copyright (C) 2019 Gioacchino Mazzurco local fs = require("nixio.fs") local ubus = require("ubus") local uloop = require("uloop") local hooksDir = "/etc/hotplug.d/initd/" local function notifyHooks(evData, evName) for hook in fs.dir(hooksDir) do os.execute( string.format( 'ACTION="%s" SERVICE="%s" %s/%s', evName, evData.service, hooksDir, hook ) ) end end local conn = ubus.connect() assert(conn, arg[0].." Failed to connect to ubus") conn:subscribe("service", { notify = notifyHooks }) uloop.run()