openmediavault-flashmemory development issues

  • I'm developing the flashmemory plugin (actually openmediavault-flashmemory-folder2ram branch of openmediavault-flashmemory).


    But I'm a bit puzzled and cannot get past the following issue.


    I have a secondary package called folder2ram, the openmediavault-flashmemory fork is supposed to run a "folder2ram -generate && folder2ram -mountall" when the plugin is enabled, and "folder2ram -clean" when the plugin is disabled.


    Checking the "enable" checkbox, clicking on Save and then confirming gives the correct result:
    the config is generated and folder2ram is started.


    unchecking the "enable" checkbox, clicking on Save and then confirming does not have any effect. It should trigger a "folder2ram -clean" command.


    I tried to copy around some code but I'm not sure what its function is, can someone tell me what I'm missing here?


    The /usr/share/openmediavault/engined/module/flashmemory.inc

    is pasted below, the full source of the branch is here https://github.com/OpenMediaVa…lt-flashmemory-folder2ram


    • Offizieller Beitrag

    The following line is bad and php will stop because of the error. You are using sprintf and giving it a parameter without a location to substitute.
    $cmd = sprintf("folder2ram -clean 2>&1", $this->getName());


    Change it to:
    $cmd = "folder2ram -clean 2>&1";

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.6 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Look at the Green check mark on this link.
    http://stackoverflow.com/quest…s-mean-in-php-html-or-xml


    Your code could be written like this too if your service name and plugin name were the same, which it is not from your post above:


    $cmd = sprintf("%s -clean 2>&1", $this->getName());



    Here is an example from one of my plugins:

    Code
    {
            $cmd = sprintf(
                "export LANG=C; cp /dev/null /var/cache/%s/%s.cache 2>&1",
                $this->getPluginName(),
                $this->getPluginName()
            );


    You have a placeholder (or token) %s that is replaced by a variable "$this->getPluginName()". The this plugin thing is just a generic term we've been using so we could use older plugins as templates for newer ones. Aaron did this a while back. You try to declare all the variables at the top and then lower in the code you use the variables to plugin stuff.

  • Ty both, for quick correction and for more verbose explanation about what is what. :)


    Now that I know what that means, I'm going to follow the same standard too. So it is consistent with other plugins at least.


    Might be a good idea to append your explanations about the current issue and any other plugin guideline you follow into here DIY Plugin Development
    As I did learn more or less everything I know about OMV plugins (and php for that matter) by reading it and looking at other plugins. :whistling:


    EDIT: the forum spits formatting code all over my post... fixing...


    EDIT2: setting this as solved.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!