Skip to content

Commit

Permalink
Add zfs zed notification
Browse files Browse the repository at this point in the history
  • Loading branch information
luxflow committed Dec 31, 2016
1 parent a94a1bd commit 3e34016
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ openmediavault-zfs (3.0.6) stable; urgency=low
* Fix snapshot creating
* Add snapshot rollback
* Add force pool import option
* Add zfs zed notification

-- OpenMediaVault Plugin Developers <[email protected]> Sat, 19 Nov 2016 23:15:41 +0900

Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Depends: openmediavault (>= 3.0.34),
openmediavault-omvextrasorg (>= 3.4),
zfs-dkms,
zfsutils-linux | zfsutils,
zfs-zed
${misc:Depends}
Description: OpenMediaVault plugin for ZFS
ZFS is a combined file system and logical volume manager designed
Expand Down
5 changes: 5 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ case "$1" in
omv_config_add_element "${SERVICE_XPATH}" "autoShareNestedProperty" ""
fi

object="<uuid>$(omv_uuid)</uuid>"
object="${object}<id>zfs</id>"
object="${object}<enable>0</enable>"
omv_config_add_node_data "/config/system/notification/notifications" "notification" "${object}"

#Remove deprectaed stuff to ensure clean installation
rm -f /etc/insserv/overrides/zfs-mount

Expand Down
70 changes: 70 additions & 0 deletions usr/share/openmediavault/engined/module/zfs.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3
* @author Volker Theile <[email protected]>
* @author OpenMediaVault Plugin Developers <[email protected]>
* @copyright Copyright (c) 2009-2015 Volker Theile
* @copyright Copyright (c) 2015-2016 OpenMediaVault Plugin Developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class OMVZFS extends \OMV\Engine\Module\ServiceAbstract
implements \OMV\Engine\Notify\IListener, \OMV\Engine\Module\INotification {
/**
* Get the module name.
*/
public function getName() {
return "ZFS-ZED";
}
/**
* Defines the modules that if present should start before the service
* provided by this module.
* @return An array of modules.
*/
public function shouldStart() { return [ "email" ]; }
/**
* Generate the configuration.
* @throw E_EXEC_FAILED
*/
public function applyConfig() {
$cmd = new \OMV\System\Process("omv-mkconf", "zed");
$cmd->setRedirect2to1();
$cmd->execute();
}
/**
* Get the notification configuration.
*/
public function getNotificationConfig() {
return [
[
"id" => "zfs",
"type" => getText("Storage"),
"title" => gettext("ZFS ZED")
]
];
}
/**
* Bind listeners.
*/
function bindListeners(\OMV\Engine\Notify\Dispatcher $dispatcher) {
$dispatcher->addListener(
OMV_NOTIFY_MODIFY,
"org.openmediavault.conf.system.notification.email",
[ $this, "setDirty" ]);
$dispatcher->addListener(
OMV_NOTIFY_MODIFY,
"org.openmediavault.conf.system.notification.notification",
[ $this, "setDirty" ]);
}
}
35 changes: 35 additions & 0 deletions usr/share/openmediavault/mkconf/zed
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <[email protected]>
# @author OpenMediaVault Plugin Developers <[email protected]>
# @copyright Copyright (c) 2009-2013 Volker Theile
# @copyright Copyright (c) 2013-2015 OpenMediaVault Plugin Developers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

set -e

. /etc/default/openmediavault
. /usr/share/openmediavault/scripts/helper-functions

OMV_ZED_CONFIG=${OMV_ZED_CONFIG:-"/etc/zfs/zed.d/zed.rc"}
OMV_ZED_NOTIFY_INTERVAL_SECS=3600

xmlstarlet sel -t -m "//system/email" \
-i "enable[. = '1'] and //system/notification/notifications/notification[id='zfs'][enable = '1']" \
-v "concat('ZED_EMAIL_ADDR=',primaryemail)" -n \
-o "ZED_NOTIFY_INTERVAL_SECS=${OMV_ZED_NOTIFY_INTERVAL_SECS}" \
-b \
${OMV_CONFIG_FILE} | xmlstarlet unesc > ${OMV_ZED_CONFIG}

0 comments on commit 3e34016

Please sign in to comment.