Openmediavault - how does it execute system commands using web interface?

    • OMV 4.x
    • Openmediavault - how does it execute system commands using web interface?

      Hello,

      I'd like to know how does the web framework of Openmediavault work in terms of executing system commands, like rebooting the server, editing configuration files using it's web interface.

      I'm not interested in building my own plugins, but but my own web interface for my own use at home.

      I'd appreciate it if somebody could break it down for me.

      Debian 9
      OMV 4.1.17-1

      Thanks in advance.
    • Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit
    • New

      The webserver PHP code forwards the requests to a daemon process that executes the RPC's and returns the result to the webserver process.
      Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit
    • New

      leszek_t wrote:

      So it's not possible for me to reuse it in my own script ?
      Seems so.

      Use Google to find what you are looking for:
      stackoverflow.com/questions/85…ute-root-commands-via-php
      medium.com/@daggerdwivedi/allo…ipts-as-root-b62c4491e25f
      serverfault.com/questions/7721…ipt-with-root-permissions


      But keep in mind that this is a security problem.
      Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit
    • New

      I was also looking at this this week as I just started building a plugin for the web interface, I already had a terminal tool built and now I wanted to integrate the same functionality but from the web interface, and if possible to run commands from scripts that are already built.

      So just in short you will have some javascript files that creates you menu entry, and the configuration page where you can have multiple tabs with tables or inputs and so on.

      The execution part is controlled by a php file that communicates with the javascript files and the server.

      here is an example of some code that executes a shell script

      Source Code

      1. public function setSettings($params, $context)
      2. {
      3. // Validate the RPC caller context.
      4. $this->validateMethodContext($context, ['role' => OMV_ROLE_ADMINISTRATOR]);
      5. // Validate the parameters of the RPC service method.
      6. $this->validateMethodParams($params, 'rpc.theme.settheme');
      7. // Get the existing configuration object.
      8. $db = \OMV\Config\Database::getInstance();
      9. $object = $db->get('conf.service.theme');
      10. $object->setAssoc($params);
      11. $db->set($object);
      12. // run script to apply theme
      13. $cmd = new \OMV\System\Process("omv-mkconf", "apply_theme", escapeshellarg($params['theme_select']));
      14. $cmd->setRedirect2to1();
      15. $cmd->execute();
      16. // Return the configuration object.
      17. return $object->getAssoc();
      18. }
      Display All
      Build ui in javascript, get data and set data in database with php, run shell script from php using omv helper classes in this case is process
      Check out my OMV THEME CHANGER
      I do't do support on private, except for theme changer related issues.