Commit d2906425 authored by Bastien Pujos's avatar Bastien Pujos

Multiple fixes

parent 1292217a
CREATE TABLE IF NOT EXISTS configs (
`name` varchar(255) NOT NULL,
`value` text NOT NULL,
PRIMARY KEY (`name`)
);
ALTER TABLE users ADD user_language CHAR(2) DEFAULT '0';
ALTER TABLE auth_settings ADD COLUMN ldap_group_filter varchar(255);
ALTER TABLE auth_settings CHANGE ldap_filter ldap_user_filter varchar(255);
ALTER TABLE groups ADD COLUMN group_type tinyint(1);
ALTER TABLE groups ADD COLUMN group_dn varchar(255);
CREATE TABLE `ldap_groups_extended` (
`dn` varchar(255) NOT NULL,
`group_name` varchar(255) DEFAULT NULL,
`checked` smallint(6) NOT NULL,
PRIMARY KEY (`dn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- MySQL dump 10.11
--
-- Host: localhost Database: nagiosbp
-- ------------------------------------------------------
-- Server version 5.0.95
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `bp`
--
DROP TABLE IF EXISTS `bp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bp` (
`name` varchar(255) NOT NULL,
`description` varchar(255) default NULL,
`priority` varchar(5) default NULL,
`type` varchar(3) NOT NULL,
`command` varchar(255) default NULL,
`url` varchar(255) default NULL,
`min_value` varchar(5) default NULL,
`is_define` tinyint(1) default '0',
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `bp_links`
--
DROP TABLE IF EXISTS `bp_links`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bp_links` (
`id` mediumint(9) NOT NULL auto_increment,
`bp_name` varchar(255) NOT NULL,
`bp_link` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `bp_services`
--
DROP TABLE IF EXISTS `bp_services`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bp_services` (
`id` mediumint(9) NOT NULL auto_increment,
`bp_name` varchar(255) NOT NULL,
`host` varchar(255) NOT NULL,
`service` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
GRANT ALL ON nagiosbp.* TO eonweb@localhost IDENTIFIED BY 'root66';
USE notifier;
ALTER TABLE rules ADD COLUMN tracking INT(11) NULL DEFAULT '0';
\ No newline at end of file
-- MySQL dump 10.13 Distrib 5.1.73, for redhat-linux-gnu (x86_64) -- MySQL dump 10.11
-- --
-- Host: localhost Database: notifier -------------------------- DB nagiosbp ------------------------------
-- ------------------------------------------------------ CREATE DATABASE IF NOT EXISTS nagiosbp;
-- Server version 5.1.73 USE nagiosbp;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
...@@ -15,6 +15,105 @@ ...@@ -15,6 +15,105 @@
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `bp`
--
DROP TABLE IF EXISTS `bp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bp` (
`name` varchar(255) NOT NULL,
`description` varchar(255) default NULL,
`priority` varchar(5) default NULL,
`type` varchar(3) NOT NULL,
`command` varchar(255) default NULL,
`url` varchar(255) default NULL,
`min_value` varchar(5) default NULL,
`is_define` tinyint(1) default '0',
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `bp_links`
--
DROP TABLE IF EXISTS `bp_links`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bp_links` (
`id` mediumint(9) NOT NULL auto_increment,
`bp_name` varchar(255) NOT NULL,
`bp_link` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `bp_services`
--
DROP TABLE IF EXISTS `bp_services`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bp_services` (
`id` mediumint(9) NOT NULL auto_increment,
`bp_name` varchar(255) NOT NULL,
`host` varchar(255) NOT NULL,
`service` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
GRANT ALL ON nagiosbp.* TO eonweb@localhost IDENTIFIED BY 'root66';
-------------------------- DB eonweb ------------------------------
USE eonweb;
ALTER TABLE auth_settings ADD COLUMN ldap_group_filter varchar(255);
ALTER TABLE auth_settings CHANGE ldap_filter ldap_user_filter varchar(255);
ALTER TABLE groups ADD COLUMN group_type tinyint(1);
ALTER TABLE groups ADD COLUMN group_dn varchar(255);
--
-- Table structure for table `ldap_groups_extended`
--
CREATE TABLE `ldap_groups_extended` (
`dn` varchar(255) NOT NULL,
`group_name` varchar(255) DEFAULT NULL,
`checked` smallint(6) NOT NULL,
PRIMARY KEY (`dn`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
ALTER TABLE users ADD user_language CHAR(2) DEFAULT '0';
CREATE TABLE IF NOT EXISTS configs (
`name` varchar(255) NOT NULL,
`value` text NOT NULL,
PRIMARY KEY (`name`)
);
-------------------------- DB notifier ------------------------------
CREATE DATABASE IF NOT EXISTS notifier;
USE notifier;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- --
-- Table structure for table `configs` -- Table structure for table `configs`
-- --
...@@ -128,7 +227,6 @@ CREATE TABLE `rules` ( ...@@ -128,7 +227,6 @@ CREATE TABLE `rules` (
`notificationnumber` varchar(255) NOT NULL DEFAULT '*', `notificationnumber` varchar(255) NOT NULL DEFAULT '*',
`timeperiod_id` bigint unsigned NOT NULL, `timeperiod_id` bigint unsigned NOT NULL,
`sort_key` int(32) NOT NULL default 0, `sort_key` int(32) NOT NULL default 0,
`tracking` INT(11) NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `timeperiod_id` (`timeperiod_id`), KEY `timeperiod_id` (`timeperiod_id`),
CONSTRAINT `rules_ibfk_1` FOREIGN KEY (`timeperiod_id`) REFERENCES `timeperiods` (`id`) CONSTRAINT `rules_ibfk_1` FOREIGN KEY (`timeperiod_id`) REFERENCES `timeperiods` (`id`)
...@@ -182,3 +280,4 @@ UNLOCK TABLES; ...@@ -182,3 +280,4 @@ UNLOCK TABLES;
-- Dump completed on 2017-03-13 15:55:32 -- Dump completed on 2017-03-13 15:55:32
GRANT ALL ON notifier.* TO eonweb@localhost IDENTIFIED BY 'root66'; GRANT ALL ON notifier.* TO eonweb@localhost IDENTIFIED BY 'root66';
...@@ -1317,28 +1317,35 @@ function checkUpdateDB(){ ...@@ -1317,28 +1317,35 @@ function checkUpdateDB(){
global $database_eonweb; global $database_eonweb;
global $database_username; global $database_username;
global $database_password; global $database_password;
global $path_eonweb;
$dir=$path_eonweb."/appliance/updates/";
$version_sql = sqlrequest($database_eonweb,"SELECT count(value) as value FROM configs WHERE name='version'"); $version_sql = sqlrequest($database_eonweb,"SELECT count(value) as value FROM configs WHERE name='version'");
if(mysqli_result($version_sql,0,"value") == 0){ if(mysqli_result($version_sql,0,"value") == 0){
$version_sql = sqlrequest($database_eonweb,"INSERT INTO configs (name, value) VALUES('version', '".$version."')"); $version_sql = sqlrequest($database_eonweb,"INSERT INTO configs (name, value) VALUES('version', '".$version."')");
// execution de tous les .sql jusqu'à la version donné dans config // execution de tous les .sql jusqu'à la version donné dans config
exec("ls /srv/eyesofnetwork/eonweb/appliance/updates/ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n", $SQL_Files); $SQL_Files = array_slice(scandir($dir), 2);
usort($SQL_Files, 'version_compare');
foreach($SQL_Files as $file){ foreach($SQL_Files as $file){
echo "mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"; if(rtrim($file,'.sql') <= $version){
exec("mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"); exec("mysql -u $database_username --password=$database_password < $dir$file");
}
} }
}else{ }else{
$versionBD = mysqli_result(sqlrequest($database_eonweb,"SELECT value FROM configs WHERE name='version'"),0,"value"); $versionBD = mysqli_result(sqlrequest($database_eonweb,"SELECT value FROM configs WHERE name='version'"),0,"value");
// execution des .sql entre version en BD et celle config // execution des .sql entre version en BD et celle config
exec("ls /srv/eyesofnetwork/eonweb/appliance/updates/ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n", $SQL_Files);
$SQL_Files = array_slice(scandir($dir), 2);
usort($SQL_Files, 'version_compare');
foreach($SQL_Files as $file){ foreach($SQL_Files as $file){
if((rtrim($file,'.sql') <= $version && rtrim($file,'.sql') > $versionBD)){ if((rtrim($file,'.sql') <= $version && rtrim($file,'.sql') > $versionBD)){
echo "mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"; exec("mysql -u $database_username --password=$database_password < $dir$file");
exec("mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file");
} }
} }
sqlrequest($database_eonweb,"UPDATE configs SET value='$version' WHERE name='version'"); sqlrequest($database_eonweb,"UPDATE configs SET value='$version' WHERE name='version'");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment