Create a new plugin from scratch by example pt. 2 (LLDP)

Ok, what have we replaces and renamed so far?

plugins\net-mgmt\lldpd\src\opnsense\service\templates\OPNsense\Lldpd here are the files +TARGETS which tells the systeme where to put our templates and how they are named. File lldpd controls the auto start/stop of the daemon and lldpd.conf is our config. Just remove anything between the first if and the last endif and replace collectd with lldpd.

plugins\net-mgmt\lldpd\src\opnsense\service\conf\actions.d rename the actions file to lldpd and all content. This file controls the daemon and registers the calls in configd where all commands are controlled.

plugins\net-mgmt\lldpd\src\opnsense\scripts\OPNsense\Lldpd setup.sh is needed for installations with /var in ramdisk since all these files are only generated while installation. A reboot would remove all these so they have to be recreated at bootup. You can look at the pkg* files in opnsense/ports to see where files in /var get’s created. You can also have a look at other setup.sh scripts from plugins to get an idea what all have to be done (like in postfix plugin).

plugins\net-mgmt\lldpd\src\opnsense\mvc\app\views\OPNsense\Lldpd general.volt is our content for the UI. Just search&replace, for such a simple plugin this is fine.

plugins\net-mgmt\lldpd\src\opnsense\mvc\app\models\OPNsense\Lldpd In General.php just replace Collectd with Lldpd, in General.xml is our model, we’ll do this later on. In the folder ACL is the file defining the URLs. In the folder Menu the file controls the place in the menu and the icon it should get. You can use the icons from here: http://fontawesome.io/icons/

plugins\net-mgmt\lldpd\src\opnsense\mvc\app\controllers\OPNsense\Lldpd GeneralController.php Here you define your page, just search&replace. Files in the folder API define the API and the action, like setting the values to the config and define how to start and stop. Also just search&replace. Last files are in forms and they define our fields, how they should look like (text, dropdown etc).

If you want some more explanations look at the plugin enhancement guide. Next part covers the model and forms.