diff --git a/debian/changelog b/debian/changelog index 924dc18..52145c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Sat, 19 Nov 2016 23:15:41 +0900 diff --git a/debian/control b/debian/control index 0222a28..f80c516 100644 --- a/debian/control +++ b/debian/control @@ -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 diff --git a/debian/postinst b/debian/postinst index a917d6c..4e6ad21 100644 --- a/debian/postinst +++ b/debian/postinst @@ -20,6 +20,11 @@ case "$1" in omv_config_add_element "${SERVICE_XPATH}" "autoShareNestedProperty" "" fi + object="$(omv_uuid)" + object="${object}zfs" + object="${object}0" + 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 diff --git a/usr/share/openmediavault/engined/module/zfs.inc b/usr/share/openmediavault/engined/module/zfs.inc new file mode 100644 index 0000000..0be2b86 --- /dev/null +++ b/usr/share/openmediavault/engined/module/zfs.inc @@ -0,0 +1,70 @@ + + * @author OpenMediaVault Plugin Developers + * @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 . + */ + 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" ]); + } +} \ No newline at end of file diff --git a/usr/share/openmediavault/mkconf/zed b/usr/share/openmediavault/mkconf/zed new file mode 100755 index 0000000..ae730bc --- /dev/null +++ b/usr/share/openmediavault/mkconf/zed @@ -0,0 +1,35 @@ +#!/bin/bash +# +# @license http://www.gnu.org/licenses/gpl.html GPL Version 3 +# @author Volker Theile +# @author OpenMediaVault Plugin Developers +# @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 . + +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}