OpenWrt Forum Archive

Topic: How does "save & apply" take changes effect on Luci

The content of this topic has been archived on 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all:
   When I develop one feature for Luci, i want that  clicking "save & apply" on Luci to run my script on.
   Like "system" or "network" configuration , "save & apply" may trigger /etc/init.d/system restart or /etc/init.d/network reload, i guess. But really i don't know how does Luci implement this triggering. i try to search "init.d" in Luci code, it seems that Luci doesn't call init.d 's scirpt to update config.
   Could anyone give some idea? Thank you.

Hi ,
I have 2 solutions for you.
a.First:
You can use "Save & Apply Hooks" to trigger your own script.
    Link :  https://github.com/elationfoundation/lu … del-cbi.md
   
For example ,I modified the "system.lua"
   (In my case ,it located :  src/modules/admin-cpxwrt/luasrc/model/cbi/admin_system/system.lua)

    +function m.on_after_commit(map) 
    +          luci.sys.call(" <my script ^_^>  restart ")
    +end

b.Second:
you can modify the  "/etc/config/ucitrack"
For example :
      + config system
      +       list affects network
It means after "save & apply"  it will restart both /etc/init.d/system and /etc/init.d/network

Hope it helps smile

The discussion might have continued from here.