Pinned [GUIDE] DIY Plugin Development Part 1-3

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Hi Guys,

      first thanks for this guide! Im on the way to create my first omv-plugin :)

      I have some improvements for the guide:

      - there is a bug in part 3 . The class name is "OMVModuleVirtualBox". I think it should be "OMVModuleExample" instead.

      - in part 1 (step 2) you should mention, how to clean the gui cache ( in /var/cache/openmediavault/). It takes me some time on debugging to find out, why my example node is not showing as expected. I curent use

      Source Code

      1. rm /var/cache/openmediavault/*
      is there an official omv command for this?


      Thanks
      ocean
    • oceanBT wrote:

      Hi Guys,

      first thanks for this guide! Im on the way to create my first omv-plugin :)

      I have some improvements for the guide:

      - there is a bug in part 3 . The class name is "OMVModuleVirtualBox". I think it should be "OMVModuleExample" instead.

      - in part 1 (step 2) you should mention, how to clean the gui cache ( in /var/cache/openmediavault/). It takes me some time on debugging to find out, why my example node is not showing as expected. I curent use

      Source Code

      1. rm /var/cache/openmediavault/*
      is there an official omv command for this?


      Thanks
      ocean

      Guide updated. Good luck! :)

      tekkb wrote:

      omv_purge_internal_cache

      You need to reload or restart nginx to get the browser to refresh. This is needed for any change in javascript, like a new node.

      invoke-rc.d nginx restart
      invoke-rc.d nginx reload

      No, this isn't true.

      You just need to purge the cache for new or deleted Javascript files. The only other thing you need to to is reload the page in the web browser.
    • This is used with the helper functions: . /usr/share/openmediavault/scripts/helper-functions
      omv_purge_internal_cache

      In the helper functions you find:

      Source Code

      1. # void omv_purge_internal_cache ()
      2. # Purge the internal cache, e.g. used to speedup WebGUI loading.
      3. omv_purge_internal_cache() {
      4. rm -f ${OMV_CACHE_DIR}/cache.*.json
      5. }


      In /etc/default/openmediavault is:
      OMV_CACHE_DIR="/var/cache/openmediavault"

      So I guess official command line would be:
      rm -f /var/cache/openmediavault/cache.*.json
    • @HK, yeah I was thinking it was coming from those lines but I see now it is from here.

      /var/www/openmediavault/js/omv/module/admin/system/plugin/Plugins.js

      Source Code

      1. close: function() {
      2. Ext.MessageBox.show({
      3. title: _("Information"),
      4. msg: _("The page will reload now to let the changes take effect."),
      5. modal: true,
      6. icon: Ext.MessageBox.INFO,
      7. buttons: Ext.MessageBox.OK,
      8. fn: function() {
      9. // Reload the page.
      10. OMV.confirmPageUnload = false;
      11. document.location.reload();
      12. }
      13. });
      14. }
      Display All

    • When I change a .js file, I just do a page refresh and if I change a .inc file I do a engined restart and a page refresh, never had a problem doing it that way.

      What I am watching/watched on my Popcorn Hour media player
      omv 2.1.1 stoneburner | 64 bit | omvextrasorg 1.29
      MySQL (Percona) | Newznab | Sonarr | CP | HP | NZBget | YAMJ | CUPS
    • Make a node and see if it shows without purging the cache. It won't show with just a refresh anymore.

      Just tested... created node and refreshed browser like 5 times. Nothing. Then ran this command:
      rm -f /var/cache/openmediavault/cache.*.json
      Refresh browser once and the node shows.

      Changing and creating are 2 different things.

      The post was edited 2 times, last by tekkb ().

    • [GUIDE] DIY Plugin Development Part 1-3

      When I Dev, add, modify, del files

      I do :
      $ service openmediavault-engined restart
      $ rm - f /var/cache/openmediavault/cache. *

      I logout
      Refresh my browser

      I can now login and see the results :D
      Open Media Vault 2.2.6 (Stone burner) in Prod
      Open Media Vault 3.0.32 (Erasmus) in Test

      openmedivault Docker Container
      https://github.com/prbond/openmedivault-dockerfile

      Dev :
      openmediavault-fail2ban 1.1.5 for OMV2.X
      openmediavault-fail2ban 1.3.0 for OMV3.X
      https://github.com/prbond/openmediavault-fail2ban
      https://github.com/OpenMediaVault-Plugin-Developers/openmediavault-fail2ban
    • Thanks for the apt-clean.
      But when you develop and create / modify .js and .inc is more quickly. Install and desinstall plugin (in fact a deb packet) is long and boring
      Open Media Vault 2.2.6 (Stone burner) in Prod
      Open Media Vault 3.0.32 (Erasmus) in Test

      openmedivault Docker Container
      https://github.com/prbond/openmedivault-dockerfile

      Dev :
      openmediavault-fail2ban 1.1.5 for OMV2.X
      openmediavault-fail2ban 1.3.0 for OMV3.X
      https://github.com/prbond/openmediavault-fail2ban
      https://github.com/OpenMediaVault-Plugin-Developers/openmediavault-fail2ban
    • I use the developer plugin. It kind of obscures some of the github details, keeps permissions right, helps with proper changelog format, and helps testing. I am pretty much only use Sublime Text now but I use notepad++ on Windows and nano on the command line.
      omv 4.0.11 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • Nano is my friend (on Linux) and Notepad ++ on Windows.
      Open Media Vault 2.2.6 (Stone burner) in Prod
      Open Media Vault 3.0.32 (Erasmus) in Test

      openmedivault Docker Container
      https://github.com/prbond/openmedivault-dockerfile

      Dev :
      openmediavault-fail2ban 1.1.5 for OMV2.X
      openmediavault-fail2ban 1.3.0 for OMV3.X
      https://github.com/prbond/openmediavault-fail2ban
      https://github.com/OpenMediaVault-Plugin-Developers/openmediavault-fail2ban
    • I found moving the files forwards and back to a text editor was too slow. I just edit them in the file manager in webmin. To make the config for OMV I create an init script. I make/test all the files in the location where they reside. Once I have it all working then I start to move it to github. Once in github I'll usually do edits there. Sometimes I just copy the whole edited file from the file manager in webmin and paste it in github, depending on home many changes to the file. Once it is all working decent you need to start creating all the files (control, postinst, postrm, etc..) to make the package.

      Before I build the package I usually create any needed user/group manually. I add any dependencies manually too. Here is an example of a init script to make the OMV config. This will later be done in the package by the postinst file, which is a little different. A file like this needs to be executable. Then you run it and it will create an entry for your service in the /etc/openmediavault/config.xml file. You have to do these things if you want to run/test it prior to packaging it.

      Shell-Script

      1. #!/bin/sh
      2. set -e
      3. . /etc/default/openmediavault
      4. . /usr/share/openmediavault/scripts/helper-functions
      5. ########################################################################
      6. # Update the configuration.
      7. # <config>
      8. # <services>
      9. # <shellinabox>
      10. # <enable>0</enable>
      11. # <linkify>none</linkify>
      12. # <enablebeep>0</enablebeep>
      13. # <enabletermsettings>0</enabletermsettings>
      14. # <fontfamily>Courier New</fontfamily>
      15. # <fontsize>14</fontsize>
      16. # </shellinabox>
      17. # </services>
      18. # </config>
      19. ########################################################################
      20. if ! omv_config_exists "/config/services/shellinabox"; then
      21. echo "Initialize configuration"
      22. object="<enable>0</enable>"
      23. object="${object}<linkify>none</linkify>"
      24. object="${object}<enablebeep>0</enablebeep>"
      25. object="${object}<enabletermsettings>0</enabletermsettings>"
      26. object="${object}<fontfamily>Courier New</fontfamily>"
      27. object="${object}<fontsize>14</fontsize>"
      28. omv_config_add_element "/config/services" "shellinabox" "${object}" true
      29. fi
      Display All


      PS- Edits to .js (javascript files) only need a refresh of the browser. Edits to the mkconf file you can test right away. Most other files you will need to restart engined.

      PPS- I use Github for Windows to move up the folder structure and a lot of files at once to Github.

      The post was edited 3 times, last by tekkb ().

    • No, I create them on the machine I run them on. Testing is done on that machine before there is a package. Then files are downloaded to my windows machine and then put in a folder for Github for Windows. Or copy and pasted directly into Github.

      Aaron does it different. He does not work on Windows machine and has developers plugin to aid him.
    • Doc wrote:

      Is the way plugins are developed/written changed drastically for OMV 3.0?

      Up to OMV 3.0.13, no. After 3.0.13, there have been some significant changes but nothing that increases the complexity in my opinion. 3.0.13 is the latest release though.
      omv 4.0.11 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!