Skip to content

Commit 041f5c5

Browse files
committed
Fixed config files import during debian package install process
1 parent aaa393c commit 041f5c5

13 files changed

Lines changed: 90 additions & 36 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
],
1111
"require": {
1212
"php": ">= 5.5.9",
13+
"php-fileinfo": "*",
1314
"vitexsoftware/ease-framework": "dev-master"
1415
},
1516
"autoload": {

debian/install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ debian/conf/icinga-editor.conf etc/apache2/conf-available
1818
debian/conf/icinga-editor.service etc/avahi/services
1919
debian/conf/icinga-editor etc/sudoers.d
2020
debian/plugins/* usr/lib/nagios/plugins
21-
debian/bin/iecfgimporter.php usr/bin
21+
src/bin/iecfgimporter.php usr/bin
2222

2323
locale/cs_CZ/LC_MESSAGES/*.mo usr/share/locale/cs_CZ/LC_MESSAGES
2424
locale/en_US/LC_MESSAGES/*.mo usr/share/locale/cs_CZ/LC_MESSAGES

debian/links

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
/usr/share/icinga/htdocs/images/logos /usr/share/icinga-editor/logos

debian/postinst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [ ! -f $IECFG ] ; then
6969

7070

7171
#rm -f /etc/icinga-editor/config-db.sh
72-
ln -s /usr/share/icinga/htdocs/images/logos /usr/share/icinga-editor/logos
72+
#(Moved To links file) ln -s /usr/share/icinga/htdocs/images/logos /usr/share/icinga-editor/logos
7373

7474

7575
if [ "$1" = "configure" ]; then
@@ -104,7 +104,15 @@ if [ ! -f $IECFG ] ; then
104104
fi
105105
fi
106106

107-
iecfgimporter.php
107+
# Import configuration Question ?
108+
db_input medium icinga-editor/IMPORT_CONFIG || true
109+
db_go
110+
111+
# Check their answer.
112+
db_get icinga-editor/IMPORT_CONFIG
113+
if [ "$RET" = "true" ]; then
114+
/usr/bin/iecfgimporter
115+
fi
108116
fi
109117

110118
fi

debian/rules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ override_dh_install:
77
dh_install
88
sed -i -e 's/..\//.\//g' debian/icinga-editor/usr/share/icinga-editor/about.php
99
sed -i -e 's/..\/locale/\/usr\/share\/locale/g' debian/icinga-editor/usr/share/icinga-editor/includes/IEInit.php
10-
sed -i -e 's/..\/vendor/\/var\/lib\/icinga-editor/g' debian/icinga-editor/usr/share/icinga-editor/includes/IEInit.php
1110
sed -i -e 's/..\/i18n/\/usr\/share\/locale/g' debian/icinga-editor/usr/share/icinga-editor/includes/IEInit.php
11+
mv debian/icinga-editor/usr/bin/iecfgimporter.php debian/icinga-editor/usr/bin/iecfgimporter
12+

debian/templates

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ Type: string
88
Description: IP address of ICINGA server
99
Or simply press enter to use auto genrated value
1010

11+
Template: icinga-editor/IMPORT_CONFIG
12+
Type: boolean
13+
Default: true
14+
Description: Import icinga config files ?
15+
Choose yes to import all config files in /etc/icinga directory into database.
16+
Imported files remain renamed to *.disabled

debian/templates.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Template: icinga-editor/SEND_MAILS_FROM
2+
Type: string
3+
Description: mail address of icinga admin
4+
Or simply press enter to use auto genrated name
5+
Description-cs: mailová adresa administrátora icingy
6+
7+
Template: icinga-editor/ICINGA_SERVER_IP
8+
Type: string
9+
Description: IP address of ICINGA server
10+
Or simply press enter to use auto genrated value
11+
Description-cs: IP adresa serveru ICINGA
12+
13+
Template: icinga-editor/IMPORT_CONFIG
14+
Type: boolean
15+
Default: true
16+
Description: Import icinga config files ?
17+
Choose yes to import all config files in /etc/icinga directory into
18+
database. Imported files remain renamed to *.disabled
19+
Description-cs: Importovat konfigurační soubory icingy ?
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#!/usr/bin/env php
1+
#!/usr/bin/env php -q
22
<?php
3-
4-
namespace Icinga\Editor;
3+
//namespace Icinga\Editor;
54

65
/**
76
* Import konfigurace ze souboru
@@ -11,21 +10,20 @@
1110
* @author Vitex <vitex@hippy.cz>
1211
* @copyright 2015 Vitex@hippy.cz (G)
1312
*/
14-
chdir('/usr/share/icinga-editor');
15-
16-
require_once 'includes/IEInit.php';
13+
//require_once '/usr/share/icinga-editor/includes/IEInit.php';
14+
require_once '../includes/IEInit.php';
1715

1816
$params = array('public' => true, 'generate' => true);
1917

20-
$importer = new Engine\Importer($params);
18+
$importer = new Icinga\Editor\Engine\Importer($params);
2119
$importer->importCfgFile('/etc/icinga/icinga.cfg');
2220

2321
foreach ($importer->files as $cfgFile) {
2422
if ($cfgFile == '/etc/icinga/icinga.cfg') {
2523
continue;
2624
}
27-
if (unlink($cfgFile)) {
28-
echo $cfgFile . " X\n";
25+
if (rename($cfgFile, $cfgFile.'.disabled')) {
26+
echo $cfgFile." imported\n";
2927
}
3028
}
3129

src/classes/UI/IconSelector.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,28 @@ public function __construct($host)
113113
*/
114114
public static function imageTypeOK($tmpfilename)
115115
{
116-
$finfo = new finfo(FILEINFO_MIME);
117-
$info = $finfo->file($tmpfilename);
118-
if (!$info) {
119-
return false;
120-
}
121-
if (strstr($info, 'gif')) {
122-
return true;
123-
}
124-
if (strstr($info, 'png')) {
125-
return true;
126-
}
127-
if (strstr($info, 'jpeg')) {
128-
return true;
129-
}
130-
if (strstr($info, 'ico')) {
131-
return true;
116+
if (class_exists('\finfo')) {
117+
$finfo = new \finfo(constant('FILEINFO_MIME'));
118+
$info = $finfo->file($tmpfilename);
119+
if (!$info) {
120+
return false;
121+
}
122+
if (strstr($info, 'gif')) {
123+
return true;
124+
}
125+
if (strstr($info, 'png')) {
126+
return true;
127+
}
128+
if (strstr($info, 'jpeg')) {
129+
return true;
130+
}
131+
if (strstr($info, 'ico')) {
132+
return true;
133+
}
134+
} else {
135+
\Ease\Shared::webPage()->addStatusMessage('php-fileinfo ?!?!?',
136+
'error');
132137
}
133-
134138
return false;
135139
}
136140

src/classes/UI/WebPage.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @package VitexSoftware
99
* @author Vitex <vitex@hippy.cz>
10-
* @copyright 2009-2011 Vitex@hippy.cz (G)
10+
* @copyright 2009-2016 Vitex@hippy.cz (G)
1111
*/
1212
class WebPage extends \Ease\TWB\WebPage
1313
{
@@ -103,4 +103,5 @@ function onlyForLogged($loginPage = 'login.php')
103103
{
104104
return parent::onlyForLogged($loginPage.'?backurl='.urlencode($_SERVER['REQUEST_URI']));
105105
}
106-
}
106+
107+
}

0 commit comments

Comments
 (0)