Skip to content

Commit

Permalink
Deploy script for Windows now use PowerShell
Browse files Browse the repository at this point in the history
Automatic icinga reload after successfull Configuration files generation
Deploying new script C:\Program Files\NSClient++\refresh.ps1 
Main page switched to English language
  • Loading branch information
Vitexus committed Aug 17, 2016
1 parent 65a4510 commit 86495b0
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 135 deletions.
5 changes: 3 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
icinga-editor (1.1.2-24) UNRELEASED; urgency=medium
icinga-editor (1.1.2-25) UNRELEASED; urgency=medium

[ dvorak ]
* Initial release. (Closes: #XXXXXX)
Expand Down Expand Up @@ -118,5 +118,6 @@ icinga-editor (1.1.2-24) UNRELEASED; urgency=medium
* Fixed Scripts Edit/Upload Switching strings to English
* Fixed Scripts Edit/Upload Switching strings to English
* Fixed Scripts Edit/Upload Switching strings to English
* Support for ShutDown & Up scripts to start/stop icinga

-- vitex <vitex@developer.kancl.brevnov.czf> Fri, 12 Aug 2016 19:27:30 +0200
-- vitex <vitex@developer.kancl.brevnov.czf> Tue, 16 Aug 2016 19:03:04 +0200
2 changes: 1 addition & 1 deletion debian/conf/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vitexsoftware/icinga-editor",
"description": "Editor of Icinga Configuration files (debianized)",
"version": "1.1.2.24",
"version": "1.1.2.25",
"license": "GPL-2.0",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion debian/install
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ bin/iecfgimporter.php usr/bin
bin/toicmdfile.sh usr/bin

locale/cs_CZ/LC_MESSAGES/*.mo usr/share/locale/cs_CZ/LC_MESSAGES
locale/en_US/LC_MESSAGES/*.mo usr/share/locale/cs_CZ/LC_MESSAGES
locale/en_US/LC_MESSAGES/*.mo usr/share/locale/en_US/LC_MESSAGES
2 changes: 1 addition & 1 deletion debian/revison
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24
25
34 changes: 17 additions & 17 deletions src/apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace Icinga\Editor;

/**
* Icinga Editor - generování konfigurace
* Icinga Editor - Configuration Generating
*
* @package IcingaEditor
* @subpackage WebUI
* @author Vitex <vitex@hippy.cz>
* @copyright 2012 Vitex@hippy.cz (G)
* @copyright 2012-2016 Vitex@hippy.cz (G)
*/
require_once 'includes/IEInit.php';

Expand Down Expand Up @@ -56,9 +55,9 @@
if (($line === false) && ($line_num == 1)) {
$errorLine = $oPage->container->addItem(new \Ease\Html\Div('<span class="label label-important">'._('Chyba:').'</span>',
['class' => 'alert alert-danger']));
$oUser->addStatusMessage(_('Kontrola konfigurace nevrátila výsledek.'),
$oUser->addStatusMessage(_('Configuration control empty result'),
'error');
$errorLine->addItem(_('Zkontroluj prosím zdlali nechybí potřebný fragment v /etc/sudoers:'));
$errorLine->addItem(_('Please check if /etc/sudoers contains:'));
$errorLine->addItem(new \Ease\Html\Div('User_Alias APACHE = www-data'));
$errorLine->addItem(new \Ease\Html\Div('Cmnd_Alias ICINGA = /usr/sbin/icinga, /etc/init.d/icinga'));
$errorLine->addItem(new \Ease\Html\Div('APACHE ALL = (ALL) NOPASSWD: ICINGA'));
Expand All @@ -67,18 +66,18 @@

if (strstr($line, 'Error:')) {
$line = str_replace('Error:', '', $line);
$errorLine = $oPage->container->addItem(new \Ease\Html\Div('<span class="label label-important">'._('Chyba:').'</span>',
$errorLine = $oPage->container->addItem(new \Ease\Html\Div('<span class="label label-important">'._('Error:').'</span>',
['class' => 'alert alert-danger']));

$keywords = preg_split("/['(.*)']+/", $line);
switch (trim($keywords[0])) {
case 'Service notification period':
$errorLine->addItem(' <a href="timeperiods.php">'._('Notifikační perioda').'</a> služeb ');
$errorLine->addItem(' <a href="timeperiods.php">'._('Notification period').'</a> of services ');
$errorLine->addItem(new \Ease\Html\ATag('timeperiod.php?timeperiod_name='.$keywords[1],
$keywords[1]));
break;
case 'Host notification period':
$errorLine->addItem(' <a href="timeperiods.php">'._('Notifikační perioda').'</a> hostů');
$errorLine->addItem(' <a href="timeperiods.php">'._('Notification period').'</a> of hosts');
$errorLine->addItem(new \Ease\Html\ATag('timeperiod.php?timeperiod_name='.$keywords[1],
$keywords[1]));
break;
Expand All @@ -91,7 +90,7 @@
if (isset($keywords[2])) {
switch (trim($keywords[2])) {
case 'specified for contact':
$errorLine->addItem(' specifikovaná pro kontakt ');
$errorLine->addItem(' specified for contact ');
$contact = new Engine\Contact($keywords[3]);
$errorLine->addItem(new \Ease\Html\ATag('contact.php?contact_id='.$contact->getMyKey(),
$keywords[3]));
Expand All @@ -104,11 +103,10 @@
if (isset($keywords[4])) {
switch (trim($keywords[4])) {
case 'is not defined anywhere!':
$errorLine->addItem(' není nikde definován/a ');
$errorLine->addItem(''._('is not defined anywhere'));
break;
}
}
//$OPage->addItem('<pre>' . EaseBrick::printPreBasic($keywords) . '</pre>');
}

if (strstr($line, 'Error in configuration file')) {
Expand Down Expand Up @@ -145,30 +143,32 @@
if (strstr($line, 'Total Warnings')) {
list($msg, $WarningCount) = explode(':', $line);
if (intval(trim($WarningCount))) {
$oUser->addStatusMessage(sprintf(_('celkem %s varování'),
$oUser->addStatusMessage(sprintf(_('total %s warnings'),
$WarningCount), 'warning');
} else {
$oUser->addStatusMessage(_('test proběhl bez varování'),
$oUser->addStatusMessage(_('test successfully done without warnings'),
'success');
}
}
if (strstr($line, 'Total Errors')) {
list($msg, $errorCount) = explode(':', $line);
if (intval(trim($errorCount))) {
$oUser->addStatusMessage(sprintf(_('celkem %s chyb'),
$oUser->addStatusMessage(sprintf(_('total %s errors'),
$errorCount), 'warning');
} else {
$oUser->addStatusMessage(_('test proběhl bez chyb'), 'success');
$oUser->addStatusMessage(_('test successfully done without errors'),
'success');
}
}
}
fclose($testing);

if (!intval($errorCount) && !is_null($WarningCount)) {
if (Engine\Configurator::reloadIcinga()) {
$oPage->container->addItem(_('Všechny vaše konfigurační soubory byly přegenerovány'));
$oPage->container->addItem(_('All your configuration files was regenerated'));

$oPage->container->addItem(new \Ease\TWB\LinkButton('main.php',
_('Hotovo').' '.\Ease\TWB\Part::GlyphIcon('ok-sign'), 'success'));
_('Done').' '.\Ease\TWB\Part::GlyphIcon('ok-sign'), 'success'));
\Ease\Shared::user()->setSettingValue('unsaved', false);
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/cfgconfirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
* Icinga Editor - potvrzení nasazení konfigurace
*
* @package IcingaEditor
* @subpackage WebUI
* @author Vitex <vitex@hippy.cz>
* @copyright 2012 Vitex@hippy.cz (G)
* @copyright 2012-2016 Vitex@hippy.cz (G)
*/
require_once 'includes/IEInit.php';

$host_id = $oPage->getRequestValue('host_id', 'int');
$hash = $oPage->getRequestValue('hash');

if ($host_id && $hash) {
$host = new Engine\Host($host_id);
$host = new Engine\Host($host_id);
$oUser = new \Icinga\Editor\User($host->getOwnerID());
$host->setDataValue('config_hash', $hash);
if ($host->saveToSQL()) {
echo sprintf(_('Konfigurace %s potvrzena'), $host->getName());
echo sprintf(_('Configuration Confirmed'), $host->getName());
$extCmd = new ExternalCommand();
$extCmd->addCommand('ADD_HOST_COMMENT;'.$host->getName().';1;'.$oUser->getUserLogin().';'._('Sensor Configuration Confirmed'));
$extCmd->executeAll();
} else {
echo sprintf(_('Chyba potvrzení konfigurace'), $host->getName());
echo sprintf(_('Configuration Confirmation Error'), $host->getName());
}
echo "\n<br>"._('Sledovat cestu k hostu').":\n";
echo "\n<br>"._('Watch route to host').":\n";

if (isset($_SERVER['REQUEST_SCHEME'])) {
$scheme = $_SERVER['REQUEST_SCHEME'];
Expand Down
11 changes: 9 additions & 2 deletions src/classes/ExternalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ public function addCommand($command)
*/
public function executeAll()
{
$results = [];
foreach ($this->commands as $id => $command) {
if ($this->execute($command) !== false) {
$result = $this->execute($command);
if ($result !== false) {
unset($this->commands[$id]);
$results[$command] = $result;
}
}
return $results;
}

/**
Expand All @@ -52,7 +56,10 @@ public function executeAll()
public function execute($command)
{
$this->addStatusMessage('External command: '.$command);
return system('sudo /usr/bin/toicmdfile.sh "['.time().'] '.$command.'"');
ob_start();
$result = system('sudo /usr/bin/toicmdfile.sh "['.time().'] '.$command.'"');
ob_end_clean();
return $result;
}

/**
Expand Down
Loading

0 comments on commit 86495b0

Please sign in to comment.