Creating custom templates

120 views
Skip to first unread message

Sai Subramanian

unread,
Jul 28, 2022, 2:52:06 AM7/28/22
to OpenWISP
Hi team,

I have been working on OpenWisp for my personal research related work and I am happy with your product.  

I have been facing a challenge the with your software, where I am not able to create custom built templates.

For example, I want to create a template which can run few commands on the OpenWRT device when the onboard. Can you please guide me on how I can build custom templates to achieve the above requirement?

Regards,
Sai

Federico Capoano

unread,
Jul 29, 2022, 6:23:29 AM7/29/22
to open...@googlegroups.com
Hi Sai,

If by onboarding you mean the event when the device is first recognized by the system and registers itself, then we have a specific hook for it:

If you are compiling from master or using the builds from downloads.openwisp.io, you can also use the new hotplug events:

That will allow you to add any logic you need.

For example, you could deploy scripts via OpenWISP templates, hook them to the post config reload event, which is triggered after the new config has been applied, and execute the scripts. In case you need the scripts to run only once you just need to write a control file somewhere in the permanent flash storage (eg: /etc/openwisp) and check whether that file exists before doing anything, if it exists, you simply exit, if it doesn't you let the script proceed.

It may sound obvious to some but I need to reiterate that I highly recommend to try this manually first and only once you are 100% sure that the scripts you prepared work, only then put those scripts in OpenWISP as templates and test the full flow.
Some people try to do it all at once and end up bombarding us with questions which most of the time do not have to do anything with OpenWISP but with their lack of understanding of OpenWrt.

Best regards
Federico Capoano
OpenWISP OÜ
Harjumaa, Tallinn, Sepapaja tn 6, 15551
VAT: EE101989729


--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openwisp/0f0eda32-c886-477e-8658-cedffa0dd24fn%40googlegroups.com.

Sai Subramanian

unread,
Jul 29, 2022, 7:39:39 AM7/29/22
to open...@googlegroups.com
Hi Fed,

Thanks a lot for your quick reply.
Sure, I will check whether the script is working before I start with OpenWisp.

I am trying to achieve ZTP (Zero Touch Provisioning) with OpenWISP where I want the below commands to be executed on the OpenWRT device once it is on-boarded to OpenWISP:
  • uci del firewall.zone2.network
  • uci add_list firewall.zone2.network='wan'
  • uci add_list firewall.zone2.network='wg13'
As per my knowledge I want to push a bash file containing these commands and execute it :
  • I am able to push the file to the OpenWRT device and automatically execute it by using templates.
  • I am able to push the file but the problem is that I am not able to execute the file automatically.
  • Can you please share the steps in which I can use OpenWISP to automatically execute the bash file after it has been pushed to the device?
Please let me know if this is possible, if so, requesting you to please share the steps which I can follow to fulfil the above requirement.

Regards,
Sai

You received this message because you are subscribed to a topic in the Google Groups "OpenWISP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openwisp/3A_s51rJdcE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openwisp+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openwisp/CAAGgX6JoEVQo%3D8Pxw2TqGQhGnT8cgA2sMhojv6Q3TjD3w0xf1A%40mail.gmail.com.

Federico Capoano

unread,
Jul 29, 2022, 7:52:20 AM7/29/22
to open...@googlegroups.com
Dear Sai,

I already pointed out to you how to do what you need, now is up to you to read the docs, try out the examples and implement it.
If you have more specific questions about steps that are not clear to you please do not hesitate to ask.


Best regards
Federico Capoano
OpenWISP OÜ
Harjumaa, Tallinn, Sepapaja tn 6, 15551
VAT: EE101989729

Sai Subramanian

unread,
Jul 29, 2022, 8:06:59 AM7/29/22
to open...@googlegroups.com
Got it.
Do the hooks and hotplugs need to be configured manually?  or Can it be automatically pushed through templates and executed?
Regards,
Sai

Federico Capoano

unread,
Jul 29, 2022, 8:24:20 AM7/29/22
to open...@googlegroups.com
The hooks have a default location, so if you place files there the files will be executed automatically without the need of doing anything else.
Please read the docs and examples carefully, I also recommend trying out the examples, including the hotplug example.


Best regards
Federico Capoano
OpenWISP OÜ
Harjumaa, Tallinn, Sepapaja tn 6, 15551
VAT: EE101989729

Sai Subramanian

unread,
Sep 15, 2022, 8:36:14 AM9/15/22
to open...@googlegroups.com
Hi Fed, 

Thanks a lot for your help. 
The solution you gave worked perfectly. 

Regards, 


Reply all
Reply to author
Forward
0 new messages