Run script when "Save & Apply" clicked

I have created a simple js page in luci but when i need to be able to do is run a bash script when save & apply is clicked in the gui. Any ideas how a i go about this?

  1. make sure bash is installed on the router.
  2. create an rpcd script which will run the bash script you want.
  3. create an on_save function for the map and from it call the rpcd script.

Most of the javascript-converted luci applications use rpcd scripts, so it wouldn't be too hard to find an example at github.


Might be offtopic from your main question, but

Do you really specifically need bash? It is non-standard in OpenWrt...
Or are you talking about a generic shell script (without bash extra features)?

OpenWrt has by default ash shell (from busybox) with provides the normal shell script support.

1 Like