Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Native director connectivity
Browse files Browse the repository at this point in the history
Replaced the old director communication with the new native
connectivity.
  • Loading branch information
fbergkemper committed Feb 27, 2015
1 parent eda344c commit 1dd6d59
Show file tree
Hide file tree
Showing 30 changed files with 1,050 additions and 495 deletions.
2 changes: 0 additions & 2 deletions Makefile.am
@@ -1,12 +1,10 @@
install: install-am
mkdir -p $(DESTDIR)$(pkgdatadir)
mkdir -p $(DESTDIR)/@HTTPD_CONF@
mkdir -p $(DESTDIR)@sysconfdir@/sudoers.d/

cp -pr init_autoloader.php config/ data/ module/ public/ vendor/ $(DESTDIR)$(pkgdatadir)
cp -p config/autoload/local.php.dist $(DESTDIR)/etc/bareos-webui.conf.php
ln -s /etc/bareos-webui.conf.php $(DESTDIR)/$(pkgdatadir)/config/autoload/local.php
$(INSTALL) -m 0640 install/apache/bareos-webui.conf $(DESTDIR)@HTTPD_CONF@/
$(INSTALL) -m 0440 install/sudoers.d/bareos-webui-bconsole $(DESTDIR)@sysconfdir@/sudoers.d/

# #$(INSTALL_SCRIPT) install/bareos-webui-config $(DESTDIR)@sbindir@
2 changes: 0 additions & 2 deletions Makefile.in
Expand Up @@ -522,13 +522,11 @@ uninstall-am:
install: install-am
mkdir -p $(DESTDIR)$(pkgdatadir)
mkdir -p $(DESTDIR)/@HTTPD_CONF@
mkdir -p $(DESTDIR)@sysconfdir@/sudoers.d/

cp -pr init_autoloader.php config/ data/ module/ public/ vendor/ $(DESTDIR)$(pkgdatadir)
cp -p config/autoload/local.php.dist $(DESTDIR)/etc/bareos-webui.conf.php
ln -s /etc/bareos-webui.conf.php $(DESTDIR)/$(pkgdatadir)/config/autoload/local.php
$(INSTALL) -m 0640 install/apache/bareos-webui.conf $(DESTDIR)@HTTPD_CONF@/
$(INSTALL) -m 0440 install/sudoers.d/bareos-webui-bconsole $(DESTDIR)@sysconfdir@/sudoers.d/

# #$(INSTALL_SCRIPT) install/bareos-webui-config $(DESTDIR)@sbindir@

Expand Down
38 changes: 23 additions & 15 deletions config/autoload/local.php.dist
Expand Up @@ -3,7 +3,7 @@
/**
*
* bareos-webui - Bareos Web-Frontend
*
*
* @link https://github.com/bareos/bareos-webui for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
Expand Down Expand Up @@ -32,16 +32,14 @@
* .dist extension at the end and populate values as needed.
*
* @NOTE: This file is ignored from Git by default with the .gitignore included.
* This is a good practice, as it prevents sensitive credentials from accidentally
* This is a good practice, as it prevents sensitive credentials from accidentally
* being committed into version control.
*/

