add backup api; closes #865 (#895)

* add backup api; closes #865
* make backup api devel
* sysutils/api-backup: rename
* sysutils/api-backup: fix prev
* fix ACL
This commit is contained in:
Fabian Franz BSc
2018-10-07 15:57:59 +02:00
committed by GitHub
parent 133abddd94
commit b44d8ba706
4 changed files with 63 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
PLUGIN_NAME= api-backup
PLUGIN_VERSION= 0.0.1
PLUGIN_COMMENT= Provide the functionality to download the config.xml
PLUGIN_MAINTAINER= franz.fabian.94@gmail.com
PLUGIN_DEVEL= YES
.include "../../Mk/plugins.mk"
+1
View File
@@ -0,0 +1 @@
Provide the functionality to download the config.xml
@@ -0,0 +1,47 @@
<?php
/*
* Copyright (C) 2018 Fabian Franz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\Backup\Api;
use OPNsense\Base\ApiControllerBase;
class BackupController extends ApiControllerBase
{
const CONFIG_XML = '/conf/config.xml';
public function downloadAction()
{
$this->response->setStatusCode(200, "OK");
$this->response->setContentType('application/xml', 'UTF-8');
$this->response->setHeader("Content-Disposition", "attachment; filename=\"config.xml\"");
$data = file_get_contents(self::CONFIG_XML);
$this->response->setContent($data);
}
public function afterExecuteRoute($dispatcher)
{
$this->response->send();
}
}
@@ -0,0 +1,8 @@
<acl>
<page-Backup>
<name>Backup API</name>
<patterns>
<pattern>api/backup/*</pattern>
</patterns>
</page-Backup>
</acl>