-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2c2a222
Showing
16 changed files
with
552 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
openmediavault-symlinks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
openmediavault-symlinks (3.0) stable; urgency=low | ||
|
||
* Initial release after separation from downloader plugin | ||
|
||
-- OpenMediaVault Plugin Developers <plugins@omv-extras.org> Mon, 31 Aug 2015 07:00:14 -0500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Source: openmediavault-symlinks | ||
Section: net | ||
XB-Plugin-Section: filesystems | ||
Priority: optional | ||
Maintainer: OpenMediaVault Plugin Developers <plugins@omv-extras.org> | ||
Build-Depends: debhelper (>= 9.0.0 ) | ||
Standards-Version: 3.9.6 | ||
Homepage: http://omv-extras.org/ | ||
|
||
Package: openmediavault-symlinks | ||
Architecture: all | ||
Depends: openmediavault (>= 3.0.19), | ||
openmediavault-omvextrasorg (>= 3.2), | ||
${misc:Depends} | ||
Description: OpenMediaVault symlinks plugin | ||
Allow creation of symlinks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Format: http://dep.debian.net/deps/dep5 | ||
Upstream-Contact: OpenMediaVault Plugin Developers <plugins@omv-extras.org> | ||
Copyright: 2013-2016 OpenMediaVault Plugin Developers <plugins@omv-extras.org> | ||
License: GPL-3 | ||
|
||
Files: /var/www/openmediavault/images/link.png | ||
/var/www/openmediavault/images/link.svg | ||
Copyright: IcoMoon <http://www.icomoon.io> | ||
IcoMoon <http://www.icomoon.io> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
usr/share/openmediavault/* usr/share/openmediavault | ||
var/www/openmediavault/* var/www/openmediavault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dir-or-file-in-var-www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
# | ||
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3 | ||
# @author Volker Theile <volker.theile@openmediavault.org> | ||
# @author OpenMediaVault Plugin Developers <plugins@omv-extras.org> | ||
# @copyright Copyright (c) 2009-2013 Volker Theile | ||
# @copyright Copyright (c) 2013-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/>. | ||
|
||
set -e | ||
|
||
. /etc/default/openmediavault | ||
. /usr/share/openmediavault/scripts/helper-functions | ||
|
||
case "$1" in | ||
configure) | ||
SERVICE_XPATH_NAME="symlinks" | ||
SERVICE_XPATH="/config/services/${SERVICE_XPATH_NAME}" | ||
|
||
if ! omv_config_exists "${SERVICE_XPATH}"; then | ||
echo "Initialize configuration" | ||
omv_config_add_element "/config/services" "${SERVICE_XPATH_NAME}" | ||
omv_config_add_element "${SERVICE_XPATH}" "symlinks" "" | ||
fi | ||
|
||
dpkg-trigger update-fixperms | ||
dpkg-trigger update-locale | ||
;; | ||
|
||
abort-upgrade|abort-remove|abort-deconfigure) | ||
;; | ||
|
||
*) | ||
echo "postinst called with unknown argument '$1'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
# | ||
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3 | ||
# @author Volker Theile <volker.theile@openmediavault.org> | ||
# @author OpenMediaVault Plugin Developers <plugins@omv-extras.org> | ||
# @copyright Copyright (c) 2009-2013 Volker Theile | ||
# @copyright Copyright (c) 2013-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/>. | ||
|
||
set -e | ||
|
||
. /etc/default/openmediavault | ||
. /usr/share/openmediavault/scripts/helper-functions | ||
|
||
case "$1" in | ||
remove) | ||
;; | ||
|
||
purge) | ||
# Remove the configuration data | ||
omv_config_delete "/config/services/symlinks" | ||
;; | ||
|
||
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) | ||
;; | ||
|
||
*) | ||
echo "postrm called with unknown argument '$1'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/make -f | ||
|
||
%: | ||
dh $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0 (native) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
activate restart-engined |
28 changes: 28 additions & 0 deletions
28
usr/share/openmediavault/datamodels/conf.service.symlinks.symlink.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"type": "config", | ||
"id": "conf.service.symlinks.symlink", | ||
"title": "Symlinks symlink", | ||
"queryinfo": { | ||
"xpath": "//services/symlinks/symlinks/symlink", | ||
"iterable": true, | ||
"idproperty": "uuid" | ||
}, | ||
"properties": { | ||
"uuid": { | ||
"type": "string", | ||
"format": "uuidv4" | ||
}, | ||
"enable: { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"source": { | ||
"type": "string", | ||
"default": "" | ||
}, | ||
"destination": { | ||
"type": "string", | ||
"default": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[{ | ||
"type": "rpc", | ||
"id": "rpc.symlinks.setsymlink", | ||
"params": { | ||
"type": "object", | ||
"properties": { | ||
"uuid": { | ||
"type": "string", | ||
"format": "uuidv4", | ||
"required": true | ||
}, | ||
"enable: { | ||
"type": "boolean", | ||
"required": true | ||
}, | ||
"source": { | ||
"type": "string", | ||
"required": true | ||
}, | ||
"destination": { | ||
"type": "string", | ||
"required": true | ||
} | ||
} | ||
} | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
/** | ||
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3 | ||
* @author Volker Theile <volker.theile@openmediavault.org> | ||
* @copyright Copyright (c) 2009-2013 Volker Theile | ||
* @copyright Copyright (c) 2013-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/>. | ||
*/ | ||
require_once("openmediavault/object.inc"); | ||
require_once("openmediavault/config.inc"); | ||
require_once("openmediavault/error.inc"); | ||
require_once("openmediavault/util.inc"); | ||
require_once("openmediavault/rpcservice.inc"); | ||
require_once("openmediavault/notify.inc"); | ||
|
||
class OMVRpcServiceSymlinks extends OMVRpcServiceAbstract | ||
{ | ||
public function getName() | ||
{ | ||
return "Symlinks"; | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->registerMethod("getSymlinkList"); | ||
$this->registerMethod("getSymlink"); | ||
$this->registerMethod("setSymlink"); | ||
$this->registerMethod("deleteSymlink"); | ||
} | ||
|
||
public function getSymlinkList($params, $context) | ||
{ | ||
// Validate the RPC caller context. | ||
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]); | ||
// Validate the parameters of the RPC service method. | ||
$this->validateMethodParams($params, "rpc.common.getlist"); | ||
// Get the configuration object. | ||
$db = \OMV\Config\Database::getInstance(); | ||
$objects = $db->get("conf.service.symlinks.symlink"); | ||
// Filter the result. | ||
return $this->applyFilter($objects, $params['start'], $params['limit'], | ||
$params['sortfield'], $params['sortdir']); | ||
} | ||
|
||
public function getSymlink($params, $context) | ||
{ | ||
// Validate the RPC caller context. | ||
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]); | ||
// Validate the parameters of the RPC service method. | ||
$this->validateMethodParams($params, "rpc.common.objectuuid"); | ||
// Get the configuration object. | ||
$db = \OMV\Config\Database::getInstance(); | ||
return $db->getAssoc("conf.service.symlinks.symlink", $params['uuid']); | ||
} | ||
|
||
public function setSymlink($params, $context) | ||
{ | ||
// Validate the RPC caller context. | ||
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]); | ||
// Validate the parameters of the RPC service method. | ||
$this->validateMethodParams($params, "rpc.symlinks.setsymlink"); | ||
// Prepare the configuration object. | ||
$object = new \OMV\Config\ConfigObject("conf.service.symlinks.symlink"); | ||
$object->setAssoc($params); | ||
// Set the configuration object. | ||
$isNew = $object->isNew(); | ||
$db = \OMV\Config\Database::getInstance(); | ||
// remove old symbolic link if modifying existing symlink | ||
if ($isNew == OMV_NOTIFY_MODIFY) { | ||
$oldObject = $db->getAssoc("conf.service.symlinks.symlink", $params['uuid']); | ||
if (is_link($oldObject->get('destination'))) { | ||
unlink($oldObject->get('destination')); | ||
} | ||
} | ||
$db->set($object); | ||
|
||
if ($object->('enable') === true) { | ||
// Create symbolic link | ||
$success = false; | ||
$success = symlink($object->get('source'), $object->('destination')); | ||
if (false === $success) { | ||
throw new \OMV\Exception( | ||
sprintf( | ||
"Failed to create symbolic link at %s", | ||
$object->get('destination') | ||
) | ||
); | ||
} | ||
} | ||
// Notify configuration changes. | ||
$dispatcher = \OMV\Engine\Notify\Dispatcher::getInstance(); | ||
$dispatcher->notify( | ||
$isNew ? OMV_NOTIFY_CREATE : OMV_NOTIFY_MODIFY, | ||
"org.openmediavault.services.symlinks.symlink", | ||
$object->getAssoc() | ||
); | ||
// Return the configuration object. | ||
return $object->getAssoc(); | ||
} | ||
|
||
public function deleteSymlink($params, $context) | ||
{ | ||
// Validate the RPC caller context. | ||
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]); | ||
// Validate the parameters of the RPC service method. | ||
$this->validateMethodParams($params, "rpc.common.objectuuid"); | ||
// remove old symbolic link | ||
if (is_link($params['destination'])) { | ||
unlink($params['destination']); | ||
} | ||
// Delete the configuration object. | ||
return $this->deleteConfigObjectByUuid( | ||
"conf.service.symlinks.symlink", | ||
$params['uuid'], | ||
"org.openmediavault.services.symlinks.symlink" | ||
); | ||
} | ||
} |
Oops, something went wrong.