return array(

'db' => array(

// Set your database driver here: Pdo_Mysql, Pdo_Pgsql, Mysqli or Pgsql
'driver' => 'Pdo_Pgsql',
'driver' => 'Pdo_Pgsql',
// Set your database here
'dbname' => 'bareos',
// Set your hostname here
Expand All @@ -50,15 +48,25 @@ return array(
'username' => 'bareos_webui',
// Set your password here
'password' => '',

),
'bconsole' => array(
// Set full path to bconsole command
'exec_path' => '/usr/sbin/bconsole',
// Use sudo to execute bconsole command: true or false
'sudo' => 'true',
// Set full path to bconsole configuration file
'config_path' => '/etc/bareos/bconsole.conf',
),

'director' => array(
// Director hostname or ip address
'host' => '127.0.0.1',
// Director port
'port' => '9101',
// Director password
'password' => '',
// Director named console
'console_name' => null,
// TLS parameter
'tls_verify_peer' => false,
'server_can_do_tls' => false,
'server_requires_tls' => false,
'client_can_do_tls' => true,
'client_requires_tls' => false,
'ca_file' => null,
'cert_file' => null,
'cert_file_passphrase' => null,
'allowed_cns' => null,
),
);
1 change: 0 additions & 1 deletion debian/control
Expand Up @@ -14,6 +14,5 @@ Vcs-Browser: https://github.com/bareos/bareos-webui.git
Package: bareos-webui
Architecture: all
Depends: apache2 | httpd, libapache2-mod-php5 | php5 | php5-cgi, php5-cli, php5-gd, php5-json, php5-mysql, php5-pgsql, php5-sqlite | php5-sqlite3, zendframework (>= 2.2.0) | zend-framework (>= 2.2.0) | php5-zendframework2 (>= 2.2.0), ${misc:Depends}
Recommends: sudo
Description: Bareos Web User Interface.
Webinterface for the Bareos backup system.
33 changes: 3 additions & 30 deletions doc/install/INSTALL.md
Expand Up @@ -5,7 +5,6 @@ Remember: this project is still in alpha state.
### SYSTEM REQUIREMENTS

* A working Bareos environment, Bareos 12.4 or later, including a Bareos catalog database (currently only PostgreSQL is tested)
* A working Bareos Console (bconsole) on this system
* An Apache 2.x Webserver with mod-rewrite, mod-php5 and mod-setenvif enabled
* PHP 5.3.3 or later
* PHP PDO Extension
Expand All @@ -20,7 +19,7 @@ Remember: this project is still in alpha state.
### How bareos-webui accesses Bareos

Bareos-webui connects to Bareos by
* bconsole
* native connection to the director
* database connection (read-only) to the Bareos catalog

## Installation
Expand Down Expand Up @@ -50,7 +49,6 @@ However, not all distributions offer these packages.

* add the [Bareos contrib](http://download.bareos.org/bareos/contrib/) repository that is matching your Linux distribution
* install the package bareos-webui
* verify, that your local bconsole can connect to your Bareos environment, e.g. run ```bconsole```
* configure your database connection to your Bareos catalog in ```/etc/bareos-webui.conf.php``` (this is the link target of ```/usr/share/bareos-webui/config/autoload/local.php```). See [configure database connection](#configure-the-database-connection)
* reload your Apache webserver
* test bareos-webui using the url: [http://localhost/bareos-webui](http://localhost/bareos-webui)
Expand All @@ -67,7 +65,7 @@ git clone https://github.com/bareos/bareos-webui.git
cd bareos-webui
```

* Download composer.phar
* Download composer.phar

```
wget https://getcomposer.org/composer.phar
Expand Down Expand Up @@ -99,30 +97,6 @@ This will change and no longer be necessary in future, but it is the way to go f
SetEnv "ZF2_PATH" "/usr/share/php5"
```

### Configuration to be able to run bconsole commands within the web-frontend

In order to be able to execute bconsole commands within the web-frontend, it is necessary there is a sudo rule for the user under
which your webserver is running. So, run visudo and add the following lines, e.g:

```
# bareos web-frontend entry
wwwrun ALL=NOPASSWD: /usr/sbin/bconsole
```

or something like ...

```
# bareos web-frontend entry
apache ALL=NOPASSWD: /usr/sbin/bconsole
```

You can use the default sudo configuration from bareos-webui, that should work on most Linux distributions:
```
cd /etc/sudoers.d/
wget https://raw.github.com/bareos/bareos-webui/master/install/sudoers.d/bareos-webui-bconsole
chmod u=r,g=r,o= bareos-webui-bconsole
```

### Configure the database connection

Bareos-webui needs only a read-only connection to the Bareos catalog database, so there are multiple possibilities to configure bareos-webui:
Expand Down Expand Up @@ -159,8 +133,7 @@ Reload the PostgreSQL configuration:
pg_ctl reload
```


#####
#####

Adapt the bareos-webui configuration file to match your database settings.

Expand Down
4 changes: 0 additions & 4 deletions install/sudoers.d/bareos-webui-bconsole

This file was deleted.

28 changes: 15 additions & 13 deletions module/Client/src/Client/Controller/ClientController.php
Expand Up @@ -4,7 +4,7 @@

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Bareos\BConsole\BConsoleConnector;
use Bareos\BSock\BareosBSock;

class ClientController extends AbstractActionController
{
Expand All @@ -15,8 +15,8 @@ class ClientController extends AbstractActionController
public function indexAction()
{
$order_by = $this->params()->fromRoute('order_by') ? $this->params()->fromRoute('order_by') : 'ClientId';
$order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : 'DESC';
$limit = $this->params()->fromRoute('limit') ? $this->params()->fromRoute('limit') : '25';
$order = $this->params()->fromRoute('order') ? $this->params()->fromRoute('order') : 'DESC';
$limit = $this->params()->fromRoute('limit') ? $this->params()->fromRoute('limit') : '25';
$paginator = $this->getClientTable()->fetchAll(true, $order_by, $order);
$paginator->setCurrentPageNumber( (int) $this->params()->fromQuery('page', 1) );
$paginator->setItemCountPerPage($limit);
Expand All @@ -31,46 +31,48 @@ public function indexAction()
);
}

public function detailsAction()
public function detailsAction()
{

$id = (int) $this->params()->fromRoute('id', 0);
if(!$id) {
return $this->redirect()->toRoute('client');
}

$result = $this->getClientTable()->getClient($id);
$cmd = 'status client="' . $result->name . '"';
$config = $this->getServiceLocator()->get('Config');
$bcon = new BConsoleConnector($config['bconsole']);
$bsock = new BareosBSock();
$bsock->set_config($config['director']);
$bsock->init();

return new ViewModel(
array(
'client' => $this->getClientTable()->getClient($id),
'job' => $this->getJobTable()->getLastSuccessfulClientJob($id),
'bconsoleOutput' => $bcon->getBConsoleOutput($cmd),
'bconsoleOutput' => $bsock->send_command($cmd),
)
);

}

public function getClientTable()
public function getClientTable()
{
if(!$this->clientTable) {
$sm = $this->getServiceLocator();
$this->clientTable = $sm->get('Client\Model\ClientTable');
}
return $this->clientTable;
}
public function getJobTable()

public function getJobTable()
{
if(!$this->jobTable) {
$sm = $this->getServiceLocator();
$this->jobTable = $sm->get('Job\Model\JobTable');
}
return $this->jobTable;
}

}

31 changes: 11 additions & 20 deletions module/Client/view/client/client/details.phtml
Expand Up @@ -12,11 +12,11 @@ $this->headTitle($title);

<div class="col-md-7">
<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title">General Information</h3>
</div>

<div class="panel-body">

<table class="table table-striped table-bordered" style="font-size: 9pt;">
Expand Down Expand Up @@ -53,33 +53,24 @@ $this->headTitle($title);
<div class="col-md-5">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">todo placeholder (client stats)</h3>
</div>
<div class="panel-body">
</div>
</div>
-->

<!-- bconsoleOutput start -->
<div class="row">

<div class="col-md-12">

<pre style="font-size: 8pt;">
<code>
<?php
foreach($this->bconsoleOutput as $row) {
echo $row ."<br />";
}
?>
</code>
</pre>

</div>

<div class="col-md-12">
<pre style="font-size: 8pt;">
<code>
<?php echo $this->bconsoleOutput; ?>
</code>
</pre>
</div>
</div>
<!-- bconsoleOutput end -->

0 comments on commit 1dd6d59

Please sign in to comment.