OPNsense Forum

English Forums => Development and Code Review => Topic started by: darsen on July 14, 2021, 08:19:34 am

Title: Module does not appear in Menu
Post by: darsen on July 14, 2021, 08:19:34 am
Hi everyone,

I developed a OPNSense module following this guide: https://docs.opnsense.org/development/examples/helloworld.html

I have also created Menu.xml to specify where exactly I want my module to appear in OPNSense Menu. After that, I packaged the module into a "txz".

After installing the module on a new OPNSense, by running "pkg install my-module.txz", I don't see it appearing in the Menu.

If I restart OPNSense, then I see it.

Do I need to restart something as part of POST_INSTALL ?

Thanks a lot,

darsen
Title: Re: Module does not appear in Menu
Post by: franco on July 14, 2021, 08:30:15 am
If you have the latest plugin code it should work out of the box after install (and has been for a long time).

You can always run "opnsense-patch" to clear the menu cache. It's just a file on the disk:

https://github.com/opnsense/update/commit/ed95d5e3bb5


Cheers,
Franco
Title: Re: Module does not appear in Menu
Post by: darsen on July 14, 2021, 08:36:49 am
If you have the latest plugin code it should work out of the box after install (and has been for a long time).

You can always run "opnsense-patch" to clear the menu cache. It's just a file on the disk:

https://github.com/opnsense/update/commit/ed95d5e3bb5


Cheers,
Franco

It works with opnsense-patch ! Thanks a lot!

Can I include opnsense-patch inside "+POST_INSTALL" ?

Thanks a lot

darsen
Title: Re: Module does not appear in Menu
Post by: franco on July 14, 2021, 08:43:08 am
As I said the appropriate hook is provided by https://github.com/opnsense/plugins/blob/master/Templates/configure unless you clobber +POST_INSTALL yourself. If that is the case you can always alter your approach and use +POST_INSTALL.pre or +POST_INSTALL.post file overrides.


Cheers,
Franco
Title: Re: Module does not appear in Menu
Post by: darsen on July 14, 2021, 08:51:26 am
As I said the appropriate hook is provided by https://github.com/opnsense/plugins/blob/master/Templates/configure unless you clobber +POST_INSTALL yourself. If that is the case you can always alter your approach and use +POST_INSTALL.pre or +POST_INSTALL.post file overrides.


Cheers,
Franco

Aha now I get it, so if I remove the +POST_INSTALL everything should work.
I created the +POST_INSTALL because the documentation said that it needs to be created:

Quote
Next add a +POST_INSTALL file in the plugin directory, to reload the configd process after installation. This is needed for the new “test” command to register.

Maybe we can update the documentation to make it more clear.

Thanks a lot Franco!
Title: Re: Module does not appear in Menu
Post by: franco on July 14, 2021, 09:00:18 am
Uh, ok, I will update the docs. Thanks for the pointer!


Cheers,
Franco
Title: Re: Module does not appear in Menu
Post by: franco on July 14, 2021, 09:02:50 am
Actually, can you point me to the documentation that seems outdated? I can't find it in the docs repo...


Cheers,
Franco
Title: Re: Module does not appear in Menu
Post by: darsen on July 14, 2021, 09:04:18 am
This one: https://docs.opnsense.org/development/examples/helloworld.html

Best Regards

Aleks
Title: Re: Module does not appear in Menu
Post by: franco on July 14, 2021, 09:04:55 am
Hi Aleks,

Ah thanks. I was grepping for "POST_INSTALL" but the source file reads "POST\_INSTALL"... d'oh :)


Cheers,
Franco
Title: Re: Module does not appear in Menu
Post by: franco on July 14, 2021, 09:07:19 am
PS: done https://github.com/opnsense/docs/commit/0a5f23c70b80 :)