]> git.datanom.net - omvzfs.git/blobdiff - src/Utils.php
Added method to add ZFS pool to OMV mountpoint backend.
[omvzfs.git] / src / Utils.php
index 13c89ed5ddbbc096139acd84220b5354b796bf63..251157a6abf564c8e13a977abffa4251c0003c2d 100644 (file)
@@ -27,6 +27,40 @@ class OMVModuleZFSUtil {
                return null;
        }
 
+       /**
+        * Add any missing ZFS pool to the OMV backend
+        *
+        */
+       public static function addMissingOMVMntEnt() {
+               global $xmlConfig;
+               $msg = "";
+               $cmd = "zpool list -H -o name";
+               OMVModuleZFSUtil::exec($cmd, $out, $res);
+               foreach($out as $name) {
+                       $pooluuid = OMVModuleZFSUtil::getUUIDbyName($name);
+                       $xpath = "//system/fstab/mntent[fsname=" . $pooluuid . "]";
+                       $object = $xmlConfig->get($xpath);
+                       if(is_null($object)) {
+                               $uuid = OMVUtil::uuid();
+                               $ds = new OMVModuleZFSDataset($name);
+                               $dir = $ds->getMountPoint();
+                               $object = array(
+                                       "uuid" => $uuid,
+                                       "fsname" => $pooluuid,
+                                       "dir" => $dir,
+                                       "type" => "zfs",
+                                       "opts" => "rw,relatime,xattr",
+                                       "freq" => "0",
+                                       "passno" => "2"
+                               );
+                               $xmlConfig->set("//system/fstab",array("mntent" => $object));
+                               $dispatcher = &OMVNotifyDispatcher::getInstance();
+                               $dispatcher->notify(OMV_NOTIFY_CREATE,"org.openmediavault.system.fstab.mntent", $object);
+                       }
+               }
+               return null;
+       }
+
        /**
         * Get an array with all ZFS objects
         *
This page took 0.028679 seconds and 5 git commands to generate.