From 376764379b0689a28d22920d3e31edbf1e54ebe4 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 19 Mar 2012 21:44:30 +0000 Subject: [PATCH] Sync to svn r3955 to get fresh installation working From: Michael Prokop --- db_scripts/base/0010_create_bss.up | 151 +---- db_scripts/base/0020_create_oss.up | 430 +++++-------- db_scripts/base/0030_create_kamailio_301.up | 148 ++--- .../base/0040_create_oss_triggers_kamailio.up | 596 ++++++++---------- db_scripts/base/0050_create_accounting.up | 49 +- db_scripts/base/0070_create_sipstats.up | 38 -- db_scripts/base/0080_create_carrier.up | 104 --- db_scripts/base/0100_grants_dbs.template | 74 ++- .../0110_grants_proxies_kamailio.template | 25 +- db_scripts/base/3955.down | 2 - db_scripts/base/3955.up | 18 - db_scripts/base/6424.up | 10 +- 12 files changed, 538 insertions(+), 1107 deletions(-) delete mode 100644 db_scripts/base/0070_create_sipstats.up delete mode 100644 db_scripts/base/0080_create_carrier.up delete mode 100644 db_scripts/base/3955.down delete mode 100644 db_scripts/base/3955.up diff --git a/db_scripts/base/0010_create_bss.up b/db_scripts/base/0010_create_bss.up index 81660703..59a77d41 100644 --- a/db_scripts/base/0010_create_bss.up +++ b/db_scripts/base/0010_create_bss.up @@ -72,15 +72,12 @@ CREATE TABLE `billing_profiles` ( `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), `handle` varchar(63) NOT NULL, `name` varchar(31) NOT NULL, - `prepaid` bool NOT NULL DEFAULT FALSE, + `prepaid` bool NOT NULL DEFAULT TRUE, `interval_charge` double NOT NULL DEFAULT 0, `interval_free_time` int(5) NOT NULL DEFAULT 0, `interval_free_cash` double NOT NULL DEFAULT 0, `interval_unit` enum('week','month') NOT NULL DEFAULT 'month', `interval_count` tinyint(3) UNSIGNED NOT NULL DEFAULT 1, - `fraud_interval_limit` int(11) UNSIGNED NULL DEFAULT NULL, - `fraud_interval_lock` tinyint(3) UNSIGNED NOT NULL DEFAULT 0, - `fraud_interval_notify` varchar(255) NULL DEFAULT NULL, `currency` varchar(31) NULL DEFAULT NULL, `vat_rate` tinyint(3) UNSIGNED NULL DEFAULT NULL, `vat_included` bool NOT NULL DEFAULT TRUE, @@ -105,43 +102,6 @@ CREATE TABLE `billing_zones` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; -CREATE TABLE `billing_zones_history` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `bz_id` int(11) UNSIGNED, - `billing_profile_id` int(11) UNSIGNED NOT NULL, - `zone` varchar(127) NOT NULL, - `detail` varchar(127) NULL, - PRIMARY KEY (`id`), - KEY `bzid_idx` (`bz_id`), - CONSTRAINT `b_z_h_bzid_ref` FOREIGN KEY (`bz_id`) - REFERENCES `billing_zones` (`id`) - ON DELETE SET NULL ON UPDATE NO ACTION -) ENGINE=InnoDB; - -DELIMITER | - -CREATE TRIGGER bill_zones_crepl_trig AFTER INSERT ON billing_zones - FOR EACH ROW BEGIN - - INSERT INTO billing_zones_history - VALUES(NULL, NEW.id, NEW.billing_profile_id, NEW.zone, NEW.detail); - - END; -| - -CREATE TRIGGER bill_zones_urepl_trig AFTER UPDATE ON billing_zones - FOR EACH ROW BEGIN - - UPDATE billing_zones_history - SET bz_id = NEW.id, billing_profile_id = NEW.billing_profile_id, - zone = NEW.zone, detail = NEW.detail - WHERE bz_id = OLD.id; - - END; -| - -DELIMITER ; - CREATE TABLE `billing_fees` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `billing_profile_id` int(11) UNSIGNED NOT NULL REFERENCES `billing_profiles` (`id`), @@ -169,71 +129,6 @@ CREATE TABLE `billing_fees` ( UNIQUE KEY `profdestype_idx` (`billing_profile_id`, `destination`, `type`) ) ENGINE=InnoDB; -CREATE TABLE `billing_fees_history` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `bf_id` int(11) UNSIGNED, - `billing_profile_id` int(11) UNSIGNED NOT NULL, - `billing_zones_history_id` int(11) UNSIGNED NULL, - `destination` varchar(255) NOT NULL, - `type` enum('call', 'sms') NOT NULL DEFAULT 'call', - `onpeak_init_rate` double NOT NULL DEFAULT 0, - `onpeak_init_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `onpeak_follow_rate` double NOT NULL DEFAULT 0, - `onpeak_follow_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `offpeak_init_rate` double NOT NULL DEFAULT 0, - `offpeak_init_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `offpeak_follow_rate` double NOT NULL DEFAULT 0, - `offpeak_follow_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `use_free_time` bool NOT NULL DEFAULT FALSE, - PRIMARY KEY (`id`), - KEY `bfid_idx` (`bf_id`), - CONSTRAINT `b_f_h_bfid_ref` FOREIGN KEY (`bf_id`) - REFERENCES `billing_fees` (`id`) - ON DELETE SET NULL ON UPDATE NO ACTION, - KEY `zonehid_idx` (`billing_zones_history_id`), - CONSTRAINT `b_f_h_bzhid_ref` FOREIGN KEY (`billing_zones_history_id`) - REFERENCES `billing_zones_history` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE -) ENGINE=InnoDB; - -DELIMITER | - -CREATE TRIGGER bill_fees_crepl_trig AFTER INSERT ON billing_fees - FOR EACH ROW BEGIN - DECLARE my_bzh_id int UNSIGNED; - - SELECT id INTO my_bzh_id FROM billing_zones_history WHERE bz_id = NEW.billing_zone_id; - - INSERT INTO billing_fees_history - VALUES(NULL, NEW.id, NEW.billing_profile_id, my_bzh_id, NEW.destination, - NEW.type, NEW.onpeak_init_rate, NEW.onpeak_init_interval, NEW.onpeak_follow_rate, - NEW.onpeak_follow_interval, NEW.offpeak_init_rate, NEW.offpeak_init_interval, - NEW.offpeak_follow_rate, NEW.offpeak_follow_interval, NEW.use_free_time); - - END; -| - -CREATE TRIGGER bill_fees_urepl_trig AFTER UPDATE ON billing_fees - FOR EACH ROW BEGIN - DECLARE my_bzh_id int UNSIGNED; - - SELECT id INTO my_bzh_id FROM billing_zones_history WHERE bz_id = NEW.billing_zone_id; - - UPDATE billing_fees_history - SET bf_id = NEW.id, billing_profile_id = NEW.billing_profile_id, - billing_zones_history_id = my_bzh_id, destination = NEW.destination, type = NEW.type, - onpeak_init_rate = NEW.onpeak_init_rate, onpeak_init_interval = NEW.onpeak_init_interval, - onpeak_follow_rate = NEW.onpeak_follow_rate, onpeak_follow_interval = NEW.onpeak_follow_interval, - offpeak_init_rate = NEW.offpeak_init_rate, offpeak_init_interval = NEW.offpeak_init_interval, - offpeak_follow_rate = NEW.offpeak_follow_rate, offpeak_follow_interval = NEW.offpeak_follow_interval, - use_free_time = NEW.use_free_time - WHERE bf_id = OLD.id; - - END; -| - -DELIMITER ; - CREATE TABLE `billing_peaktime_weekdays` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `billing_profile_id` int(11) UNSIGNED NOT NULL REFERENCES `billing_profiles` (`id`), @@ -351,7 +246,6 @@ CREATE TABLE `customers` ( `contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), `tech_contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), `comm_contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), - `external_id` varchar(255) NULL default NULL, `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `create_timestamp` timestamp, PRIMARY KEY (`id`), @@ -371,8 +265,7 @@ CREATE TABLE `customers` ( KEY `techcontact_idx` (`tech_contact_id`), CONSTRAINT `cu_techcontact_ref` FOREIGN KEY (`tech_contact_id`) REFERENCES `contacts` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - KEY `externalid_idx` (`external_id`) + ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB; CREATE TABLE `customer_registers` ( @@ -496,7 +389,6 @@ CREATE TABLE `contracts` ( `contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), `order_id` int(11) UNSIGNED NULL REFERENCES `orders` (`id`), `status` enum('pending','active','locked','terminated') NOT NULL DEFAULT 'active', - `external_id` varchar(255) NULL default NULL, `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `create_timestamp` timestamp NOT NULL, `activate_timestamp` timestamp NULL, @@ -517,8 +409,7 @@ CREATE TABLE `contracts` ( KEY `orderid_idx` (`order_id`), CONSTRAINT `co_orderid_ref` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE, - KEY `externalid_idx` (`external_id`) + ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB; -- create resellers->contracts foreign key @@ -550,7 +441,6 @@ CREATE TABLE `voip_subscribers` ( `domain_id` int(11) UNSIGNED NOT NULL REFERENCES `domains` (`id`), `status` enum('active','locked','terminated') NOT NULL DEFAULT 'active', `primary_number_id` int(11) unsigned default NULL, - `external_id` varchar(255) NULL default NULL, PRIMARY KEY (`id`), UNIQUE KEY `uuid_idx` (uuid), KEY `username_idx` (`username`), @@ -562,15 +452,14 @@ CREATE TABLE `voip_subscribers` ( CONSTRAINT `v_s_domainid_ref` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - KEY `pnumid_idx` (`primary_number_id`), - KEY `externalid_idx` (`external_id`) + KEY `pnumid_idx` (`primary_number_id`) ) ENGINE=InnoDB; -- create table that stores all known E.164 numbers CREATE TABLE `voip_numbers` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `cc` int(4) UNSIGNED NOT NULL, - `ac` varchar(7) NOT NULL, + `ac` int(5) UNSIGNED NOT NULL, `sn` varchar(31) NOT NULL, `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), `subscriber_id` int(11) UNSIGNED NULL REFERENCES `voip_subscribers` (`id`), @@ -579,7 +468,6 @@ CREATE TABLE `voip_numbers` ( `list_timestamp` timestamp, PRIMARY KEY (`id`), KEY `listts_idx` (`list_timestamp`), - UNIQUE KEY `number_idx` (`cc`,`ac`,`sn`), KEY `resellerid_idx` (`reseller_id`), CONSTRAINT `v_n_resellerid_ref` FOREIGN KEY (`reseller_id`) REFERENCES `resellers` (`id`) @@ -594,7 +482,7 @@ CREATE TABLE `voip_numbers` ( CREATE TABLE `voip_number_blocks` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `cc` int(4) UNSIGNED NOT NULL, - `ac` varchar(7) NOT NULL, + `ac` int(5) UNSIGNED NOT NULL, `sn_prefix` varchar(31) NOT NULL, `sn_length` tinyint(2) UNSIGNED NOT NULL, `allocable` bool NOT NULL DEFAULT FALSE, @@ -623,7 +511,7 @@ ALTER TABLE voip_subscribers ADD CONSTRAINT `v_s_pnumid_ref` FOREIGN KEY (`primary_number_id`) REFERENCES `voip_numbers` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE + ON DELETE CASCADE ON UPDATE CASCADE ; -- create account status table @@ -729,22 +617,15 @@ CREATE TABLE `voip_intercept` ( -- insert some data to get rating and the web interface working -- system internal products -INSERT INTO `products` (id,class,handle,name,on_sale) - VALUES (1,'pstnpeering','PSTN_PEERING','PSTN Peering',1), - (2,'sippeering','SIP_PEERING','SIP Peering',1), - (3,'reseller','VOIP_RESELLER','VoIP Reseller',1); +INSERT INTO `products` + VALUES (1,NULL,'pstnpeering','PSTN_PEERING','PSTN Peering',1,NULL,NULL,NULL), + (2,NULL,'sippeering','SIP_PEERING','SIP Peering',1,NULL,NULL,NULL), + (3,NULL,'reseller','VOIP_RESELLER','VoIP Reseller',1,NULL,NULL,NULL); -- the default reseller contract, will be the only one unless multitenancy is enabled -INSERT INTO `contracts` (id,status,modify_timestamp,create_timestamp,activate_timestamp) VALUES (1,'active',now(),now(),now()); -INSERT INTO `resellers` (id,contract_id,name,status) VALUES (1,1,'default','active'); -INSERT INTO `billing_mappings` (id,start_date,end_date,contract_id,product_id) VALUES (1,NULL,NULL,1,3); +INSERT INTO `contracts` VALUES (1,NULL,NULL,NULL,NULL,'active',now(),now(),now(),NULL); +INSERT INTO `resellers` VALUES (1,1,'default','active'); +INSERT INTO `billing_mappings` VALUES (1,NULL,NULL,NULL,1,3); -- first administrative account, change password after first login -INSERT INTO `admins` (id,reseller_id,login,md5pass,is_master,is_superuser,call_data,lawful_intercept) - VALUES (1,1,'administrator',md5('administrator'),1,1,1,1); +INSERT INTO `admins` VALUES (1,1,'administrator',md5('administrator'),1,1,1,0,1,1,1); -- default billing profile creation -INSERT INTO `billing_profiles` (id,reseller_id,handle,name,interval_unit,interval_count) - VALUES(1,1,'default','Default Billing Profile','month',1); -INSERT INTO `billing_zones` (id,billing_profile_id,zone,detail) VALUES (1,1,'Free Default Zone','All Destinations'); -INSERT INTO `billing_fees` (id,billing_profile_id,billing_zone_id,destination,type, - onpeak_init_rate,onpeak_init_interval,onpeak_follow_rate,onpeak_follow_interval, - offpeak_init_rate,offpeak_init_interval,offpeak_follow_rate,offpeak_follow_interval) - VALUES (1,1,1,'.*','call',0,600,0,600,0,600,0,600); +INSERT INTO `billing_profiles` VALUES(1,1,'default','Default Billing Profile',1,0,0,0,'month',1,NULL,0,0); diff --git a/db_scripts/base/0020_create_oss.up b/db_scripts/base/0020_create_oss.up index fef94be2..6666bed9 100644 --- a/db_scripts/base/0020_create_oss.up +++ b/db_scripts/base/0020_create_oss.up @@ -15,10 +15,27 @@ USE provisioning; CREATE TABLE `voip_domains` ( `id` int(11) UNSIGNED NOT NULL auto_increment, `domain` varchar(127) NOT NULL, + `local` bool NOT NULL default FALSE, + `timezone` varchar(31) default NULL, PRIMARY KEY (`id`), UNIQUE KEY `domain_idx` (`domain`) ) ENGINE=InnoDB; +-- create domain rewrite rules table +CREATE TABLE `voip_domain_rewrites` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `domain_id` int(11) unsigned NOT NULL, + `match_pattern` varchar(64) NOT NULL DEFAULT '', + `replace_pattern` varchar(64) NOT NULL, + `description` varchar(127) NOT NULL DEFAULT '', + `direction` enum('in','out') NOT NULL, + `field` enum('caller','callee') NOT NULL, + `priority` int(11) unsigned NOT NULL DEFAULT 50, + PRIMARY KEY (`id`), + KEY `domainidx` (`domain_id`), + CONSTRAINT `v_drw_domainid_ref` FOREIGN KEY (`domain_id`) REFERENCES `voip_domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + -- create subscriber table CREATE TABLE `voip_subscribers` ( @@ -26,11 +43,12 @@ CREATE TABLE `voip_subscribers` ( `username` varchar(127) NOT NULL, `domain_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_domains` (`id`), `uuid` char(36) NOT NULL, - `password` varchar(40) default NULL, + `password` varchar(31) default NULL, + `timezone` varchar(31) default NULL, `admin` bool NOT NULL DEFAULT FALSE, `account_id` int(11) UNSIGNED NULL DEFAULT NULL, `webusername` varchar(127) default NULL, - `webpassword` varchar(40) default NULL, + `webpassword` varchar(31) default NULL, `autoconf_displayname` varchar(255) default NULL, `autoconf_group_id` int(11) unsigned default NULL, `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, @@ -63,63 +81,21 @@ CREATE TABLE `voip_dbaliases` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; --- sip peering tables -CREATE TABLE `voip_peer_groups` ( - `id` int(11) unsigned NOT NULL auto_increment, - `name` varchar(127) NOT NULL, - `priority` tinyint(3) NOT NULL default '1', - `description` varchar(255), - `peering_contract_id` int(11) unsigned, - PRIMARY KEY (`id`), - UNIQUE KEY `name` (`name`) -) ENGINE=InnoDB; - -CREATE TABLE `voip_peer_rules` ( - `id` int(11) unsigned NOT NULL auto_increment, - `group_id` int(11) unsigned NOT NULL, - `callee_prefix` varchar(64) NOT NULL default '', - `caller_prefix` varchar(64) default NULL, - `description` varchar(255) NOT NULL, - PRIMARY KEY (`id`), - KEY `grpidx` (`group_id`), - CONSTRAINT `v_pg_groupid_ref` FOREIGN KEY (`group_id`) REFERENCES `voip_peer_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `voip_peer_hosts` ( - `id` int(11) unsigned NOT NULL auto_increment, - `group_id` int(11) unsigned NOT NULL, - `name` varchar(64) NOT NULL default '', - `ip` varchar(64) NOT NULL, - `host` varchar(64) DEFAULT NULL, - `port` int(5) NOT NULL default '5060', - `weight` tinyint(3) NOT NULL default '0', - `via_lb` tinyint(1) NOT NULL default '0', - PRIMARY KEY (`id`), - UNIQUE KEY `grpname` (`group_id`,`name`), - KEY `grpidx` (`group_id`), - CONSTRAINT `v_ps_groupid_ref` FOREIGN KEY (`group_id`) REFERENCES `voip_peer_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -- create voip_preferences table -CREATE TABLE `voip_preferences` ( +CREATE TABLE voip_preferences ( `id` int(11) UNSIGNED NOT NULL auto_increment, `attribute` varchar(31) NOT NULL, `type` tinyint(3) NOT NULL default 0, `max_occur` tinyint(3) UNSIGNED NOT NULL, - `usr_pref` bool NOT NULL default FALSE, - `dom_pref` bool NOT NULL default FALSE, - `peer_pref` bool NOT NULL default FALSE, `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `internal` tinyint(1) NOT NULL default 0, - `data_type` enum('boolean','int','string') NOT NULL default 'string', - `read_only` bool NOT NULL default FALSE, - `description` text, + `internal` bool NOT NULL default FALSE, + `data_type` enum('bool','int','string') NOT NULL default 'string', PRIMARY KEY (`id`), UNIQUE KEY `attribute_idx` (`attribute`) ) ENGINE=InnoDB; -- create subscriber preferences table -CREATE TABLE `voip_usr_preferences` ( +CREATE TABLE voip_usr_preferences ( `id` int(11) UNSIGNED NOT NULL auto_increment, `subscriber_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_subscribers` (`id`), `attribute_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_preferences` (`id`), @@ -138,7 +114,7 @@ CREATE TABLE `voip_usr_preferences` ( ) ENGINE=InnoDB; -- create domain preferences table -CREATE TABLE `voip_dom_preferences` ( +CREATE TABLE voip_dom_preferences ( `id` int(11) UNSIGNED NOT NULL auto_increment, `domain_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_domains` (`id`), `attribute_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_preferences` (`id`), @@ -156,24 +132,6 @@ CREATE TABLE `voip_dom_preferences` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; --- create peer host preferences table -CREATE TABLE `voip_peer_preferences` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `peer_host_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_peer_hosts` (`id`), - `attribute_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_preferences` (`id`), - `value` varchar(255) NOT NULL, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `peerhostid_idx` (`peer_host_id`), - KEY `attributeid_idx` (`attribute_id`), - CONSTRAINT `v_p_p_peerhostid_ref` FOREIGN KEY (`peer_host_id`) - REFERENCES `voip_peer_hosts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `v_p_p_attributeid_ref` FOREIGN KEY (`attribute_id`) - REFERENCES `voip_preferences` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -- create preliminary address book table -- this should be moved to LDAP at some time CREATE TABLE `voip_contacts` ( @@ -268,6 +226,62 @@ CREATE TABLE `voip_fax_destinations` ( ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; +-- sip peering tables +CREATE TABLE `voip_peer_groups` ( + `id` int(11) unsigned NOT NULL auto_increment, + `name` varchar(127) NOT NULL, + `priority` tinyint(3) NOT NULL default '1', + `description` varchar(255), + `peering_contract_id` int(11) unsigned, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB; + +CREATE TABLE `voip_peer_rules` ( + `id` int(11) unsigned NOT NULL auto_increment, + `group_id` int(11) unsigned NOT NULL, + `callee_prefix` varchar(64) NOT NULL default '', + `caller_prefix` varchar(64) default NULL, + `description` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + KEY `grpidx` (`group_id`), + CONSTRAINT `v_pg_groupid_ref` FOREIGN KEY (`group_id`) REFERENCES `voip_peer_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + +CREATE TABLE `voip_peer_hosts` ( + `id` int(11) unsigned NOT NULL auto_increment, + `group_id` int(11) unsigned NOT NULL, + `name` varchar(64) NOT NULL default '', + `ip` varchar(15) NOT NULL, + `domain` varchar(64) NOT NULL, + `port` int(5) NOT NULL default '5060', + `weight` tinyint(3) NOT NULL default '0', + `via_lb` tinyint(1) NOT NULL default '0', + `dp_caller_in_id` int(11) unsigned NOT NULL, + `dp_callee_in_id` int(11) unsigned NOT NULL, + `dp_caller_out_id` int(11) unsigned NOT NULL, + `dp_callee_out_id` int(11) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `grpname` (`group_id`,`name`), + KEY `grpidx` (`group_id`), + CONSTRAINT `v_ps_groupid_ref` FOREIGN KEY (`group_id`) REFERENCES `voip_peer_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + +CREATE TABLE `voip_peer_rewrites` ( + `id` int(11) unsigned NOT NULL auto_increment, + `peer_id` int(11) unsigned NOT NULL, + `match_pattern` varchar(64) NOT NULL default '', + `replace_pattern` varchar(64) NOT NULL, + `description` varchar(127) NOT NULL default '', + `direction` enum('in','out') NOT NULL default 'in', + `field` enum('caller','callee') NOT NULL default 'caller', + `priority` int(11) unsigned NOT NULL DEFAULT 50, + PRIMARY KEY (`id`), + KEY `peeridx` (`peer_id`), + KEY `dirfieldidx` (`direction`,`field`), + CONSTRAINT `v_prw_peerid_ref` FOREIGN KEY (`peer_id`) REFERENCES `voip_peer_hosts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + -- audio files for IVR, auto-attendant, etc. CREATE TABLE `voip_audio_files` ( `id` int(11) unsigned NOT NULL auto_increment, @@ -318,6 +332,13 @@ CREATE TABLE language_strings ( UNIQUE KEY `codelang_idx` (code, language) ) ENGINE=InnoDB; +-- counter for various operations +CREATE TABLE `counter` ( + `name` varchar(64) NOT NULL, + `value` int(11) unsigned NOT NULL, + PRIMARY KEY (`name`) +) ENGINE=InnoDB; + -- xmlrpc dispatcher tables CREATE TABLE `xmlqueue` ( `id` int(10) unsigned NOT NULL auto_increment, @@ -336,7 +357,6 @@ CREATE TABLE `xmlhosts` ( `ip` varchar(15) NOT NULL, `port` int(5) unsigned NOT NULL, `path` varchar(64) NOT NULL DEFAULT '/', - `sip_port` int(5) unsigned DEFAULT NULL, `description` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB; @@ -361,231 +381,63 @@ CREATE TABLE `xmlhostgroups` ( REFERENCES `xmlhosts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; -CREATE TABLE `voip_rewrite_rule_sets` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(32) NOT NULL, - `description` varchar(255) DEFAULT NULL, - `caller_in_dpid` int(11) unsigned DEFAULT NULL, - `callee_in_dpid` int(11) unsigned DEFAULT NULL, - `caller_out_dpid` int(11) unsigned DEFAULT NULL, - `callee_out_dpid` int(11) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `name_idx` (`name`) -) ENGINE=InnoDB; - --- this is a sequencer for the dpids in `voip_rewrite_rule_sets` above -CREATE TABLE `voip_rwrs_sequence` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE `voip_rewrite_rules` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `set_id` int(11) unsigned NOT NULL, - `match_pattern` varchar(64) NOT NULL DEFAULT '', - `replace_pattern` varchar(64) NOT NULL, - `description` varchar(127) NOT NULL DEFAULT '', - `direction` enum('in','out') NOT NULL DEFAULT 'in', - `field` enum('caller','callee') NOT NULL DEFAULT 'caller', - `priority` int(11) unsigned NOT NULL DEFAULT '50', - PRIMARY KEY (`id`), - KEY `setidx` (`set_id`), - KEY `dirfieldidx` (`direction`,`field`), - CONSTRAINT `v_rwr_setid_ref` FOREIGN KEY (`set_id`) REFERENCES `voip_rewrite_rule_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- call forward tables -CREATE TABLE `voip_cf_destination_sets` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `subscriber_id` int(11) unsigned DEFAULT NULL, - `name` varchar(255) NOT NULL, - PRIMARY KEY (`id`), - KEY `sub_idx` (`subscriber_id`), - KEY `name_idx` (`name`), - CONSTRAINT `v_s_subid_ref` FOREIGN KEY (`subscriber_id`) REFERENCES `voip_subscribers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `voip_cf_destinations` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `destination_set_id` int(11) unsigned NOT NULL, - `destination` varchar(255) NOT NULL, - `priority` int(3) unsigned DEFAULT NULL, - `timeout` int(11) unsigned NOT NULL DEFAULT 300, - PRIMARY KEY (`id`), - KEY `dset_idx` (`destination_set_id`), - KEY `destination_idx` (`destination`), - CONSTRAINT `v_cf_dsetid_ref` FOREIGN KEY (`destination_set_id`) REFERENCES `voip_cf_destination_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `voip_cf_time_sets` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `subscriber_id` int(11) unsigned DEFAULT NULL, - `name` varchar(255) NOT NULL, - PRIMARY KEY (`id`), - KEY `sub_idx` (`subscriber_id`), - KEY `name_idx` (`name`), - CONSTRAINT `v_cf_ts_subid_ref` FOREIGN KEY (`subscriber_id`) REFERENCES -`voip_subscribers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `voip_cf_periods` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `time_set_id` int(11) unsigned NOT NULL, - `year` varchar(255) DEFAULT NULL, - `month` varchar(255) DEFAULT NULL, - `mday` varchar(255) DEFAULT NULL, - `wday` varchar(255) DEFAULT NULL, - `hour` varchar(255) DEFAULT NULL, - `minute` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `tset_idx` (`time_set_id`), - CONSTRAINT `v_cf_tsetid_ref` FOREIGN KEY (`time_set_id`) REFERENCES -`voip_cf_time_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `voip_cf_mappings` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `subscriber_id` int(11) unsigned NOT NULL, - `type` enum('cfu','cfb','cfna','cft') NOT NULL DEFAULT 'cfu', - `destination_set_id` int(11) unsigned DEFAULT NULL, - `time_set_id` int(11) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `sub_idx` (`subscriber_id`), - KEY `type_idx` (`type`), - CONSTRAINT `v_cfmap_subid_ref` FOREIGN KEY (`subscriber_id`) REFERENCES `voip_subscribers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cfmap_time_ref` FOREIGN KEY (`time_set_id`) REFERENCES `voip_cf_time_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cfmap_dest_ref` FOREIGN KEY (`destination_set_id`) REFERENCES `voip_cf_destination_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE - -) ENGINE=InnoDB; -- INSERT default data -- localization language strings LOAD DATA LOCAL INFILE 'language_strings.txt' INTO TABLE language_strings; +-- dialplan id counter +INSERT INTO counter VALUES('dp_id', 1); + -- xmlrpc dispatcher -INSERT INTO xmlgroups (id, name) VALUES(1, 'proxy'); -INSERT INTO xmlgroups (id, name) VALUES(2, 'registrar'); -INSERT INTO xmlgroups (id, name) VALUES(3, 'presence'); -INSERT INTO xmlgroups (id, name) VALUES(4, 'loadbalancer'); -INSERT INTO xmlgroups (id, name) VALUES(5, 'appserver'); --- TODO: SR interface hack to work around rpc/mi discrepancies -INSERT INTO xmlgroups (id, name) VALUES(6, 'proxy-ng'); - -INSERT INTO xmlhosts (id, ip, port, path, sip_port, description) VALUES (1,'127.0.0.1','8000','/RPC2', '5062', 'Kamailio'); -INSERT INTO xmlhosts (id, ip, port, path, description) VALUES (2,'127.0.0.1','8090','/','Sems'); --- TODO: SR interface hack to work around rpc/mi discrepancies -INSERT INTO xmlhosts (id, ip, port, path, description) VALUES (3,'127.0.0.1','5062','/','Kamailio-SR'); - -INSERT INTO xmlhostgroups (id, group_id, host_id) VALUES (1,1,1); -INSERT INTO xmlhostgroups (id, group_id, host_id) VALUES (2,5,2); -INSERT INTO xmlhostgroups (id, group_id, host_id) VALUES (3,6,3); - --- regular kamailio preferences -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, read_only, description) - VALUES('lock', 0, 1, 'string', 1, 1, 'See "lock_voip_account_subscriber" for a list of possible values. A lock value of "none" will not be returned to the caller. Read-only setting.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('block_in_mode', 1, 1, 'boolean', 1, 'Specifies the operational mode of the incoming block list. If unset or set to a false value, it is a blacklist (accept all calls except from numbers listed in the block list), with a true value it is a whitelist (reject all calls except from numbers listed in the block list).'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('block_in_list', 0, 1, 'string', 0, 'Contains wildcarded E.164 numbers that are (not) allowed to call the subscriber. "*", "?" and "[x-y]" with "x" and "y" representing numbers from 0 to 9 may be used as wildcards like in shell patterns.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('block_in_clir', 1, 1, 'boolean', 1, 'Incoming anonymous calls (with calling line identification restriction) are blocked if set to true.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('block_out_mode', 1, 1, 'boolean', 1, 'Specifies the operational mode of the outgoing block list. If unset or set to a false value, it is a blacklist (allow all calls except to numbers listed in the block list), with a true value it is a whitelist (deny all calls except to numbers listed in the block list).'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('block_out_list', 0, 1, 'string', 0, 'Contains wildcarded E.164 numbers that are (not) allowed to be called by the subscriber. "*", "?" and "[x-y]" with "x" and "y" representing numbers from 0 to 9 may be used as wildcards like in shell patterns.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('adm_block_in_mode', 1, 1, 'boolean', 1, 'Same as "block_in_mode" but may only be set by administrators.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('adm_block_in_list', 0, 1, 'string', 0, 'Same as "block_in_list" but may only be set by administrators and is applied prior to the user setting.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('adm_block_in_clir', 1, 1, 'boolean', 1, 'Same as "block_in_clir" but may only be set by administrators and is applied prior to the user setting.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('adm_block_out_mode', 1, 1, 'boolean', 1, 'Same as "block_out_mode" but may only be set by administrators.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('adm_block_out_list', 0, 1, 'string', 0, 'Same as "block_out_list" but may only be set by administrators and is applied prior to the user setting.'); -INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description) - VALUES(1, 1, 'cfu', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Unconditional" entry in the voip_cf_mappings table'); -INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description) - VALUES(1, 1, 'cfb', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Busy" entry in the voip_cf_mappings table'); -INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description) - VALUES(1, 1, 'cfna', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Unavailable" entry in the voip_cf_mappings table'); -INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description) - VALUES(1, 1, 'cft', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Timeout" entry in the voip_cf_mappings table'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('ringtimeout', 1, 1, 'int', 1, 'Specifies how many seconds the system should wait before redirecting the call if "cft" is set.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('cli', 0, 1, 'string', 1, 'E.164 number or complete SIP URI. "network-provided calling line identification" - specifies the source E.164 number or SIP username that is used for outgoing calls in the SIP "From" and "P-Asserted-Identity" headers (as user- and network-provided calling numbers). The content of the "From" header may be overridden by the "user_cli" preference and client (if allowed by the "allowed_clis" preference) SIP signalling. Automatically set to the primary E.164 number specified in the subscriber details.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('user_cli', 0, 1, 'string', 1, 'E.164 number or complete SIP URI. "user-provided calling line identification" - specifies the source E.164 number or SIP username that is used for outgoing calls. If set, this is put in the SIP "From" header (as user-provided calling number) if a client sends a CLI which is not allowed by "allowed_clis" or "allowed_clis" is not set.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('clir', 1, 1, 'boolean', 1, '"Calling line identification restriction" - if set to true, the CLI is not displayed on outgoing calls.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('cc', 0, 1, 'string', 1, 'The country code that will be used for routing of dialed numbers without a country code. Defaults to the country code of the E.164 number if the subscriber has one.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('ac', 0, 1, 'string', 1, 'The area code that will be used for routing of dialed numbers without an area code. Defaults to the area code of the E.164 number if the subscriber has one.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('svc_ac', 0, 1, 'string', 1, 'The area code that will be used for routing of dialed service numbers without an area code. Defaults to "ac".'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('emerg_ac', 0, 1, 'string', 1, 'The area code that will be used for routing of dialed emergency numbers without an area code. Defaults to "ac".'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('block_out_override_pin', 0, 1, 'string', 1, 'A PIN code which may be used in a VSC to disable the outgoing user block list and NCOS level for a call.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('adm_block_out_override_pin', 0, 1, 'string', 1, 'Same as "block_out_override_pin" but additionally disables the administrative block list and NCOS level.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description) - VALUES('allowed_clis', 0, 1, 'string', 0, 'A list of shell patterns specifying which CLIs are allowed to be set by the subscriber. "*", "?" and "[x-y]" with "x" and "y" representing numbers from 0 to 9 may be used as wildcards as usual in shell patterns.'); -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, data_type, max_occur, description) VALUES('e164_to_ruri', 1, 0, 1, 'boolean', 1, 'Send the E164 number instead of SIP AOR as request username when sending INVITE to the subscriber. If a 404 is received the SIP AOR is sent as request URI as fallback.'); - --- "external" kamailio preferences - only used for documentation and provisioning parameter checks -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal, description) - VALUES('ncos', 0, 1, 'string', 1, -1, 'Specifies the NCOS level that applies to the user.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal, description) - VALUES('adm_ncos', 0, 1, 'string', 1, -1, 'Same as "ncos", but may only be set by administrators and is applied prior to the user setting.'); - --- "internal" kamailio preferences - not directly accessible via provisioning (often mapped to an "external" preference somehow) -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('ncos_id', 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('adm_ncos_id', 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('account_id', 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('ext_contract_id', 0, 1, 'string', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('ext_subscriber_id', 0, 1, 'string', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('prepaid', 1, 1, 'boolean', 1, 1); - --- domain preferences -INSERT INTO voip_preferences (attribute, type, dom_pref, data_type, max_occur, description) VALUES('unauth_inbound_calls', 1, 1, 'boolean', 1, 'Allow unauthenticated inbound calls from FOREIGN domain to users within this domain. Use with care - it allows to flood your users with voice spam.'); - - --- peer preferences -INSERT INTO voip_preferences (attribute, type, usr_pref, peer_pref, data_type, max_occur, description) - VALUES('peer_auth_user', 0, 1, 1, 'string', 1, 'A username used for authentication against a peer host.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, peer_pref, data_type, max_occur, description) - VALUES('peer_auth_pass', 0, 1, 1, 'string', 1, 'A password used for authentication against a peer host.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, peer_pref, data_type, max_occur, description) - VALUES('peer_auth_realm', 0, 1, 1, 'string', 1, 'A realm (hostname) used to identify and for authentication against a peer host.'); -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('find_subscriber_by_auth_user', 1, 0, 0, 1, 'boolean', 1, 'For incoming calls from this peer, find the destination subscriber also using its auth_username used for outbound registration.'); - - --- user + domain preferences -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, data_type, max_occur, description) VALUES('omit_outbound_displayname', 1, 1, 1, 'boolean', 1, 'Suppress the caller display-name that is put in the SIP "From" header on outgoing calls.'); -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, data_type, max_occur, description) VALUES('force_inbound_calls_to_peer', 1, 1, 1, 'boolean', 1, 'Force calls to this user to be treated as if the user was not local. This helps in migration scenarios.'); - - --- user + domain + peer preferences -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('always_use_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Force rtp relay for this peer/domain/user.'); -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('never_use_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Do not use rtp relay for this peer/domain/user. Rtp will be relayed if other participants have always_use_rtpproxy preference enabled.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('peer_auth_register', 1, 1, 1, 1, 'boolean', 1, 'Specifies whether registration at the peer host is desired.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('concurrent_max', 1, 1, 1, 1, 'int', 1, 'Maximum number of concurrent sessions (calls) for a subscriber or peer.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('concurrent_max_out', 1, 1, 1, 1, 'int', 1, 'Maximum number of concurrent outgoing sessions (calls) coming from a subscriber or going to a peer.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('force_outbound_calls_to_peer', 1, 1, 1, 1, 'boolean', 1, 'Force calls from this user/domain/peer to be routed to PSTN even if the callee is local. Use with caution, as this setting may increase your costs! When enabling this option in a peer, make sure you trust it, as the NGCP will become an open relay for it!'); - -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal, description) - VALUES('rewrite_rule_set', 1, 1, 1, 1, 'int', 1, -1, 'Specifies the list of caller and callee rewrite rules which should be applied for incoming and outgoing calls.'); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal) - VALUES('rewrite_caller_in_dpid', 1, 1, 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal) - VALUES('rewrite_callee_in_dpid', 1, 1, 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal) - VALUES('rewrite_caller_out_dpid', 1, 1, 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal) - VALUES('rewrite_callee_out_dpid', 1, 1, 1, 1, 'int', 1, 1); -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('always_use_ipv4_for_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Always force the IPv4 address for the RTP relay, regardless of what is autodetected on SIP/SDP level. This is mutually exclusive with always_use_ipv6_for_rtpproxy.'); -INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('always_use_ipv6_for_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Always force the IPv6 address for the RTP relay, regardless of what is autodetected on SIP/SDP level. This is mutually exclusive with always_use_ipv4_for_rtpproxy.'); +INSERT INTO xmlgroups (name) VALUES('proxy'); +INSERT INTO xmlgroups (name) VALUES('registrar'); +INSERT INTO xmlgroups (name) VALUES('presence'); +INSERT INTO xmlgroups (name) VALUES('loadbalancer'); +INSERT INTO xmlgroups (name) VALUES('appserver'); + +-- internal domain and subscribers +INSERT INTO voip_domains (domain, local) VALUES('voip.sipwise.local', true); +INSERT INTO voip_subscribers (username, domain_id, uuid, create_timestamp) + SELECT 'no_such_number', id, '9bcb88b6-541a-43da-8fdc-816f5557ff93', NOW() + FROM voip_domains WHERE domain = 'voip.sipwise.local'; +INSERT INTO voip_subscribers (username, domain_id, uuid, password, create_timestamp) + SELECT 'nagios', id, 'ac1697cf-6933-45ef-9abf-b1278054ded0', 'nagios4Sipwise!', NOW() + FROM voip_domains WHERE domain = 'voip.sipwise.local'; + +-- kamailio preferences +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('lock', 0, 'int', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('block_in_mode', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('block_in_list', 0, 'string', 0); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('block_in_clir', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('block_out_mode', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('block_out_list', 0, 'string', 0); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('adm_block_in_mode', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('adm_block_in_list', 0, 'string', 0); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('adm_block_in_clir', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('adm_block_out_mode', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('adm_block_out_list', 0, 'string', 0); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('cfu', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('cfb', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('cfna', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('cft', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('ringtimeout', 1, 'int', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('cli', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('clir', 1, 'bool', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('cc', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('ac', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('svc_ac', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur) VALUES('emerg_ac', 0, 'string', 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal) VALUES('ncos_id', 1, 'int', 1, 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal) VALUES('adm_ncos_id', 1, 'int', 1, 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal) VALUES('dp_dom_caller_in', 1, 'int', 1, 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal) VALUES('dp_dom_callee_in', 1, 'int', 1, 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal) VALUES('dp_dom_caller_out', 1, 'int', 1, 1); +INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal) VALUES('dp_dom_callee_out', 1, 'int', 1, 1); + +-- xmlrpc hosts +INSERT INTO xmlhosts VALUES ('1','127.0.0.1','8000','/RPC2','Kamailio'); +INSERT INTO xmlhosts VALUES ('2','127.0.0.1','8090','/','Sems'); +INSERT INTO xmlhostgroups VALUES ('1','1','1'); +INSERT INTO xmlhostgroups VALUES ('2','5','2'); diff --git a/db_scripts/base/0030_create_kamailio_301.up b/db_scripts/base/0030_create_kamailio_301.up index deca5732..1019f156 100644 --- a/db_scripts/base/0030_create_kamailio_301.up +++ b/db_scripts/base/0030_create_kamailio_301.up @@ -1,7 +1,7 @@ USE mysql; DROP DATABASE IF EXISTS kamailio; -CREATE DATABASE IF NOT EXISTS kamailio CHARACTER SET 'utf8'; +CREATE DATABASE IF NOT EXISTS kamailio CHARACTER SET 'latin1'; USE kamailio; @@ -10,13 +10,12 @@ CREATE TABLE `acc` ( `method` varchar(16) NOT NULL DEFAULT '', `from_tag` varchar(64) NOT NULL DEFAULT '', `to_tag` varchar(64) NOT NULL DEFAULT '', - `callid` varchar(255) NOT NULL DEFAULT '', + `callid` varchar(64) NOT NULL DEFAULT '', `sip_code` varchar(3) NOT NULL DEFAULT '', - `sip_reason` varchar(128) NOT NULL DEFAULT '', + `sip_reason` varchar(32) NOT NULL DEFAULT '', `time` datetime NOT NULL, - `time_hires` decimal(13,3) NOT NULL, - `src_leg` varchar(2048) default NULL, - `dst_leg` varchar(2048) default NULL, + `src_leg` varchar(255) default NULL, + `dst_leg` varchar(255) default NULL, `dst_user` varchar(64) NOT NULL default '', `dst_ouser` varchar(64) NOT NULL default '', `dst_domain` varchar(128) NOT NULL default '', @@ -24,7 +23,7 @@ CREATE TABLE `acc` ( `src_domain` varchar(128) NOT NULL default '', PRIMARY KEY (`id`), KEY `callid_idx` (`callid`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `dbaliases` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -35,7 +34,7 @@ CREATE TABLE `dbaliases` ( PRIMARY KEY (`id`), UNIQUE KEY `alias_idx` (`alias_username`,`alias_domain`), KEY `target_idx` (`username`,`domain`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `dialog` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -62,7 +61,7 @@ CREATE TABLE `dialog` ( `req_uri` varchar(128) NOT NULL, PRIMARY KEY (`id`), KEY `hash_idx` (`hash_entry`,`hash_id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `dialplan` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -72,10 +71,10 @@ CREATE TABLE `dialplan` ( `match_exp` varchar(64) NOT NULL, `match_len` int(11) NOT NULL, `subst_exp` varchar(64) NOT NULL, - `repl_exp` varchar(64) NOT NULL, + `repl_exp` varchar(32) NOT NULL, `attrs` varchar(32) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `dispatcher` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -85,7 +84,7 @@ CREATE TABLE `dispatcher` ( `priority` int(11) NOT NULL DEFAULT '0', `description` varchar(64) NOT NULL DEFAULT '', PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `domain` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -93,58 +92,38 @@ CREATE TABLE `domain` ( `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', PRIMARY KEY (`id`), UNIQUE KEY `domain_idx` (`domain`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -CREATE TABLE `lcr_gw` ( +CREATE TABLE `gw` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `lcr_id` smallint(5) unsigned NOT NULL, `gw_name` varchar(128) NOT NULL, - `ip_addr` varchar(64) NOT NULL, + `grp_id` int(10) unsigned NOT NULL, + `ip_addr` varchar(15) NOT NULL, `hostname` varchar(64) DEFAULT NULL, `port` smallint(5) unsigned DEFAULT NULL, - `params` varchar(64) DEFAULT NULL, `uri_scheme` tinyint(3) unsigned DEFAULT NULL, `transport` tinyint(3) unsigned DEFAULT NULL, `strip` tinyint(3) unsigned DEFAULT NULL, `tag` varchar(16) DEFAULT NULL, + `weight` int(10) unsigned DEFAULT NULL, `flags` int(10) unsigned NOT NULL DEFAULT '0', `defunct` int(10) unsigned DEFAULT NULL, - `group_id` int(11) unsigned NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `lcr_id_gw_name_idx` (`lcr_id`,`gw_name`), - UNIQUE KEY `lcr_id_ip_addr_idx` (`lcr_id`,`ip_addr`) -) ENGINE=InnoDB; + UNIQUE KEY `lcr_id_grp_id_gw_name_idx` (`lcr_id`,`grp_id`,`gw_name`), + UNIQUE KEY `lcr_id_grp_id_ip_addr_idx` (`lcr_id`,`grp_id`,`ip_addr`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -CREATE TABLE `lcr_rule` ( +CREATE TABLE `lcr` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `lcr_id` smallint(5) unsigned NOT NULL, `prefix` varchar(16) DEFAULT NULL, `from_uri` varchar(64) DEFAULT NULL, - `stopper` int(10) unsigned NOT NULL DEFAULT '0', - `enabled` int(10) unsigned NOT NULL DEFAULT '1', - `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `lcr_id_idx` (`lcr_id`) -) ENGINE=InnoDB; - -CREATE TABLE `lcr_rule_target` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lcr_id` smallint(5) unsigned NOT NULL, - `rule_id` int(10) unsigned NOT NULL, - `gw_id` int(10) unsigned NOT NULL, + `grp_id` int(10) unsigned NOT NULL, `priority` tinyint(3) unsigned NOT NULL, - `weight` int(10) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`), - UNIQUE KEY `rule_id_gw_id_idx` (`rule_id`,`gw_id`), - KEY `lcr_id_idx` (`lcr_id`), - KEY `gw_id_idx` (`gw_id`), - CONSTRAINT `l_r_t_ruleid_ref` FOREIGN KEY (`rule_id`) - REFERENCES `lcr_rule` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `l_r_t_gwid_ref` FOREIGN KEY (`gw_id`) - REFERENCES `lcr_gw` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; + KEY `lcr_id_idx` (`lcr_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `location` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -165,7 +144,7 @@ CREATE TABLE `location` ( `methods` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `account_contact_idx` (`username`,`domain`,`contact`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `speed_dial` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -179,13 +158,13 @@ CREATE TABLE `speed_dial` ( `description` varchar(64) NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `speed_dial_idx` (`username`,`domain`,`sd_domain`,`sd_username`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `subscriber` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(64) NOT NULL DEFAULT '', `domain` varchar(64) NOT NULL DEFAULT '', - `password` varchar(40) NOT NULL DEFAULT '', + `password` varchar(25) NOT NULL DEFAULT '', `email_address` varchar(64) NOT NULL DEFAULT '', `ha1` varchar(64) NOT NULL DEFAULT '', `ha1b` varchar(64) NOT NULL DEFAULT '', @@ -196,7 +175,7 @@ CREATE TABLE `subscriber` ( PRIMARY KEY (`id`), UNIQUE KEY `account_idx` (`username`,`domain`), KEY `username_idx` (`username`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `trusted` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -206,7 +185,7 @@ CREATE TABLE `trusted` ( `tag` varchar(64) DEFAULT NULL, PRIMARY KEY (`id`), KEY `peer_idx` (`src_ip`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `usr_preferences` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -220,7 +199,7 @@ CREATE TABLE `usr_preferences` ( PRIMARY KEY (`id`), KEY `ua_idx` (`uuid`,`attribute`), KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `dom_preferences` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -234,21 +213,7 @@ CREATE TABLE `dom_preferences` ( PRIMARY KEY (`id`), KEY `ua_idx` (`uuid`,`attribute`), KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB; - -CREATE TABLE `peer_preferences` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uuid` varchar(36) NOT NULL, - `username` varchar(128) NOT NULL DEFAULT '0', - `domain` varchar(64) NOT NULL DEFAULT '', - `attribute` varchar(32) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `value` varchar(128) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - KEY `ua_idx` (`uuid`,`attribute`) --- not used -- KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `address` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -256,14 +221,13 @@ CREATE TABLE `address` ( `ip_addr` varchar(15) NOT NULL, `mask` tinyint(4) NOT NULL DEFAULT '32', `port` smallint(5) unsigned NOT NULL DEFAULT '0', - `tag` VARCHAR(64), PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `version` ( `table_name` varchar(32) NOT NULL, `table_version` int(10) unsigned NOT NULL DEFAULT '0' -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `voicemail_users` ( `uniqueid` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -294,7 +258,7 @@ CREATE TABLE `voicemail_users` ( PRIMARY KEY (`uniqueid`), KEY `customer_idx` (`customer_id`), KEY `mailbox_context` (`mailbox`,`context`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `voicemail_spool` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -303,8 +267,8 @@ CREATE TABLE `voicemail_spool` ( `context` varchar(63) DEFAULT '', `macrocontext` varchar(63) DEFAULT '', `callerid` varchar(255) DEFAULT '', - `origtime` varchar(16) DEFAULT '', - `duration` varchar(16) DEFAULT '', + `origtime` int(11) unsigned DEFAULT '0', + `duration` int(11) unsigned DEFAULT '0', `mailboxuser` varchar(255) DEFAULT '', `mailboxcontext` varchar(63) DEFAULT '', `recording` longblob, @@ -312,7 +276,7 @@ CREATE TABLE `voicemail_spool` ( KEY `dir` (`dir`), KEY `mailboxuser_idx` (`mailboxuser`), CONSTRAINT `v_s_mailboxuser_ref` FOREIGN KEY (`mailboxuser`) REFERENCES `voicemail_users` (`customer_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `fax_preferences` ( `subscriber_id` int(10) unsigned NOT NULL, @@ -323,7 +287,7 @@ CREATE TABLE `fax_preferences` ( `send_copy` enum('true','false') NOT NULL default 'false', `send_copy_cc` enum('true','false') NOT NULL default 'false', PRIMARY KEY (`subscriber_id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `fax_destinations` ( `id` int(10) unsigned NOT NULL auto_increment, @@ -336,42 +300,12 @@ CREATE TABLE `fax_destinations` ( `status` enum('true','false') NOT NULL default 'false', PRIMARY KEY (`id`), KEY `subscriber_id` (`subscriber_id`) -) ENGINE=InnoDB; - -CREATE TABLE `sems_registrations` ( - `subscriber_id` int(11) NOT NULL, - `registration_status` tinyint(1) NOT NULL DEFAULT '0', - `last_registration` datetime DEFAULT NULL, - `expiry` datetime DEFAULT NULL, - `last_code` smallint(2) DEFAULT NULL, - `last_reason` varchar(256) DEFAULT NULL, - `contacts` varchar(512) DEFAULT NULL, - PRIMARY KEY (`subscriber_id`) -) ENGINE=InnoDB; - -CREATE TABLE `fax_journal` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `subscriber_id` int(10) unsigned NOT NULL DEFAULT '0', - `the_timestamp` int(11) unsigned NOT NULL DEFAULT '0', - `duration` int(11) unsigned NOT NULL DEFAULT '0', - `direction` enum('in','out') NOT NULL DEFAULT 'in', - `peer_number` varchar(255) NOT NULL DEFAULT '', - `peer_name` varchar(255) NOT NULL DEFAULT '', - `pages` int(10) unsigned NOT NULL DEFAULT '0', - `reason` varchar(255) NOT NULL, - `status` varchar(255) NOT NULL DEFAULT '', - `signal_rate` int(10) unsigned NOT NULL DEFAULT '0', - `quality` varchar(255) NOT NULL DEFAULT '', - `filename` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - KEY `selkey` (`subscriber_id`,`direction`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `version` VALUES ('acc',4), - ('lcr_gw',1), - ('lcr_rule_target',1), - ('lcr_rule',1), + ('gw',10), + ('lcr',3), ('domain',1), ('trusted',5), ('location',1004), @@ -381,7 +315,7 @@ INSERT INTO `version` VALUES ('subscriber',6), ('dialog',4), ('dispatcher',3), - ('address',4), + ('address',3), ('dialplan',1); diff --git a/db_scripts/base/0040_create_oss_triggers_kamailio.up b/db_scripts/base/0040_create_oss_triggers_kamailio.up index a08d9969..585a892a 100644 --- a/db_scripts/base/0040_create_oss_triggers_kamailio.up +++ b/db_scripts/base/0040_create_oss_triggers_kamailio.up @@ -10,8 +10,8 @@ CREATE TRIGGER voip_sub_crepl_trig AFTER INSERT ON voip_subscribers SELECT domain INTO subscriber_domain FROM voip_domains where id = NEW.domain_id; - INSERT INTO kamailio.subscriber (username, domain, uuid, password, datetime_created, ha1, ha1b) - VALUES(NEW.username, subscriber_domain, NEW.uuid, NEW.password, now(), + INSERT INTO kamailio.subscriber (username, domain, uuid, timezone, password, datetime_created, ha1, ha1b) + VALUES(NEW.username, subscriber_domain, NEW.uuid, NEW.timezone, NEW.password, now(), MD5(CONCAT(NEW.username, ':', subscriber_domain, ':', NEW.password)), MD5(CONCAT(NEW.username, '@', subscriber_domain, ':', subscriber_domain, ':', NEW.password))); END; @@ -26,7 +26,7 @@ CREATE TRIGGER voip_sub_urepl_trig AFTER UPDATE ON voip_subscribers SELECT domain INTO new_subscriber_domain FROM voip_domains where id = NEW.domain_id; UPDATE kamailio.subscriber SET username = NEW.username, domain = new_subscriber_domain, - uuid = NEW.uuid, password = NEW.password, + uuid = NEW.uuid, timezone = NEW.timezone, password = NEW.password, ha1 = MD5(CONCAT(NEW.username, ':', new_subscriber_domain, ':', NEW.password)), ha1b = MD5(CONCAT(NEW.username, '@', new_subscriber_domain, ':', new_subscriber_domain, ':', NEW.password)) WHERE username = OLD.username @@ -114,56 +114,55 @@ CREATE TRIGGER voip_dba_drepl_trig BEFORE DELETE ON voip_dbaliases CREATE TRIGGER voip_prul_crepl_trig AFTER INSERT ON voip_peer_rules FOR EACH ROW BEGIN + DECLARE prio int(11) unsigned; - INSERT INTO kamailio.lcr_rule (lcr_id, prefix, from_uri, stopper, enabled, group_id) - VALUES(1, NEW.callee_prefix, NEW.caller_prefix, - 0, 1, NEW.group_id); + SELECT priority INTO prio FROM voip_peer_groups + WHERE id = NEW.group_id; - INSERT INTO kamailio.lcr_rule_target (lcr_id, rule_id, gw_id, priority, weight) - SELECT gw.lcr_id, LAST_INSERT_ID(), gw.id, vpg.priority, vph.weight - FROM kamailio.lcr_gw gw - INNER JOIN provisioning.voip_peer_hosts vph ON vph.ip = gw.ip_addr - AND gw.lcr_id = 1 - AND vph.group_id = gw.group_id - INNER JOIN provisioning.voip_peer_groups vpg ON vpg.id = vph.group_id - WHERE vph.group_id = NEW.group_id; + INSERT INTO kamailio.lcr (lcr_id, prefix, from_uri, grp_id, priority) + VALUES(1, NEW.callee_prefix, IF(LENGTH(NEW.caller_prefix), CONCAT('^', NEW.caller_prefix), ''), NEW.group_id, prio); END; | CREATE TRIGGER voip_prul_urepl_trig AFTER UPDATE ON voip_peer_rules FOR EACH ROW BEGIN + DECLARE prio int(11) unsigned; - UPDATE kamailio.lcr_rule - SET prefix = NEW.callee_prefix, from_uri = NEW.caller_prefix - WHERE prefix = OLD.callee_prefix - AND from_uri = OLD.caller_prefix - AND group_id = OLD.group_id; + SELECT priority INTO prio FROM voip_peer_groups + WHERE id = NEW.group_id; + + UPDATE kamailio.lcr SET prefix = NEW.callee_prefix, + from_uri = IF(LENGTH(NEW.caller_prefix), CONCAT('^', NEW.caller_prefix), '') + WHERE grp_id = OLD.group_id + AND prefix = OLD.callee_prefix + AND from_uri = IF(LENGTH(OLD.caller_prefix), CONCAT('^', OLD.caller_prefix), '') + AND priority = prio; END; | -CREATE TRIGGER voip_prul_drepl_trig AFTER DELETE ON voip_peer_rules +CREATE TRIGGER voip_pgrp_urepl_trig AFTER UPDATE ON voip_peer_groups FOR EACH ROW BEGIN - DELETE FROM kamailio.lcr_rule - WHERE prefix = OLD.callee_prefix - AND from_uri = OLD.caller_prefix - AND group_id = OLD.group_id; - - -- foreign key will delete from kamailio.lcr_rule_target + UPDATE kamailio.lcr SET priority = NEW.priority + WHERE grp_id = NEW.id; END; | -CREATE TRIGGER voip_pgrp_urepl_trig AFTER UPDATE ON voip_peer_groups +CREATE TRIGGER voip_prul_drepl_trig AFTER DELETE ON voip_peer_rules FOR EACH ROW BEGIN + DECLARE prio int(11) unsigned; + + SELECT priority INTO prio FROM voip_peer_groups + WHERE id = OLD.group_id; - UPDATE kamailio.lcr_rule_target rt, kamailio.lcr_gw gw - SET rt.priority = NEW.priority - WHERE gw.id = rt.gw_id - AND gw.lcr_id = 1 - AND gw.group_id = NEW.id; + DELETE FROM kamailio.lcr + WHERE grp_id = OLD.group_id AND + prefix = OLD.callee_prefix AND + from_uri = IF(LENGTH(OLD.caller_prefix), CONCAT('^', OLD.caller_prefix), '') AND + priority = prio; END; | @@ -171,8 +170,8 @@ CREATE TRIGGER voip_pgrp_urepl_trig AFTER UPDATE ON voip_peer_groups CREATE TRIGGER voip_pgrp_drepl_trig AFTER DELETE ON voip_peer_groups FOR EACH ROW BEGIN - DELETE FROM kamailio.lcr_rule WHERE group_id = OLD.id; - DELETE FROM kamailio.lcr_gw WHERE group_id = OLD.id; + DELETE FROM kamailio.lcr WHERE grp_id = OLD.id; + DELETE FROM kamailio.gw WHERE grp_id = OLD.id; END; | @@ -180,77 +179,242 @@ CREATE TRIGGER voip_pgrp_drepl_trig AFTER DELETE ON voip_peer_groups CREATE TRIGGER voip_phost_crepl_trig AFTER INSERT ON voip_peer_hosts FOR EACH ROW BEGIN - INSERT INTO kamailio.lcr_gw (lcr_id, gw_name, ip_addr, hostname, port, uri_scheme, transport, strip, flags, group_id) - VALUES(1, NEW.name, NEW.ip, NEW.host, NEW.port, 1, 1, 0, NEW.id, NEW.group_id); - - INSERT INTO kamailio.lcr_rule_target (lcr_id, rule_id, gw_id, priority, weight) - SELECT rule.lcr_id, rule.id, LAST_INSERT_ID(), vpg.priority, NEW.weight - FROM kamailio.lcr_rule rule - INNER JOIN provisioning.voip_peer_groups vpg ON vpg.id = rule.group_id - WHERE vpg.id = NEW.group_id; + INSERT INTO kamailio.gw (lcr_id, gw_name, grp_id, ip_addr, port, weight, + uri_scheme, transport, strip, tag, flags, defunct) VALUES + (1, NEW.name, NEW.group_id, NEW.ip, NEW.port, NEW.weight, + 1, 1, 0, NULL, NEW.id, NULL); END; | CREATE TRIGGER voip_phost_urepl_trig AFTER UPDATE ON voip_peer_hosts FOR EACH ROW BEGIN + + UPDATE kamailio.gw SET gw_name = NEW.name, + ip_addr = NEW.ip, port = NEW.port, weight = NEW.weight, tag = NULL + WHERE grp_id = OLD.group_id AND gw_name = OLD.name AND + ip_addr = OLD.ip AND port = OLD.port AND weight = OLD.weight; - UPDATE kamailio.lcr_gw - SET gw_name = NEW.name, ip_addr = NEW.ip, hostname = NEW.host, port = NEW.port, flags = NEW.id - WHERE lcr_id = 1 AND ip_addr = OLD.ip; + END; +| - UPDATE kamailio.lcr_rule_target rt, kamailio.lcr_gw gw - SET rt.weight = NEW.weight - WHERE gw.id = rt.gw_id - AND gw.lcr_id = 1 - AND gw.group_id = NEW.group_id - AND gw.ip_addr = NEW.ip; +CREATE TRIGGER voip_phost_drepl_trig AFTER DELETE ON voip_peer_hosts + FOR EACH ROW BEGIN + + DELETE FROM kamailio.gw + WHERE grp_id = OLD.group_id AND gw_name = OLD.name AND + ip_addr = OLD.ip AND port = OLD.port AND weight = OLD.weight; + DELETE FROM kamailio.dialplan + WHERE dpid IN (OLD.dp_caller_in_id, OLD.dp_callee_in_id, + OLD.dp_caller_out_id, OLD.dp_callee_out_id); END; | -CREATE TRIGGER voip_phost_drepl_trig AFTER DELETE ON voip_peer_hosts + +CREATE TRIGGER voip_domrw_crepl_trig AFTER INSERT ON voip_domain_rewrites + FOR EACH ROW BEGIN + + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; + DECLARE dp_id int(11) unsigned default 0; + + SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_in' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_in' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_out' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_out' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + + IF NEW.direction = 'in' AND NEW.field = 'caller' THEN + SET dp_id = caller_in_id; + ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN + SET dp_id = callee_in_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN + SET dp_id = caller_out_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN + SET dp_id = callee_out_id; + END IF; + + INSERT INTO kamailio.dialplan (dpid, pr, match_op, match_exp, + match_len, subst_exp, repl_exp, attrs) + VALUES(dp_id, NEW.priority, 1, NEW.match_pattern, 0, NEW.match_pattern, NEW.replace_pattern, ''); + + END; +| + +CREATE TRIGGER voip_domrw_urepl_trig AFTER UPDATE ON voip_domain_rewrites + FOR EACH ROW BEGIN + + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; + DECLARE dp_id int(11) unsigned default 0; + + SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_in' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_in' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_out' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_out' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + + IF NEW.direction = 'in' AND NEW.field = 'caller' THEN + SET dp_id = caller_in_id; + ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN + SET dp_id = callee_in_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN + SET dp_id = caller_out_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN + SET dp_id = callee_out_id; + END IF; + + UPDATE kamailio.dialplan SET match_exp = NEW.match_pattern, + subst_exp = NEW.match_pattern, repl_exp = NEW.replace_pattern, pr = NEW.priority + WHERE dpid = dp_id AND match_exp = OLD.match_pattern AND pr = OLD.priority + AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; + + END; +| + +CREATE TRIGGER voip_domrw_drepl_trig AFTER DELETE ON voip_domain_rewrites FOR EACH ROW BEGIN - DELETE FROM kamailio.lcr_gw - WHERE lcr_id = 1 - AND group_id = OLD.group_id - AND ip_addr = OLD.ip; + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; + DECLARE dp_id int(11) unsigned default 0; - -- foreign key will delete from kamailio.lcr_rule_target + SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_caller_in' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_callee_in' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_caller_out' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp, + voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_callee_out' + AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; + + IF OLD.direction = 'in' AND OLD.field = 'caller' THEN + SET dp_id = caller_in_id; + ELSEIF OLD.direction = 'in' AND OLD.field = 'callee' THEN + SET dp_id = callee_in_id; + ELSEIF OLD.direction = 'out' AND OLD.field = 'caller' THEN + SET dp_id = caller_out_id; + ELSEIF OLD.direction = 'out' AND OLD.field = 'callee' THEN + SET dp_id = callee_out_id; + END IF; + + DELETE FROM kamailio.dialplan + WHERE dpid = dp_id AND match_exp = OLD.match_pattern + AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; END; | -CREATE TRIGGER voip_peerpref_crepl_trig AFTER INSERT ON voip_peer_preferences +CREATE TRIGGER voip_peerrw_crepl_trig AFTER INSERT ON voip_peer_rewrites FOR EACH ROW BEGIN + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; + DECLARE dp_id int(11) unsigned default 0; - INSERT INTO kamailio.peer_preferences - (id, uuid, attribute, type, value, last_modified) - SELECT NEW.id, NEW.peer_host_id, attribute, type, NEW.value, NOW() - FROM provisioning.voip_preferences - WHERE id = NEW.attribute_id; + SELECT dp_caller_in_id, dp_callee_in_id, dp_caller_out_id, dp_callee_out_id + INTO caller_in_id, callee_in_id, caller_out_id, callee_out_id + FROM voip_peer_hosts WHERE id = NEW.peer_id; + + IF NEW.direction = 'in' AND NEW.field = 'caller' THEN + SET dp_id = caller_in_id; + ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN + SET dp_id = callee_in_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN + SET dp_id = caller_out_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN + SET dp_id = callee_out_id; + END IF; + + INSERT INTO kamailio.dialplan (dpid, pr, match_op, match_exp, + match_len, subst_exp, repl_exp, attrs) + VALUES(dp_id, NEW.priority, 1, NEW.match_pattern, 0, NEW.match_pattern, NEW.replace_pattern, ''); END; | -CREATE TRIGGER voip_peerpref_urepl_trig AFTER UPDATE ON voip_peer_preferences +CREATE TRIGGER voip_peerrw_urepl_trig AFTER UPDATE ON voip_peer_rewrites FOR EACH ROW BEGIN + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; + DECLARE dp_id int(11) unsigned default 0; - UPDATE kamailio.peer_preferences pp, provisioning.voip_preferences vp - SET pp.id = NEW.id, pp.uuid = NEW.peer_host_id, pp.type = vp.type, - pp.attribute = vp.attribute, pp.value = NEW.value, pp.last_modified = NOW() - WHERE pp.id = OLD.id - AND vp.id = NEW.attribute_id; + SELECT dp_caller_in_id, dp_callee_in_id, dp_caller_out_id, dp_callee_out_id + INTO caller_in_id, callee_in_id, caller_out_id, callee_out_id + FROM voip_peer_hosts WHERE id = NEW.peer_id; + + IF NEW.direction = 'in' AND NEW.field = 'caller' THEN + SET dp_id = caller_in_id; + ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN + SET dp_id = callee_in_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN + SET dp_id = caller_out_id; + ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN + SET dp_id = callee_out_id; + END IF; + + UPDATE kamailio.dialplan SET match_exp = NEW.match_pattern, + subst_exp = NEW.match_pattern, repl_exp = NEW.replace_pattern, + pr = NEW.priority + WHERE dpid = dp_id AND match_exp = OLD.match_pattern AND pr = OLD.priority + AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; END; | -CREATE TRIGGER voip_peerpref_drepl_trig BEFORE DELETE ON voip_peer_preferences +CREATE TRIGGER voip_peerrw_drepl_trig AFTER DELETE ON voip_peer_rewrites FOR EACH ROW BEGIN + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; + DECLARE dp_id int(11) unsigned default 0; - DELETE FROM kamailio.peer_preferences - WHERE id = OLD.id; + SELECT dp_caller_in_id, dp_callee_in_id, dp_caller_out_id, dp_callee_out_id + INTO caller_in_id, callee_in_id, caller_out_id, callee_out_id + FROM voip_peer_hosts WHERE id = OLD.peer_id; + + IF OLD.direction = 'in' AND OLD.field = 'caller' THEN + SET dp_id = caller_in_id; + ELSEIF OLD.direction = 'in' AND OLD.field = 'callee' THEN + SET dp_id = callee_in_id; + ELSEIF OLD.direction = 'out' AND OLD.field = 'caller' THEN + SET dp_id = caller_out_id; + ELSEIF OLD.direction = 'out' AND OLD.field = 'callee' THEN + SET dp_id = callee_out_id; + END IF; + + DELETE FROM kamailio.dialplan + WHERE dpid = dp_id AND match_exp = OLD.match_pattern + AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; END; | @@ -331,280 +495,58 @@ CREATE TRIGGER voip_usrpref_drepl_trig BEFORE DELETE ON voip_usr_preferences END; | -CREATE TRIGGER voip_rwrules_crepl_trig AFTER INSERT ON voip_rewrite_rules - FOR EACH ROW BEGIN - - DECLARE new_set_id int(11) unsigned; - - SELECT IF(NEW.direction = 'in', IF(NEW.field = 'caller', caller_in_dpid, callee_in_dpid), IF(NEW.field = 'caller', caller_out_dpid, callee_out_dpid)) - INTO new_set_id FROM voip_rewrite_rule_sets WHERE id = NEW.set_id; - - INSERT INTO kamailio.dialplan (dpid,pr,match_op,match_exp,match_len,subst_exp,repl_exp,attrs) - VALUES(new_set_id,NEW.priority,1,NEW.match_pattern,0,NEW.match_pattern,NEW.replace_pattern,''); - - END; -| - -CREATE TRIGGER voip_rwrules_urepl_trig AFTER UPDATE ON voip_rewrite_rules - FOR EACH ROW BEGIN - - DECLARE old_set_id int(11) unsigned; - DECLARE new_set_id int(11) unsigned; - - SELECT IF(OLD.direction = 'in', IF(OLD.field = 'caller', caller_in_dpid, callee_in_dpid), IF(OLD.field = 'caller', caller_out_dpid, callee_out_dpid)) - INTO old_set_id FROM voip_rewrite_rule_sets WHERE id = OLD.set_id; - SELECT IF(NEW.direction = 'in', IF(NEW.field = 'caller', caller_in_dpid, callee_in_dpid), IF(NEW.field = 'caller', caller_out_dpid, callee_out_dpid)) - INTO new_set_id FROM voip_rewrite_rule_sets WHERE id = NEW.set_id; - - UPDATE kamailio.dialplan - SET dpid = new_set_id, - pr = NEW.priority, - match_exp = NEW.match_pattern, - subst_exp = NEW.match_pattern, - repl_exp = NEW.replace_pattern - WHERE dpid = old_set_id - AND pr = OLD.priority - AND match_exp = OLD.match_pattern - AND subst_exp = OLD.match_pattern - AND repl_exp = OLD.replace_pattern; - - END; -| - -CREATE TRIGGER voip_rwrules_drepl_trig BEFORE DELETE ON voip_rewrite_rules - FOR EACH ROW BEGIN - - DECLARE old_set_id int(11) unsigned; - - SELECT IF(OLD.direction = 'in', IF(OLD.field = 'caller', caller_in_dpid, callee_in_dpid), IF(OLD.field = 'caller', caller_out_dpid, callee_out_dpid)) - INTO old_set_id FROM voip_rewrite_rule_sets WHERE id = OLD.set_id; - - DELETE FROM kamailio.dialplan - WHERE dpid = old_set_id - AND pr = OLD.priority - AND match_exp = OLD.match_pattern - AND subst_exp = OLD.match_pattern - AND repl_exp = OLD.replace_pattern; - - END; -| - -CREATE TRIGGER voip_rwrulesets_crepl_trig BEFORE INSERT ON voip_rewrite_rule_sets - FOR EACH ROW BEGIN - - IF NEW.caller_in_dpid IS NULL THEN - INSERT INTO voip_rwrs_sequence VALUES(); - SET NEW.caller_in_dpid = (SELECT LAST_INSERT_ID()); - END IF; - IF NEW.callee_in_dpid IS NULL THEN - INSERT INTO voip_rwrs_sequence VALUES(); - SET NEW.callee_in_dpid = (SELECT LAST_INSERT_ID()); - END IF; - IF NEW.caller_out_dpid IS NULL THEN - INSERT INTO voip_rwrs_sequence VALUES(); - SET NEW.caller_out_dpid = (SELECT LAST_INSERT_ID()); - END IF; - IF NEW.callee_out_dpid IS NULL THEN - INSERT INTO voip_rwrs_sequence VALUES(); - SET NEW.callee_out_dpid = (SELECT LAST_INSERT_ID()); - END IF; - - DELETE a FROM voip_rwrs_sequence a, voip_rwrs_sequence b WHERE a.id < b.id; - - END; -| - -CREATE TRIGGER voip_rwrulesets_urepl_trig AFTER UPDATE ON voip_rewrite_rule_sets +CREATE TRIGGER voip_dom_crepl_trig AFTER INSERT ON voip_domains FOR EACH ROW BEGIN - IF NEW.caller_in_dpid != OLD.caller_in_dpid THEN - UPDATE kamailio.dialplan SET dpid = NEW.caller_in_dpid WHERE dpid = OLD.caller_in_dpid; - UPDATE voip_usr_preferences a, voip_preferences b - SET a.value = NEW.caller_in_dpid - WHERE b.attribute = 'rewrite_caller_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_in_dpid; - UPDATE voip_dom_preferences a, voip_preferences b - SET a.value = NEW.caller_in_dpid - WHERE b.attribute = 'rewrite_caller_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_in_dpid; - UPDATE voip_peer_preferences a, voip_preferences b - SET a.value = NEW.caller_in_dpid - WHERE b.attribute = 'rewrite_caller_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_in_dpid; - END IF; - IF NEW.callee_in_dpid != OLD.callee_in_dpid THEN - UPDATE kamailio.dialplan SET dpid = NEW.callee_in_dpid WHERE dpid = OLD.callee_in_dpid; - UPDATE voip_usr_preferences a, voip_preferences b - SET a.value = NEW.callee_in_dpid - WHERE b.attribute = 'rewrite_callee_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_in_dpid; - UPDATE voip_dom_preferences a, voip_preferences b - SET a.value = NEW.callee_in_dpid - WHERE b.attribute = 'rewrite_callee_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_in_dpid; - UPDATE voip_peer_preferences a, voip_preferences b - SET a.value = NEW.callee_in_dpid - WHERE b.attribute = 'rewrite_callee_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_in_dpid; - END IF; - IF NEW.caller_out_dpid != OLD.caller_out_dpid THEN - UPDATE kamailio.dialplan SET dpid = NEW.caller_out_dpid WHERE dpid = OLD.caller_out_dpid; - UPDATE voip_usr_preferences a, voip_preferences b - SET a.value = NEW.caller_out_dpid - WHERE b.attribute = 'rewrite_caller_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_out_dpid; - UPDATE voip_dom_preferences a, voip_preferences b - SET a.value = NEW.caller_out_dpid - WHERE b.attribute = 'rewrite_caller_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_out_dpid; - UPDATE voip_peer_preferences a, voip_preferences b - SET a.value = NEW.caller_out_dpid - WHERE b.attribute = 'rewrite_caller_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_out_dpid; - END IF; - IF NEW.callee_out_dpid != OLD.callee_out_dpid THEN - UPDATE kamailio.dialplan SET dpid = NEW.callee_out_dpid WHERE dpid = OLD.callee_out_dpid; - UPDATE voip_usr_preferences a, voip_preferences b - SET a.value = NEW.callee_out_dpid - WHERE b.attribute = 'rewrite_callee_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_out_dpid; - UPDATE voip_dom_preferences a, voip_preferences b - SET a.value = NEW.callee_out_dpid - WHERE b.attribute = 'rewrite_callee_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_out_dpid; - UPDATE voip_peer_preferences a, voip_preferences b - SET a.value = NEW.callee_out_dpid - WHERE b.attribute = 'rewrite_callee_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_out_dpid; + IF NEW.local IS TRUE THEN + INSERT INTO kamailio.domain (domain) VALUES(NEW.domain); END IF; END; | -CREATE TRIGGER voip_rwrulesets_drepl_trig BEFORE DELETE ON voip_rewrite_rule_sets - FOR EACH ROW BEGIN - - DELETE a FROM voip_usr_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_caller_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_in_dpid; - DELETE a FROM voip_usr_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_callee_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_in_dpid; - DELETE a FROM voip_usr_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_caller_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_out_dpid; - DELETE a FROM voip_usr_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_callee_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_out_dpid; - - DELETE a FROM voip_dom_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_caller_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_in_dpid; - DELETE a FROM voip_dom_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_callee_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_in_dpid; - DELETE a FROM voip_dom_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_caller_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_out_dpid; - DELETE a FROM voip_dom_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_callee_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_out_dpid; - - DELETE a FROM voip_peer_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_caller_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_in_dpid; - DELETE a FROM voip_peer_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_callee_in_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_in_dpid; - DELETE a FROM voip_peer_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_caller_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.caller_out_dpid; - DELETE a FROM voip_peer_preferences a, voip_preferences b - WHERE b.attribute = 'rewrite_callee_out_dpid' - AND a.attribute_id = b.id - AND a.value = OLD.callee_out_dpid; - - -- work around MySQL bug. the cascaded delete should trigger our - -- voip_dom_preferences delete action, but doesn't - DELETE FROM kamailio.dialplan WHERE dpid = OLD.caller_in_dpid; - DELETE FROM kamailio.dialplan WHERE dpid = OLD.callee_in_dpid; - DELETE FROM kamailio.dialplan WHERE dpid = OLD.caller_out_dpid; - DELETE FROM kamailio.dialplan WHERE dpid = OLD.callee_out_dpid; - - END; -| - -CREATE TRIGGER voip_pref_urepl_trig AFTER UPDATE ON voip_preferences +CREATE TRIGGER voip_dom_urepl_trig AFTER UPDATE ON voip_domains FOR EACH ROW BEGIN - IF OLD.attribute != NEW.attribute THEN - UPDATE kamailio.usr_preferences - SET attribute = NEW.attribute - WHERE attribute = OLD.attribute; - UPDATE kamailio.dom_preferences - SET attribute = NEW.attribute - WHERE attribute = OLD.attribute; - UPDATE kamailio.peer_preferences - SET attribute = NEW.attribute - WHERE attribute = OLD.attribute; + IF NEW.local IS TRUE AND OLD.local IS FALSE THEN + INSERT INTO kamailio.domain (domain) VALUES(NEW.domain); + ELSEIF NEW.local IS FALSE AND OLD.local IS TRUE THEN + DELETE FROM kamailio.domain WHERE domain = OLD.domain; END IF; END; | -CREATE TRIGGER voip_pref_drepl_trig BEFORE DELETE ON voip_preferences - FOR EACH ROW BEGIN - - -- work around MySQL bug. the cascaded delete should trigger our - -- voip_*_preferences delete action, but doesn't - DELETE FROM voip_usr_preferences WHERE attribute_id = OLD.id; - DELETE FROM voip_dom_preferences WHERE attribute_id = OLD.id; - DELETE FROM voip_peer_preferences WHERE attribute_id = OLD.id; - - END; -| - -CREATE TRIGGER voip_dom_crepl_trig AFTER INSERT ON voip_domains +CREATE TRIGGER voip_dom_drepl_trig BEFORE DELETE ON voip_domains FOR EACH ROW BEGIN - INSERT INTO kamailio.domain (domain) VALUES(NEW.domain); - - END; -| + DECLARE caller_in_id int(11) unsigned; + DECLARE callee_in_id int(11) unsigned; + DECLARE caller_out_id int(11) unsigned; + DECLARE callee_out_id int(11) unsigned; -CREATE TRIGGER voip_dom_drepl_trig BEFORE DELETE ON voip_domains - FOR EACH ROW BEGIN + SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp + WHERE vp.attribute = 'dp_dom_caller_in' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; + SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp + WHERE vp.attribute = 'dp_dom_callee_in' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; + SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp + WHERE vp.attribute = 'dp_dom_caller_out' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; + SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp + WHERE vp.attribute = 'dp_dom_callee_out' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; - DELETE FROM kamailio.domain WHERE domain = OLD.domain; + IF OLD.local IS TRUE THEN + DELETE FROM kamailio.domain WHERE domain = OLD.domain; + END IF; + + DELETE FROM kamailio.dialplan WHERE dpid IN + (caller_in_id, callee_in_id, caller_out_id, callee_out_id); -- work around MySQL bug. the cascaded delete should trigger our -- voip_dom_preferences delete action, but doesn't DELETE FROM kamailio.dom_preferences WHERE domain = OLD.domain; -- this will trigger the delete action for each subscriber DELETE FROM provisioning.voip_subscribers WHERE domain_id = OLD.id; + END; | @@ -918,13 +860,3 @@ CREATE TRIGGER voip_aig_drepl_trig BEFORE DELETE ON voip_allowed_ip_groups | DELIMITER ; - --- internal domain and subscribers -INSERT INTO voip_domains (domain) VALUES('voip.sipwise.local'); -INSERT INTO voip_subscribers (username, domain_id, uuid, password, create_timestamp) - SELECT 'no_such_number', id, '9bcb88b6-541a-43da-8fdc-816f5557ff93', MD5(RAND()), NOW() - FROM voip_domains WHERE domain = 'voip.sipwise.local'; -INSERT INTO voip_subscribers (username, domain_id, uuid, password, create_timestamp) - SELECT 'nagios', id, 'ac1697cf-6933-45ef-9abf-b1278054ded0', 'nagios4Sipwise!', NOW() - FROM voip_domains WHERE domain = 'voip.sipwise.local'; - diff --git a/db_scripts/base/0050_create_accounting.up b/db_scripts/base/0050_create_accounting.up index 11aaf2d7..952388a9 100644 --- a/db_scripts/base/0050_create_accounting.up +++ b/db_scripts/base/0050_create_accounting.up @@ -13,45 +13,47 @@ USE accounting; -- create accounting tables -CREATE TABLE `acc` like kamailio.acc; +CREATE TABLE `acc` ( + `id` int(10) unsigned NOT NULL auto_increment, + `method` varchar(16) NOT NULL default '', + `from_tag` varchar(64) NOT NULL default '', + `to_tag` varchar(64) NOT NULL default '', + `callid` varchar(128) NOT NULL default '', + `sip_code` char(3) NOT NULL default '', + `sip_reason` varchar(32) NOT NULL default '', + `time` datetime NOT NULL, + `src_leg` varchar(255) default NULL, + `dst_leg` varchar(255) default NULL, + `server` varchar(64) NOT NULL, + PRIMARY KEY (`id`), + KEY `acc_callid` (`callid`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `cdr` ( `id` int(10) unsigned NOT NULL auto_increment, `update_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `source_user_id` char(36) NOT NULL, `source_provider_id` varchar(255) NOT NULL, - `source_external_subscriber_id` varchar(255) DEFAULT NULL, - `source_external_contract_id` varchar(255) DEFAULT NULL, - `source_account_id` int(11) unsigned NOT NULL DEFAULT '0', `source_user` varchar(255) NOT NULL, `source_domain` varchar(255) NOT NULL, `source_cli` varchar(64) NOT NULL, `source_clir` tinyint(1) NOT NULL default '0', `destination_user_id` char(36) NOT NULL, `destination_provider_id` varchar(255) NOT NULL, - `destination_external_subscriber_id` varchar(255) DEFAULT NULL, - `destination_external_contract_id` varchar(255) DEFAULT NULL, - `destination_account_id` int(11) unsigned NOT NULL DEFAULT '0', `destination_user` varchar(255) NOT NULL, `destination_domain` varchar(255) NOT NULL, `destination_user_dialed` varchar(255) NOT NULL, `destination_user_in` varchar(255) NOT NULL, `destination_domain_in` varchar(255) NOT NULL, - `peer_auth_user` varchar(255) DEFAULT NULL, - `peer_auth_realm` varchar(255) DEFAULT NULL, `call_type` enum('call','cfu','cft','cfb','cfna') NOT NULL default 'call', `call_status` enum('ok','busy','noanswer','cancel','offline','timeout','other') NOT NULL default 'ok', `call_code` char(3) NOT NULL, - `init_time` decimal(13,3) NOT NULL, - `start_time` decimal(13,3) NOT NULL, - `duration` decimal(13,3) NOT NULL, + `start_time` timestamp NOT NULL default '0000-00-00 00:00:00', + `duration` int(10) unsigned NOT NULL, `call_id` varchar(255) NOT NULL, - `carrier_cost` decimal(10,2) default NULL, - `reseller_cost` decimal(10,2) default NULL, - `customer_cost` decimal(10,2) default NULL, - `carrier_free_time` int(10) unsigned DEFAULT NULL, - `reseller_free_time` int(10) unsigned DEFAULT NULL, - `customer_free_time` int(10) unsigned DEFAULT NULL, + `carrier_cost` float default NULL, + `reseller_cost` float default NULL, + `customer_cost` float default NULL, `carrier_billing_fee_id` int(11) unsigned default NULL, `reseller_billing_fee_id` int(11) unsigned default NULL, `customer_billing_fee_id` int(11) unsigned default NULL, @@ -72,19 +74,12 @@ CREATE TABLE `cdr` ( KEY `sprov` (`source_provider_id`), KEY `dprov` (`destination_provider_id`), KEY `kcid` (`call_id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `mark` ( `id` int(10) unsigned NOT NULL auto_increment, `collector` varchar(255) NOT NULL, `acc_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB; +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -CREATE TABLE `prepaid_costs` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `call_id` varchar(255) NOT NULL, - `cost` double NOT NULL, - `free_time_used` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; diff --git a/db_scripts/base/0070_create_sipstats.up b/db_scripts/base/0070_create_sipstats.up deleted file mode 100644 index 7799b2e9..00000000 --- a/db_scripts/base/0070_create_sipstats.up +++ /dev/null @@ -1,38 +0,0 @@ -USE mysql; -DROP DATABASE IF EXISTS sipstats; - -CREATE DATABASE IF NOT EXISTS sipstats CHARACTER SET 'utf8'; - -USE sipstats; - --- create packets tables - -CREATE TABLE `packets` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `timestamp` decimal(17,6) NOT NULL, - `src_mac` binary(6) NOT NULL, - `dst_mac` binary(6) NOT NULL, - `protocol` enum('IPv4','IPv6') NOT NULL, - `src_ip` varchar(39) NOT NULL, - `dst_ip` varchar(39) NOT NULL, - `src_port` smallint(5) unsigned NOT NULL, - `dst_port` smallint(5) unsigned NOT NULL, - `header` blob NOT NULL, - `payload` blob NOT NULL, - `trailer` blob NOT NULL, - `method` varchar(20) NOT NULL, - `cseq_method` varchar(16) NOT NULL, - `call_id` varchar(255) NOT NULL, - `request_uri` varchar(255) NOT NULL, - `from_uri` varchar(255) NOT NULL, - `caller_uuid` varchar(255) NOT NULL, - `callee_uuid` varchar(255) NOT NULL, - `was_fragmented` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`id`,`timestamp`), - KEY `call_id_idx` (`call_id`), - KEY `caller_uuid_idx` (`caller_uuid`), - KEY `callee_uuid_idx` (`callee_uuid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 -PARTITION BY RANGE (FLOOR(`timestamp`)) -(PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = MyISAM); - diff --git a/db_scripts/base/0080_create_carrier.up b/db_scripts/base/0080_create_carrier.up deleted file mode 100644 index ec001ab2..00000000 --- a/db_scripts/base/0080_create_carrier.up +++ /dev/null @@ -1,104 +0,0 @@ --- step out of our billing DB -USE mysql; - --- drop database if it allready exists --- this will drop all tables and triggers -DROP DATABASE IF EXISTS carrier; - --- create DB with utf8 default charset, so we don't have to --- specify charset for each table -CREATE DATABASE carrier CHARACTER SET 'utf8'; - -USE carrier; - -CREATE TABLE `customers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `external_id` varchar(255) NULL default NULL, - `url` varchar(31) NOT NULL, - `shopuser` varchar(31) NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `externalid_idx` (`external_id`), - UNIQUE KEY `shopuser_idx` (`shopuser`) -) ENGINE=InnoDB; - -CREATE TABLE `orders` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `customer_id` int(11) UNSIGNED NOT NULL REFERENCES `customers` (`id`), - PRIMARY KEY (`id`), - KEY `customerid_idx` (`customer_id`), - CONSTRAINT `o_customerid_ref` FOREIGN KEY (`customer_id`) - REFERENCES `customers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `contracts` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `external_id` varchar(255) NULL default NULL, - `url` varchar(31) NULL default NULL, - `customer_id` int(11) UNSIGNED NULL REFERENCES `customers` (`id`), - `sip_uri` varchar(127) NULL default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `externalid_idx` (`external_id`), - KEY `customerid_idx` (`customer_id`), - CONSTRAINT `c_customerid_ref` FOREIGN KEY (`customer_id`) - REFERENCES `customers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `credits` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - PRIMARY KEY (`id`), - KEY `contractid_idx` (`contract_id`), - CONSTRAINT `c_contractid_ref` FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `payments` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `order_id` int(11) UNSIGNED NULL REFERENCES `orders` (`id`), - `credit_id` int(11) UNSIGNED NULL REFERENCES `credits` (`id`), - PRIMARY KEY (`id`), - KEY `orderid_idx` (`order_id`), - CONSTRAINT `p_orderid_ref` FOREIGN KEY (`order_id`) - REFERENCES `orders` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `creditid_idx` (`credit_id`), - CONSTRAINT `p_creditid_ref` FOREIGN KEY (`credit_id`) - REFERENCES `credits` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `subscribers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `external_id` varchar(255) NULL default NULL, - `username` varchar(127) NOT NULL, - `domain` varchar(127) NOT NULL, - `webusername` varchar(127) default NULL, - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - PRIMARY KEY (`id`), - UNIQUE KEY `externalid_idx` (`external_id`), - UNIQUE KEY `usrdom_idx` (`username`, `domain`), - UNIQUE KEY `domwebuser_idx` (`domain`, `webusername`), - KEY `contractid_idx` (`contract_id`), - CONSTRAINT `s_contractid_ref` FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `numbers` ( - `number` varchar(42) NOT NULL, - `subscriber_id` int(11) UNSIGNED NULL REFERENCES `subscribers` (`id`), - PRIMARY KEY `number_idx` (`number`), - KEY `subscriberid_idx` (`subscriber_id`), - CONSTRAINT `n_subscriberid_ref` FOREIGN KEY (`subscriber_id`) - REFERENCES `subscribers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `interceptions` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `url` varchar(31) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; diff --git a/db_scripts/base/0100_grants_dbs.template b/db_scripts/base/0100_grants_dbs.template index b5f25d6b..ff519949 100644 --- a/db_scripts/base/0100_grants_dbs.template +++ b/db_scripts/base/0100_grants_dbs.template @@ -1,53 +1,59 @@ -GRANT SELECT ON mysql.* TO 'nagios'@'localhost' IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.location TO 'nagios'@'localhost' IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON provisioning.voip_subscribers TO 'nagios'@'localhost' IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replicator@"192.168.255.%" IDENTIFIED BY 'PW_REPLICATOR'; -GRANT SELECT ON kamailio.* TO 'kamailioro'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT ALL ON kamailio.* TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON kamailio.location TO 'natping'@'localhost' IDENTIFIED BY 'PW_NATPING'; +GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON mysql.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON mysql.* TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON kamailio.location TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON kamailio.location TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; -#GRANT ALL ON accounting.* TO 'collector'@'localhost' IDENTIFIED BY 'PW_COLLECTOR'; +GRANT SELECT ON kamailio.* TO kamailioro@localhost IDENTIFIED BY 'PW_KAMAILIORW'; +GRANT ALL ON kamailio.* TO kamailio@localhost IDENTIFIED BY 'PW_KAMAILIORW'; +GRANT SELECT ON kamailio.location TO natping@'192.168.255.%' IDENTIFIED BY 'PW_NATPING'; +GRANT SELECT ON kamailio.location TO natping@localhost IDENTIFIED BY 'PW_NATPING'; + +GRANT ALL ON accounting.* TO 'collector'@'localhost' IDENTIFIED BY 'PW_COLLECTOR'; +GRANT ALL ON accounting.* TO 'collector'@'192.168.255.%' IDENTIFIED BY 'PW_COLLECTOR'; GRANT ALL ON accounting.* TO 'mediator'@'localhost' IDENTIFIED BY 'PW_MEDIATOR'; +GRANT ALL ON accounting.* TO 'mediator'@'192.168.255.%' IDENTIFIED BY 'PW_MEDIATOR'; GRANT SELECT ON provisioning.* TO 'mediator'@'localhost' IDENTIFIED BY 'PW_MEDIATOR'; +GRANT SELECT ON provisioning.* TO 'mediator'@'192.168.255.%' IDENTIFIED BY 'PW_MEDIATOR'; GRANT SELECT ON billing.* TO 'mediator'@'localhost' IDENTIFIED BY 'PW_MEDIATOR'; +GRANT SELECT ON billing.* TO 'mediator'@'192.168.255.%' IDENTIFIED BY 'PW_MEDIATOR'; GRANT ALL ON accounting.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; +GRANT ALL ON accounting.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; GRANT ALL ON billing.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; +GRANT ALL ON billing.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL PRIVILEGES ON kamailio.voicemail_users TO 'asterisk'@'localhost' IDENTIFIED BY 'PW_ASTERISK'; -GRANT ALL PRIVILEGES ON kamailio.voicemail_spool TO 'asterisk'@'localhost' IDENTIFIED BY 'PW_ASTERISK'; +GRANT ALL PRIVILEGES ON kamailio.voicemail_users TO asterisk@'192.168.255.%' IDENTIFIED BY 'PW_ASTERISK'; +GRANT ALL PRIVILEGES ON kamailio.voicemail_users TO asterisk@localhost IDENTIFIED BY 'PW_ASTERISK'; +GRANT ALL PRIVILEGES ON kamailio.voicemail_spool TO asterisk@'192.168.255.%' IDENTIFIED BY 'PW_ASTERISK'; +GRANT ALL PRIVILEGES ON kamailio.voicemail_spool TO asterisk@localhost IDENTIFIED BY 'PW_ASTERISK'; GRANT ALL ON provisioning.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; +GRANT ALL ON provisioning.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; GRANT ALL ON kamailio.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON sipstats.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; - - -GRANT SELECT ON accounting.cdr TO 'exporter'@'localhost' IDENTIFIED BY 'PW_EXPORTER'; -GRANT SELECT,INSERT,UPDATE ON accounting.mark TO 'exporter'@'localhost' IDENTIFIED BY 'PW_EXPORTER'; -GRANT SELECT ON billing.billing_zones_history TO 'exporter'@'localhost' IDENTIFIED BY 'PW_EXPORTER'; - -GRANT RELOAD ON *.* TO 'rsyslog'@'localhost' IDENTIFIED BY 'PW_RSYSLOG'; -GRANT ALL on syslog.* TO 'rsyslog'@'localhost' IDENTIFIED BY 'PW_RSYSLOG'; - -GRANT SELECT,INSERT,UPDATE ON accounting.* TO 'rateomat'@'localhost' IDENTIFIED BY 'PW_RATEOMAT'; -GRANT DELETE ON accounting.prepaid_costs TO 'rateomat'@'localhost' IDENTIFIED BY 'PW_RATEOMAT'; -GRANT SELECT,INSERT,UPDATE ON billing.* TO 'rateomat'@'localhost' IDENTIFIED BY 'PW_RATEOMAT'; +GRANT ALL ON kamailio.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; -GRANT SELECT,INSERT,UPDATE ON accounting.* TO 'sems_prepaid'@'localhost' IDENTIFIED BY 'PW_SEMS_PREPAID'; -GRANT SELECT,INSERT,UPDATE ON billing.* TO 'sems_prepaid'@'localhost' IDENTIFIED BY 'PW_SEMS_PREPAID'; +GRANT SELECT ON powerdns.* TO pdns@'192.168.255.%' IDENTIFIED BY 'dns4Sipwise!'; -GRANT ALL PRIVILEGES ON *.* TO 'sipwise'@'localhost' IDENTIFIED BY 'PW_SIPWISE' WITH GRANT OPTION; +GRANT SELECT ON accounting.cdr TO exporter@'192.168.255.%' IDENTIFIED BY 'PW_EXPORTER'; +GRANT SELECT ON accounting.cdr TO exporter@localhost IDENTIFIED BY 'PW_EXPORTER'; +GRANT SELECT,INSERT,UPDATE ON accounting.mark TO exporter@'192.168.255.%' IDENTIFIED BY 'PW_EXPORTER'; +GRANT SELECT,INSERT,UPDATE ON accounting.mark TO exporter@localhost IDENTIFIED BY 'PW_EXPORTER'; -GRANT ALL PRIVILEGES ON kamailio.* to 'dbcleaner'@'localhost' IDENTIFIED BY 'PW_CLEANUP_TOOLS'; -GRANT ALL PRIVILEGES ON accounting.* to 'dbcleaner'@'localhost' IDENTIFIED BY 'PW_CLEANUP_TOOLS'; +GRANT RELOAD ON *.* TO rsyslog@localhost IDENTIFIED BY 'PW_RSYSLOG'; +GRANT ALL on syslog.* TO rsyslog@localhost IDENTIFIED BY 'PW_RSYSLOG'; -GRANT SELECT ON provisioning.* to 'hylafax'@'localhost' IDENTIFIED BY 'PW_HYLAFAX'; +GRANT SELECT,INSERT,UPDATE ON accounting.* TO rateomat@'192.168.255.%' IDENTIFIED BY 'PW_RATEOMAT'; +GRANT SELECT,INSERT,UPDATE ON accounting.* TO rateomat@localhost IDENTIFIED BY 'PW_RATEOMAT'; +GRANT SELECT,INSERT,UPDATE ON billing.* TO rateomat@'192.168.255.%' IDENTIFIED BY 'PW_RATEOMAT'; +GRANT SELECT,INSERT,UPDATE ON billing.* TO rateomat@localhost IDENTIFIED BY 'PW_RATEOMAT'; -GRANT ALL ON sipstats.* to 'voisniff'@'localhost' IDENTIFIED BY 'PW_VOISNIFF'; +GRANT ALL PRIVILEGES ON *.* TO sipwise@localhost IDENTIFIED BY 'PW_SIPWISE' WITH GRANT OPTION; -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO 'replicator'@'sp1' IDENTIFIED BY 'PW_REPLICATOR'; -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO 'replicator'@'sp2' IDENTIFIED BY 'PW_REPLICATOR'; -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO 'nagios'@'sp1' IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO 'nagios'@'sp2' IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO 'nagios'@'localhost' IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT ALL PRIVILEGES ON kamailio.* to dbcleaner@localhost IDENTIFIED BY 'PW_CLEANUP_TOOLS'; +GRANT ALL PRIVILEGES ON kamailio.* to dbcleaner@'192.168.255.%' IDENTIFIED BY 'PW_CLEANUP_TOOLS'; +GRANT ALL PRIVILEGES ON accounting.* to dbcleaner@localhost IDENTIFIED BY 'PW_CLEANUP_TOOLS'; +GRANT ALL PRIVILEGES ON accounting.* to dbcleaner@'192.168.255.%' IDENTIFIED BY 'PW_CLEANUP_TOOLS'; diff --git a/db_scripts/base/0110_grants_proxies_kamailio.template b/db_scripts/base/0110_grants_proxies_kamailio.template index 68ab7f28..eec8f62d 100644 --- a/db_scripts/base/0110_grants_proxies_kamailio.template +++ b/db_scripts/base/0110_grants_proxies_kamailio.template @@ -1,18 +1,11 @@ -GRANT SELECT ON mysql.* TO 'nagios'@'localhost' IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.location TO 'nagios'@'localhost' IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON mysql.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON mysql.* TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON kamailio.location TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; +GRANT SELECT ON kamailio.location TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.* TO 'kamailioro'@'localhost' IDENTIFIED BY 'PW_KAMAILIORO'; -GRANT ALL ON kamailio.* TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_peer_hosts TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_cf_destination_sets TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_cf_destinations TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_cf_periods TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_cf_time_sets TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_cf_mappings TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON billing.ncos_levels TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON billing.ncos_lnp_list TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON billing.ncos_pattern_list TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON billing.lnp_numbers TO 'kamailio'@'localhost' IDENTIFIED BY 'PW_KAMAILIORW'; +GRANT SELECT ON kamailio.* TO kamailioro@localhost IDENTIFIED BY 'PW_KAMAILIORO'; +GRANT ALL ON kamailio.* TO kamailio@localhost IDENTIFIED BY 'PW_KAMAILIORW'; +GRANT SELECT ON provisioning.voip_peer_hosts TO kamailio@localhost IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON kamailio.* to 'hylafax'@'localhost' IDENTIFIED BY 'PW_HYLAFAX'; -GRANT INSERT ON kamailio.fax_journal to 'hylafax'@'localhost' IDENTIFIED BY 'PW_HYLAFAX'; diff --git a/db_scripts/base/3955.down b/db_scripts/base/3955.down deleted file mode 100644 index 4a3cbf06..00000000 --- a/db_scripts/base/3955.down +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE provisioning.voip_preferences MODIFY COLUMN `type` tinyint(3) NOT NULL; -ALTER TABLE provisioning.voip_preferences DROP COLUMN `data_type`; diff --git a/db_scripts/base/3955.up b/db_scripts/base/3955.up deleted file mode 100644 index b95c28fe..00000000 --- a/db_scripts/base/3955.up +++ /dev/null @@ -1,18 +0,0 @@ -ALTER TABLE provisioning.voip_preferences MODIFY COLUMN `type` tinyint(3) NOT NULL default 0; -ALTER TABLE provisioning.voip_preferences ADD COLUMN `data_type` enum('bool','int','string') NOT NULL default 'string'; - -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'block_in_mode'; -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'block_in_clir'; -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'block_out_mode'; -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'adm_block_in_mode'; -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'adm_block_in_clir'; -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'adm_block_out_mode'; -UPDATE provisioning.voip_preferences SET data_type = 'bool' where attribute = 'clir'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'lock'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'ringtimeout'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'ncos_id'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'adm_ncos_id'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'dp_dom_caller_in'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'dp_dom_callee_in'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'dp_dom_caller_out'; -UPDATE provisioning.voip_preferences SET data_type = 'int' where attribute = 'dp_dom_callee_out'; diff --git a/db_scripts/base/6424.up b/db_scripts/base/6424.up index 19edace6..38e3f85d 100644 --- a/db_scripts/base/6424.up +++ b/db_scripts/base/6424.up @@ -37,11 +37,11 @@ ALTER TABLE `acc` MODIFY `sip_code` varchar(3) CHARACTER SET utf8 NOT NULL DEFAU ALTER TABLE `acc` MODIFY `sip_reason` varchar(128) CHARACTER SET utf8 NOT NULL DEFAULT ''; ALTER TABLE `acc` MODIFY `src_leg` varchar(2048) CHARACTER SET utf8 default NULL; ALTER TABLE `acc` MODIFY `dst_leg` varchar(2048) CHARACTER SET utf8 default NULL; -ALTER TABLE `acc` MODIFY `dst_user` varchar(64) CHARACTER SET utf8 NOT NULL default ''; -ALTER TABLE `acc` MODIFY `dst_ouser` varchar(64) CHARACTER SET utf8 NOT NULL default ''; -ALTER TABLE `acc` MODIFY `dst_domain` varchar(128) CHARACTER SET utf8 NOT NULL default ''; -ALTER TABLE `acc` MODIFY `src_user` varchar(64) CHARACTER SET utf8 NOT NULL default ''; -ALTER TABLE `acc` MODIFY `src_domain` varchar(128) CHARACTER SET utf8 NOT NULL default ''; +#ALTER TABLE `acc` MODIFY `dst_user` varchar(64) CHARACTER SET utf8 NOT NULL default ''; +#ALTER TABLE `acc` MODIFY `dst_ouser` varchar(64) CHARACTER SET utf8 NOT NULL default ''; +#ALTER TABLE `acc` MODIFY `dst_domain` varchar(128) CHARACTER SET utf8 NOT NULL default ''; +#ALTER TABLE `acc` MODIFY `src_user` varchar(64) CHARACTER SET utf8 NOT NULL default ''; +#ALTER TABLE `acc` MODIFY `src_domain` varchar(128) CHARACTER SET utf8 NOT NULL default ''; ALTER TABLE `acc_backup` CONVERT TO CHARACTER SET utf8; ALTER TABLE `acc_trash` CONVERT TO CHARACTER SET utf8;