openwisp / openwisp-config

OpenWRT configuration agent for OpenWISP Controller
https://openwisp.io/docs/dev/openwrt-config-agent/
GNU General Public License v3.0
372 stars 56 forks source link

Add possibility to run a command after configuration is applied #26

Closed gabri94 closed 7 years ago

gabri94 commented 7 years ago

In order to use OpenWISP with LibreMesh, we need a way to call the command "lime-config" after the configuration has been fetched, but before the networking get reloaded.

I propose to add a parameter to specify a generic command in the config file.

nemesifier commented 7 years ago

Question: does lime-config work with a single configuration file or multiple files?

Take a look at this script that is used internally by openwisp-config: openwisp-reload-config.

It's a modified version of OpenWRT's reload-config (procd), which also explicitly calls /etc/init.d/<service> reload if necessary.

That's a way of doing it which wouldn't need to do new development.

An alternative would be to add some kind of customisable hook to call when the configuration is applied, which would also be interesting.

Could you find the source code of lime-config and link it here? I want to take a look at it but can't find it quickly.

G10h4ck commented 7 years ago

lime-config read a couple of config files and write almost everything else

nemesifier commented 7 years ago

@G10h4ck thanks for the info, could you add the link to the source code of lime-config please?

G10h4ck commented 7 years ago

https://github.com/libremesh/lime-packages/blob/develop/packages/lime-system/files/usr/bin/lime-config

The modules are loaded from here

https://github.com/libremesh/lime-packages/tree/develop/packages/lime-system/files/usr/lib/lua/lime

nemesifier commented 7 years ago

I guess the best thing is to add a generic hook to call lime-config as suggested by @gabri94. Stay tuned.

nemesifier commented 7 years ago

Thx @gabri94 and @G10h4ck, see 033d69a. I will issue a new release later.

nemesifier commented 7 years ago

Released openwisp-config 0.4.5.