summaryrefslogtreecommitdiffstats
path: root/main/kamailio
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-05-27 11:16:40 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-05-27 11:16:40 +0000
commit9be2ab52dcb8e6f2863a79374e995db437fb6240 (patch)
tree7e9dbcd1eb41ab0dd12483a1c7cccf110092adca /main/kamailio
parent42621152fa4fe37326c199558c5d1f89dfd42794 (diff)
downloadaports-9be2ab52dcb8e6f2863a79374e995db437fb6240.tar.bz2
aports-9be2ab52dcb8e6f2863a79374e995db437fb6240.tar.xz
main/kamailio: sqlite subpkg and cleanup kamctl db scripts
The kamctl db scripts belongs to respective db package.
Diffstat (limited to 'main/kamailio')
-rw-r--r--main/kamailio/0001-utils-Install-the-sqlite-scripts.patch66
-rw-r--r--main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch1223
-rw-r--r--main/kamailio/APKBUILD35
3 files changed, 1319 insertions, 5 deletions
diff --git a/main/kamailio/0001-utils-Install-the-sqlite-scripts.patch b/main/kamailio/0001-utils-Install-the-sqlite-scripts.patch
new file mode 100644
index 000000000..bf5304bd1
--- /dev/null
+++ b/main/kamailio/0001-utils-Install-the-sqlite-scripts.patch
@@ -0,0 +1,66 @@
+From 3ced6fc0e5298ac6f2f6dade4d564078ec586ebf Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 26 May 2011 14:04:26 +0000
+Subject: [PATCH] utils: Install the sqlite scripts
+
+Fix the makefiles to actually install the sqlite scripts
+---
+ modules_k/db_sqlite/Makefile | 10 ++++++++++
+ utils/kamctl/Makefile | 23 +++++++++++++++++++++++
+ 2 files changed, 33 insertions(+), 0 deletions(-)
+
+diff --git a/modules_k/db_sqlite/Makefile b/modules_k/db_sqlite/Makefile
+index 9a75593..1f1dd2d 100644
+--- a/modules_k/db_sqlite/Makefile
++++ b/modules_k/db_sqlite/Makefile
+@@ -13,3 +13,13 @@ DEFS+=-DOPENSER_MOD_INTERFACE
+ SERLIBPATH=../../lib
+ SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
+ include ../../Makefile.modules
++
++ifeq ($(INSTALL_FLAVOUR),kamailio)
++# extra install for kamailio
++
++install-sqlite-scripts: $(bin_prefix)/$(bin_dir)
++ SQLITEON=yes make -C ../../utils/kamctl/ install-modules
++
++install-scripts: install-sqlite-scripts
++
++endif # INSTALL_FLAVOUR
+diff --git a/utils/kamctl/Makefile b/utils/kamctl/Makefile
+index 0f2643b..8b0f790 100644
+--- a/utils/kamctl/Makefile
++++ b/utils/kamctl/Makefile
+@@ -245,6 +245,29 @@ install-modules: $(bin_prefix)/$(bin_dir)
+ fi ;\
+ done ;\
+ fi
++ # install sqlite stuff
++ if [ "$(SQLITEON)" = "yes" ]; then \
++ mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
++ sed -e "s#/usr/local/sbin#$(bin_target)#g" \
++ < kamctl.pgsql > /tmp/kamctl.sqlite ; \
++ $(INSTALL_CFG) /tmp/kamctl.sqlite \
++ $(modules_prefix)/$(lib_dir)/kamctl/kamctl.sqlite ; \
++ rm -fr /tmp/kamctl.sqlite ; \
++ sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
++ < kamdbctl.sqlite > /tmp/kamdbctl.sqlite ; \
++ $(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.sqlite ; \
++ $(INSTALL_CFG) /tmp/kamdbctl.sqlite $(modules_prefix)/$(lib_dir)/kamctl/ ; \
++ rm -fr /tmp/kamdbctl.sqlite ; \
++ mkdir -p $(data_prefix)/$(data_dir)/sqlite ; \
++ for FILE in $(wildcard sqlite/*) ; do \
++ if [ -f $$FILE ] ; then \
++ $(INSTALL_TOUCH) $$FILE \
++ $(data_prefix)/$(data_dir)/sqlite/`basename "$$FILE"` ; \
++ $(INSTALL_CFG) $$FILE \
++ $(data_prefix)/$(data_dir)/sqlite/`basename "$$FILE"` ; \
++ fi ;\
++ done ; \
++ fi
+
+
+ $(cfg_prefix)/$(cfg_dir):
+--
+1.7.4.5
+
diff --git a/main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch b/main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
new file mode 100644
index 000000000..30525faf8
--- /dev/null
+++ b/main/kamailio/0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
@@ -0,0 +1,1223 @@
+From 215a55e097c07b497747caf2a04c65cb11d783c6 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Thu, 26 May 2011 07:07:19 +0000
+Subject: [PATCH] utils: add sqlite support to kamctl/kamdbctl
+
+I basically copied the postgrersql scripts and simplified them a bit
+---
+ utils/kamctl/kamctl | 6 +
+ utils/kamctl/kamctl.sqlite | 51 +++++++++
+ utils/kamctl/kamctlrc | 6 +-
+ utils/kamctl/kamdbctl | 13 ++
+ utils/kamctl/kamdbctl.sqlite | 152 ++++++++++++++++++++++++++
+ utils/kamctl/sqlite/acc-create.sql | 28 +++++
+ utils/kamctl/sqlite/alias_db-create.sql | 12 ++
+ utils/kamctl/sqlite/auth_db-create.sql | 15 +++
+ utils/kamctl/sqlite/avpops-create.sql | 15 +++
+ utils/kamctl/sqlite/carrierroute-create.sql | 42 +++++++
+ utils/kamctl/sqlite/cpl-create.sql | 10 ++
+ utils/kamctl/sqlite/dialog-create.sql | 29 +++++
+ utils/kamctl/sqlite/dialplan-create.sql | 13 ++
+ utils/kamctl/sqlite/dispatcher-create.sql | 11 ++
+ utils/kamctl/sqlite/domain-create.sql | 8 ++
+ utils/kamctl/sqlite/domainpolicy-create.sql | 13 ++
+ utils/kamctl/sqlite/drouting-create.sql | 39 +++++++
+ utils/kamctl/sqlite/group-create.sql | 19 +++
+ utils/kamctl/sqlite/htable-create.sql | 9 ++
+ utils/kamctl/sqlite/imc-create.sql | 19 +++
+ utils/kamctl/sqlite/lcr-create.sql | 43 +++++++
+ utils/kamctl/sqlite/matrix-create.sql | 9 ++
+ utils/kamctl/sqlite/msilo-create.sql | 16 +++
+ utils/kamctl/sqlite/mtree-create.sql | 8 ++
+ utils/kamctl/sqlite/pdt-create.sql | 9 ++
+ utils/kamctl/sqlite/permissions-create.sql | 21 ++++
+ utils/kamctl/sqlite/presence-create.sql | 92 ++++++++++++++++
+ utils/kamctl/sqlite/purple-create.sql | 9 ++
+ utils/kamctl/sqlite/registrar-create.sql | 22 ++++
+ utils/kamctl/sqlite/rls-create.sql | 42 +++++++
+ utils/kamctl/sqlite/siptrace-create.sql | 20 ++++
+ utils/kamctl/sqlite/speeddial-create.sql | 14 +++
+ utils/kamctl/sqlite/standard-create.sql | 5 +
+ utils/kamctl/sqlite/uac-create.sql | 16 +++
+ utils/kamctl/sqlite/uri_db-create.sql | 10 ++
+ utils/kamctl/sqlite/userblacklist-create.sql | 21 ++++
+ utils/kamctl/sqlite/usrloc-create.sql | 22 ++++
+ 37 files changed, 887 insertions(+), 2 deletions(-)
+ create mode 100644 utils/kamctl/kamctl.sqlite
+ create mode 100644 utils/kamctl/kamdbctl.sqlite
+ create mode 100644 utils/kamctl/sqlite/acc-create.sql
+ create mode 100644 utils/kamctl/sqlite/alias_db-create.sql
+ create mode 100644 utils/kamctl/sqlite/auth_db-create.sql
+ create mode 100644 utils/kamctl/sqlite/avpops-create.sql
+ create mode 100644 utils/kamctl/sqlite/carrierroute-create.sql
+ create mode 100644 utils/kamctl/sqlite/cpl-create.sql
+ create mode 100644 utils/kamctl/sqlite/dialog-create.sql
+ create mode 100644 utils/kamctl/sqlite/dialplan-create.sql
+ create mode 100644 utils/kamctl/sqlite/dispatcher-create.sql
+ create mode 100644 utils/kamctl/sqlite/domain-create.sql
+ create mode 100644 utils/kamctl/sqlite/domainpolicy-create.sql
+ create mode 100644 utils/kamctl/sqlite/drouting-create.sql
+ create mode 100644 utils/kamctl/sqlite/group-create.sql
+ create mode 100644 utils/kamctl/sqlite/htable-create.sql
+ create mode 100644 utils/kamctl/sqlite/imc-create.sql
+ create mode 100644 utils/kamctl/sqlite/lcr-create.sql
+ create mode 100644 utils/kamctl/sqlite/matrix-create.sql
+ create mode 100644 utils/kamctl/sqlite/msilo-create.sql
+ create mode 100644 utils/kamctl/sqlite/mtree-create.sql
+ create mode 100644 utils/kamctl/sqlite/pdt-create.sql
+ create mode 100644 utils/kamctl/sqlite/permissions-create.sql
+ create mode 100644 utils/kamctl/sqlite/presence-create.sql
+ create mode 100644 utils/kamctl/sqlite/purple-create.sql
+ create mode 100644 utils/kamctl/sqlite/registrar-create.sql
+ create mode 100644 utils/kamctl/sqlite/rls-create.sql
+ create mode 100644 utils/kamctl/sqlite/siptrace-create.sql
+ create mode 100644 utils/kamctl/sqlite/speeddial-create.sql
+ create mode 100644 utils/kamctl/sqlite/standard-create.sql
+ create mode 100644 utils/kamctl/sqlite/uac-create.sql
+ create mode 100644 utils/kamctl/sqlite/uri_db-create.sql
+ create mode 100644 utils/kamctl/sqlite/userblacklist-create.sql
+ create mode 100644 utils/kamctl/sqlite/usrloc-create.sql
+
+diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
+index 2ec550a..c548849 100755
+--- a/utils/kamctl/kamctl
++++ b/utils/kamctl/kamctl
+@@ -124,6 +124,12 @@ case $DBENGINE in
+ DBENGINELOADED=1
+ fi
+ ;;
++ SQLITE|sqlite)
++ if [ -f "$MYLIBDIR/kamctl.sqlite" ]; then
++ . "$MYLIBDIR/kamctl.sqlite"
++ DBENGINELOADED=1
++ fi
++ ;;
+
+ esac
+
+diff --git a/utils/kamctl/kamctl.sqlite b/utils/kamctl/kamctl.sqlite
+new file mode 100644
+index 0000000..8c3eb21
+--- /dev/null
++++ b/utils/kamctl/kamctl.sqlite
+@@ -0,0 +1,51 @@
++#
++# $Id$
++#
++# control tool for maintaining Kamailio
++#
++#===================================================================
++
++##### ----------------------------------------------- #####
++### SQLITE specific variables and functions
++#
++
++##### ----------------------------------------------- #####
++### load SQL base
++#
++if [ -f "$MYLIBDIR/kamctl.sqlbase" ]; then
++ . "$MYLIBDIR/kamctl.sqlbase"
++else
++ echo "Cannot load SQL core functions '$MYLIBDIR/kamctl.sqlbase' - exiting ..."
++ exit -1
++fi
++
++DBNAME=$DB_PATH
++
++##### ----------------------------------------------- #####
++### binaries
++if [ -z "$SQLITE" ] ; then
++ locate_tool sqlite3
++ if [ -z "$TOOLPATH" ] ; then
++ echo "error: 'sqlite3' tool not found: set SQLITE variable to correct tool path"
++ exit
++ fi
++ SQLITE="$TOOLPATH"
++fi
++
++
++# input: sql query, optional sqlite3 command-line params
++sqlite_query() {
++ # if password not yet queried, query it now
++ mecho "sqlite_query: $SQLITE $2 $DBNAME $1"
++ $SQLITE $2 $DBNAME "$1"
++}
++
++# input: sql query, optional sqlite3 command-line params
++sqlite_ro_query() {
++ sqlite_query "$@"
++}
++
++DBCMD=sqlite_query
++DBROCMD=sqlite_ro_query
++DBRAWPARAMS=
++
+diff --git a/utils/kamctl/kamctlrc b/utils/kamctl/kamctlrc
+index 5e888bd..ceb6f54 100644
+--- a/utils/kamctl/kamctlrc
++++ b/utils/kamctl/kamctlrc
+@@ -12,7 +12,9 @@
+ ## chrooted directory
+ # $CHROOT_DIR="/path/to/chrooted/directory"
+
+-## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT, by default none is loaded
++## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE
++# by default none is loaded
++#
+ # If you want to setup a database with kamdbctl, you must at least specify
+ # this parameter.
+ # DBENGINE=MYSQL
+@@ -23,7 +25,7 @@
+ ## database name (for ORACLE this is TNS name)
+ # DBNAME=openser
+
+-# database path used by dbtext or db_berkeley
++# database path used by dbtext, db_berkeley or sqlite
+ # DB_PATH="/usr/local/etc/kamailio/dbtext"
+
+ ## database read/write user
+diff --git a/utils/kamctl/kamdbctl b/utils/kamctl/kamdbctl
+index c04bebd..d60f10f 100755
+--- a/utils/kamctl/kamdbctl
++++ b/utils/kamctl/kamdbctl
+@@ -108,6 +108,15 @@ case $DBENGINE in
+ merr "could not load the script in $MYLIBDIR/kamdbctl.db_berkeley for database engine $DBENGINE"
+ fi
+ ;;
++ SQLITE|sqlite)
++ if [ -f "$MYLIBDIR/kamdbctl.sqlite" ]; then
++ . "$MYLIBDIR/kamdbctl.sqlite"
++ USED_DBENGINE="sqlite"
++ DBNAME=$DB_PATH
++ else
++ merr "could not load the script in $MYLIBDIR/kamdbctl.sqlite for database engine $DBENGINE"
++ fi
++ ;;
+ esac
+
+ if [ -z "$USED_DBENGINE" ] ; then
+@@ -194,6 +203,10 @@ case $1 in
+ usage
+ exit 1
+ fi
++ if [ "$USED_DBENGINE" = "sqlite" ]; then
++ cp $DB_PATH $1
++ exit $?
++ fi
+ tmp_file=`mktemp /tmp/kamdbctl.XXXXXXXXXX` || exit 1
+ openser_dump $DBNAME $tmp_file
+ ret=$?
+diff --git a/utils/kamctl/kamdbctl.sqlite b/utils/kamctl/kamdbctl.sqlite
+new file mode 100644
+index 0000000..ecb51aa
+--- /dev/null
++++ b/utils/kamctl/kamdbctl.sqlite
+@@ -0,0 +1,152 @@
++# $Id$
++#
++# Script for adding and dropping Kamailio sqlite tables
++#
++
++# path to the database schemas
++DATA_DIR="/usr/local/share/kamailio"
++if [ -d "$DATA_DIR/sqlite" ] ; then
++ DB_SCHEMA="$DATA_DIR/sqlite"
++else
++ DB_SCHEMA="./sqlite"
++fi
++
++#################################################################
++# config vars
++#################################################################
++
++CMD="sqlite3"
++DUMP_CMD="sql_dump"
++#################################################################
++
++sql_dump()
++{
++ $CMD ${1:-$DB_PATH} .dump
++}
++
++# execute sql command with optional db name
++sql_query()
++{
++ $CMD "$@"
++}
++
++
++openser_drop() # pars: <database name>
++{
++if [ $# -ne 1 ] ; then
++ merr "openser_drop function takes one param"
++ exit 1
++fi
++
++if ! rm $1; then
++ merr "Dropping database $1 failed!"
++ exit 1
++fi
++
++minfo "Database $1 dropped"
++} #openser_drop
++
++
++openser_create () # pars: <database name>
++{
++if [ $# -ne 1 ] ; then
++ merr "openser_create function takes one param"
++ exit 1
++fi
++
++minfo "creating database $1 ..."
++
++if [ $? -ne 0 ] ; then
++ merr "Creating database failed!"
++ exit 1
++fi
++
++#sql_query "$1" "CREATE FUNCTION "concat" (text,text) RETURNS text AS 'SELECT \$1 || \$2;' LANGUAGE 'sql';
++# CREATE FUNCTION "rand" () RETURNS double precision AS 'SELECT random();' LANGUAGE 'sql';"
++# emulate mysql proprietary functions used by the lcr module in postgresql
++
++#if [ $? -ne 0 ] ; then
++# merr "Creating mysql emulation functions failed!"
++# exit 1
++#fi
++
++for TABLE in $STANDARD_MODULES; do
++ mdbg "Creating core table: $TABLE"
++ sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
++ if [ $? -ne 0 ] ; then
++ merr "Creating core tables failed!"
++ exit 1
++ fi
++done
++
++if [ -e $DB_SCHEMA/extensions-create.sql ]
++then
++ minfo "Creating custom extensions tables"
++ sql_query $1 < $DB_SCHEMA/extensions-create.sql
++ if [ $? -ne 0 ] ; then
++ merr "Creating custom extensions tables failed!"
++ exit 1
++ fi
++fi
++
++minfo "Core Kamailio tables succesfully created."
++
++get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
++if [ "$ANSWER" = "y" ]; then
++ presence_create $1
++fi
++
++get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
++if [ "$ANSWER" = "y" ]; then
++ extra_create $1
++fi
++} # openser_create
++
++
++presence_create () # pars: <database name>
++{
++if [ $# -ne 1 ] ; then
++ merr "presence_create function takes one param"
++ exit 1
++fi
++
++minfo "creating presence tables into $1 ..."
++
++sql_query "$1" < $DB_SCHEMA/presence-create.sql
++
++if [ $? -ne 0 ] ; then
++ merr "Failed to create presence tables!"
++ exit 1
++fi
++
++sql_query "$1" < $DB_SCHEMA/rls-create.sql
++
++if [ $? -ne 0 ] ; then
++ merr "Failed to create rls-presence tables!"
++ exit 1
++fi
++
++minfo "Presence tables succesfully created."
++} # end presence_create
++
++
++extra_create () # pars: <database name>
++{
++if [ $# -ne 1 ] ; then
++ merr "extra_create function takes one param"
++ exit 1
++fi
++
++minfo "creating extra tables into $1 ..."
++
++for TABLE in $EXTRA_MODULES; do
++ mdbg "Creating extra table: $TABLE"
++ sql_query "$1" < $DB_SCHEMA/$TABLE-create.sql
++ if [ $? -ne 0 ] ; then
++ merr "Creating extra tables failed!"
++ exit 1
++ fi
++done
++
++minfo "Extra tables succesfully created."
++} # end extra_create
+diff --git a/utils/kamctl/sqlite/acc-create.sql b/utils/kamctl/sqlite/acc-create.sql
+new file mode 100644
+index 0000000..4d23363
+--- /dev/null
++++ b/utils/kamctl/sqlite/acc-create.sql
+@@ -0,0 +1,28 @@
++INSERT INTO version (table_name, table_version) values ('acc','4');
++CREATE TABLE acc (
++ id INTEGER PRIMARY KEY NOT NULL,
++ method VARCHAR(16) DEFAULT '' NOT NULL,
++ from_tag VARCHAR(64) DEFAULT '' NOT NULL,
++ to_tag VARCHAR(64) DEFAULT '' NOT NULL,
++ callid VARCHAR(64) DEFAULT '' NOT NULL,
++ sip_code VARCHAR(3) DEFAULT '' NOT NULL,
++ sip_reason VARCHAR(32) DEFAULT '' NOT NULL,
++ time TIMESTAMP WITHOUT TIME ZONE NOT NULL
++);
++
++CREATE INDEX acc_callid_idx ON acc (callid);
++
++INSERT INTO version (table_name, table_version) values ('missed_calls','3');
++CREATE TABLE missed_calls (
++ id INTEGER PRIMARY KEY NOT NULL,
++ method VARCHAR(16) DEFAULT '' NOT NULL,
++ from_tag VARCHAR(64) DEFAULT '' NOT NULL,
++ to_tag VARCHAR(64) DEFAULT '' NOT NULL,
++ callid VARCHAR(64) DEFAULT '' NOT NULL,
++ sip_code VARCHAR(3) DEFAULT '' NOT NULL,
++ sip_reason VARCHAR(32) DEFAULT '' NOT NULL,
++ time TIMESTAMP WITHOUT TIME ZONE NOT NULL
++);
++
++CREATE INDEX missed_calls_callid_idx ON missed_calls (callid);
++
+diff --git a/utils/kamctl/sqlite/alias_db-create.sql b/utils/kamctl/sqlite/alias_db-create.sql
+new file mode 100644
+index 0000000..90656e9
+--- /dev/null
++++ b/utils/kamctl/sqlite/alias_db-create.sql
+@@ -0,0 +1,12 @@
++INSERT INTO version (table_name, table_version) values ('dbaliases','1');
++CREATE TABLE dbaliases (
++ id INTEGER PRIMARY KEY NOT NULL,
++ alias_username VARCHAR(64) DEFAULT '' NOT NULL,
++ alias_domain VARCHAR(64) DEFAULT '' NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ CONSTRAINT dbaliases_alias_idx UNIQUE (alias_username, alias_domain)
++);
++
++CREATE INDEX dbaliases_target_idx ON dbaliases (username, domain);
++
+diff --git a/utils/kamctl/sqlite/auth_db-create.sql b/utils/kamctl/sqlite/auth_db-create.sql
+new file mode 100644
+index 0000000..7d6d1f8
+--- /dev/null
++++ b/utils/kamctl/sqlite/auth_db-create.sql
+@@ -0,0 +1,15 @@
++INSERT INTO version (table_name, table_version) values ('subscriber','6');
++CREATE TABLE subscriber (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ password VARCHAR(25) DEFAULT '' NOT NULL,
++ email_address VARCHAR(64) DEFAULT '' NOT NULL,
++ ha1 VARCHAR(64) DEFAULT '' NOT NULL,
++ ha1b VARCHAR(64) DEFAULT '' NOT NULL,
++ rpid VARCHAR(64) DEFAULT NULL,
++ CONSTRAINT subscriber_account_idx UNIQUE (username, domain)
++);
++
++CREATE INDEX subscriber_username_idx ON subscriber (username);
++
+diff --git a/utils/kamctl/sqlite/avpops-create.sql b/utils/kamctl/sqlite/avpops-create.sql
+new file mode 100644
+index 0000000..007ecb5
+--- /dev/null
++++ b/utils/kamctl/sqlite/avpops-create.sql
+@@ -0,0 +1,15 @@
++INSERT INTO version (table_name, table_version) values ('usr_preferences','2');
++CREATE TABLE usr_preferences (
++ id INTEGER PRIMARY KEY NOT NULL,
++ uuid VARCHAR(64) DEFAULT '' NOT NULL,
++ username VARCHAR(128) DEFAULT 0 NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ attribute VARCHAR(32) DEFAULT '' NOT NULL,
++ type INTEGER DEFAULT 0 NOT NULL,
++ value VARCHAR(128) DEFAULT '' NOT NULL,
++ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL
++);
++
++CREATE INDEX usr_preferences_ua_idx ON usr_preferences (uuid, attribute);
++CREATE INDEX usr_preferences_uda_idx ON usr_preferences (username, domain, attribute);
++
+diff --git a/utils/kamctl/sqlite/carrierroute-create.sql b/utils/kamctl/sqlite/carrierroute-create.sql
+new file mode 100644
+index 0000000..baafbee
+--- /dev/null
++++ b/utils/kamctl/sqlite/carrierroute-create.sql
+@@ -0,0 +1,42 @@
++INSERT INTO version (table_name, table_version) values ('carrierroute','3');
++CREATE TABLE carrierroute (
++ id INTEGER PRIMARY KEY NOT NULL,
++ carrier INTEGER DEFAULT 0 NOT NULL,
++ domain INTEGER DEFAULT 0 NOT NULL,
++ scan_prefix VARCHAR(64) DEFAULT '' NOT NULL,
++ flags INTEGER DEFAULT 0 NOT NULL,
++ mask INTEGER DEFAULT 0 NOT NULL,
++ prob REAL DEFAULT 0 NOT NULL,
++ strip INTEGER DEFAULT 0 NOT NULL,
++ rewrite_host VARCHAR(128) DEFAULT '' NOT NULL,
++ rewrite_prefix VARCHAR(64) DEFAULT '' NOT NULL,
++ rewrite_suffix VARCHAR(64) DEFAULT '' NOT NULL,
++ description VARCHAR(255) DEFAULT NULL
++);
++
++INSERT INTO version (table_name, table_version) values ('carrierfailureroute','2');
++CREATE TABLE carrierfailureroute (
++ id INTEGER PRIMARY KEY NOT NULL,
++ carrier INTEGER DEFAULT 0 NOT NULL,
++ domain INTEGER DEFAULT 0 NOT NULL,
++ scan_prefix VARCHAR(64) DEFAULT '' NOT NULL,
++ host_name VARCHAR(128) DEFAULT '' NOT NULL,
++ reply_code VARCHAR(3) DEFAULT '' NOT NULL,
++ flags INTEGER DEFAULT 0 NOT NULL,
++ mask INTEGER DEFAULT 0 NOT NULL,
++ next_domain INTEGER DEFAULT 0 NOT NULL,
++ description VARCHAR(255) DEFAULT NULL
++);
++
++INSERT INTO version (table_name, table_version) values ('carrier_name','1');
++CREATE TABLE carrier_name (
++ id INTEGER PRIMARY KEY NOT NULL,
++ carrier VARCHAR(64) DEFAULT NULL
++);
++
++INSERT INTO version (table_name, table_version) values ('domain_name','1');
++CREATE TABLE domain_name (
++ id INTEGER PRIMARY KEY NOT NULL,
++ domain VARCHAR(64) DEFAULT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/cpl-create.sql b/utils/kamctl/sqlite/cpl-create.sql
+new file mode 100644
+index 0000000..8beedf5
+--- /dev/null
++++ b/utils/kamctl/sqlite/cpl-create.sql
+@@ -0,0 +1,10 @@
++INSERT INTO version (table_name, table_version) values ('cpl','1');
++CREATE TABLE cpl (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ cpl_xml TEXT,
++ cpl_bin TEXT,
++ CONSTRAINT cpl_account_idx UNIQUE (username, domain)
++);
++
+diff --git a/utils/kamctl/sqlite/dialog-create.sql b/utils/kamctl/sqlite/dialog-create.sql
+new file mode 100644
+index 0000000..bb086a5
+--- /dev/null
++++ b/utils/kamctl/sqlite/dialog-create.sql
+@@ -0,0 +1,29 @@
++INSERT INTO version (table_name, table_version) values ('dialog','5');
++CREATE TABLE dialog (
++ id INTEGER PRIMARY KEY NOT NULL,
++ hash_entry INTEGER NOT NULL,
++ hash_id INTEGER NOT NULL,
++ callid VARCHAR(255) NOT NULL,
++ from_uri VARCHAR(128) NOT NULL,
++ from_tag VARCHAR(64) NOT NULL,
++ to_uri VARCHAR(128) NOT NULL,
++ to_tag VARCHAR(64) NOT NULL,
++ caller_cseq VARCHAR(7) NOT NULL,
++ callee_cseq VARCHAR(7) NOT NULL,
++ caller_route_set VARCHAR(512),
++ callee_route_set VARCHAR(512),
++ caller_contact VARCHAR(128) NOT NULL,
++ callee_contact VARCHAR(128) NOT NULL,
++ caller_sock VARCHAR(64) NOT NULL,
++ callee_sock VARCHAR(64) NOT NULL,
++ state INTEGER NOT NULL,
++ start_time INTEGER NOT NULL,
++ timeout INTEGER DEFAULT 0 NOT NULL,
++ sflags INTEGER DEFAULT 0 NOT NULL,
++ toroute INTEGER DEFAULT 0 NOT NULL,
++ toroute_name VARCHAR(32),
++ req_uri VARCHAR(128) NOT NULL
++);
++
++CREATE INDEX dialog_hash_idx ON dialog (hash_entry, hash_id);
++
+diff --git a/utils/kamctl/sqlite/dialplan-create.sql b/utils/kamctl/sqlite/dialplan-create.sql
+new file mode 100644
+index 0000000..1a85e50
+--- /dev/null
++++ b/utils/kamctl/sqlite/dialplan-create.sql
+@@ -0,0 +1,13 @@
++INSERT INTO version (table_name, table_version) values ('dialplan','1');
++CREATE TABLE dialplan (
++ id INTEGER PRIMARY KEY NOT NULL,
++ dpid INTEGER NOT NULL,
++ pr INTEGER NOT NULL,
++ match_op INTEGER NOT NULL,
++ match_exp VARCHAR(64) NOT NULL,
++ match_len INTEGER NOT NULL,
++ subst_exp VARCHAR(64) NOT NULL,
++ repl_exp VARCHAR(32) NOT NULL,
++ attrs VARCHAR(32) NOT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/dispatcher-create.sql b/utils/kamctl/sqlite/dispatcher-create.sql
+new file mode 100644
+index 0000000..ec37fc4
+--- /dev/null
++++ b/utils/kamctl/sqlite/dispatcher-create.sql
+@@ -0,0 +1,11 @@
++INSERT INTO version (table_name, table_version) values ('dispatcher','4');
++CREATE TABLE dispatcher (
++ id INTEGER PRIMARY KEY NOT NULL,
++ setid INTEGER DEFAULT 0 NOT NULL,
++ destination VARCHAR(192) DEFAULT '' NOT NULL,
++ flags INTEGER DEFAULT 0 NOT NULL,
++ priority INTEGER DEFAULT 0 NOT NULL,
++ attrs VARCHAR(128) DEFAULT '' NOT NULL,
++ description VARCHAR(64) DEFAULT '' NOT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/domain-create.sql b/utils/kamctl/sqlite/domain-create.sql
+new file mode 100644
+index 0000000..0b1fbe4
+--- /dev/null
++++ b/utils/kamctl/sqlite/domain-create.sql
+@@ -0,0 +1,8 @@
++INSERT INTO version (table_name, table_version) values ('domain','1');
++CREATE TABLE domain (
++ id INTEGER PRIMARY KEY NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
++ CONSTRAINT domain_domain_idx UNIQUE (domain)
++);
++
+diff --git a/utils/kamctl/sqlite/domainpolicy-create.sql b/utils/kamctl/sqlite/domainpolicy-create.sql
+new file mode 100644
+index 0000000..c7cb279
+--- /dev/null
++++ b/utils/kamctl/sqlite/domainpolicy-create.sql
+@@ -0,0 +1,13 @@
++INSERT INTO version (table_name, table_version) values ('domainpolicy','2');
++CREATE TABLE domainpolicy (
++ id INTEGER PRIMARY KEY NOT NULL,
++ rule VARCHAR(255) NOT NULL,
++ type VARCHAR(255) NOT NULL,
++ att VARCHAR(255),
++ val VARCHAR(128),
++ description VARCHAR(255) NOT NULL,
++ CONSTRAINT domainpolicy_rav_idx UNIQUE (rule, att, val)
++);
++
++CREATE INDEX domainpolicy_rule_idx ON domainpolicy (rule);
++
+diff --git a/utils/kamctl/sqlite/drouting-create.sql b/utils/kamctl/sqlite/drouting-create.sql
+new file mode 100644
+index 0000000..9c962fa
+--- /dev/null
++++ b/utils/kamctl/sqlite/drouting-create.sql
+@@ -0,0 +1,39 @@
++INSERT INTO version (table_name, table_version) values ('dr_gateways','3');
++CREATE TABLE dr_gateways (
++ gwid INTEGER PRIMARY KEY NOT NULL,
++ type INTEGER DEFAULT 0 NOT NULL,
++ address VARCHAR(128) NOT NULL,
++ strip INTEGER DEFAULT 0 NOT NULL,
++ pri_prefix VARCHAR(64) DEFAULT NULL,
++ attrs VARCHAR(255) DEFAULT NULL,
++ description VARCHAR(128) DEFAULT '' NOT NULL
++);
++
++INSERT INTO version (table_name, table_version) values ('dr_rules','3');
++CREATE TABLE dr_rules (
++ ruleid INTEGER PRIMARY KEY NOT NULL,
++ groupid VARCHAR(255) NOT NULL,
++ prefix VARCHAR(64) NOT NULL,
++ timerec VARCHAR(255) NOT NULL,
++ priority INTEGER DEFAULT 0 NOT NULL,
++ routeid VARCHAR(64) NOT NULL,
++ gwlist VARCHAR(255) NOT NULL,
++ description VARCHAR(128) DEFAULT '' NOT NULL
++);
++
++INSERT INTO version (table_name, table_version) values ('dr_gw_lists','1');
++CREATE TABLE dr_gw_lists (
++ id INTEGER PRIMARY KEY NOT NULL,
++ gwlist VARCHAR(255) NOT NULL,
++ description VARCHAR(128) DEFAULT '' NOT NULL
++);
++
++INSERT INTO version (table_name, table_version) values ('dr_groups','2');
++CREATE TABLE dr_groups (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) NOT NULL,
++ domain VARCHAR(128) DEFAULT '' NOT NULL,
++ groupid INTEGER DEFAULT 0 NOT NULL,
++ description VARCHAR(128) DEFAULT '' NOT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/group-create.sql b/utils/kamctl/sqlite/group-create.sql
+new file mode 100644
+index 0000000..fbd91c5
+--- /dev/null
++++ b/utils/kamctl/sqlite/group-create.sql
+@@ -0,0 +1,19 @@
++INSERT INTO version (table_name, table_version) values ('grp','2');
++CREATE TABLE grp (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ grp VARCHAR(64) DEFAULT '' NOT NULL,
++ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
++ CONSTRAINT grp_account_group_idx UNIQUE (username, domain, grp)
++);
++
++INSERT INTO version (table_name, table_version) values ('re_grp','1');
++CREATE TABLE re_grp (
++ id INTEGER PRIMARY KEY NOT NULL,
++ reg_exp VARCHAR(128) DEFAULT '' NOT NULL,
++ group_id INTEGER DEFAULT 0 NOT NULL
++);
++
++CREATE INDEX re_grp_group_idx ON re_grp (group_id);
++
+diff --git a/utils/kamctl/sqlite/htable-create.sql b/utils/kamctl/sqlite/htable-create.sql
+new file mode 100644
+index 0000000..59fa681
+--- /dev/null
++++ b/utils/kamctl/sqlite/htable-create.sql
+@@ -0,0 +1,9 @@
++INSERT INTO version (table_name, table_version) values ('htable','1');
++CREATE TABLE htable (
++ id INTEGER PRIMARY KEY NOT NULL,
++ key_name VARCHAR(64) DEFAULT '' NOT NULL,
++ key_type INTEGER DEFAULT 0 NOT NULL,
++ value_type INTEGER DEFAULT 0 NOT NULL,
++ key_value VARCHAR(128) DEFAULT '' NOT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/imc-create.sql b/utils/kamctl/sqlite/imc-create.sql
+new file mode 100644
+index 0000000..99d68c1
+--- /dev/null
++++ b/utils/kamctl/sqlite/imc-create.sql
+@@ -0,0 +1,19 @@
++INSERT INTO version (table_name, table_version) values ('imc_rooms','1');
++CREATE TABLE imc_rooms (
++ id INTEGER PRIMARY KEY NOT NULL,
++ name VARCHAR(64) NOT NULL,
++ domain VARCHAR(64) NOT NULL,
++ flag INTEGER NOT NULL,
++ CONSTRAINT imc_rooms_name_domain_idx UNIQUE (name, domain)
++);
++
++INSERT INTO version (table_name, table_version) values ('imc_members','1');
++CREATE TABLE imc_members (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) NOT NULL,
++ domain VARCHAR(64) NOT NULL,
++ room VARCHAR(64) NOT NULL,
++ flag INTEGER NOT NULL,
++ CONSTRAINT imc_members_account_room_idx UNIQUE (username, domain, room)
++);
++
+diff --git a/utils/kamctl/sqlite/lcr-create.sql b/utils/kamctl/sqlite/lcr-create.sql
+new file mode 100644
+index 0000000..bf93141
+--- /dev/null
++++ b/utils/kamctl/sqlite/lcr-create.sql
+@@ -0,0 +1,43 @@
++INSERT INTO version (table_name, table_version) values ('lcr_gw','2');
++CREATE TABLE lcr_gw (
++ id INTEGER PRIMARY KEY NOT NULL,
++ lcr_id SMALLINT NOT NULL,
++ gw_name VARCHAR(128),
++ ip_addr VARCHAR(15),
++ hostname VARCHAR(64),
++ port SMALLINT,
++ params VARCHAR(64),
++ uri_scheme SMALLINT,
++ transport SMALLINT,
++ strip SMALLINT,
++ prefix VARCHAR(16) DEFAULT NULL,
++ tag VARCHAR(64) DEFAULT NULL,
++ flags INTEGER DEFAULT 0 NOT NULL,
++ defunct INTEGER DEFAULT NULL,
++ CONSTRAINT lcr_gw_lcr_id_ip_addr_port_hostname_idx UNIQUE (lcr_id, ip_addr, port, hostname)
++);
++
++INSERT INTO version (table_name, table_version) values ('lcr_rule_target','1');
++CREATE TABLE lcr_rule_target (
++ id INTEGER PRIMARY KEY NOT NULL,
++ lcr_id SMALLINT NOT NULL,
++ rule_id INTEGER NOT NULL,
++ gw_id INTEGER NOT NULL,
++ priority SMALLINT NOT NULL,
++ weight INTEGER DEFAULT 1 NOT NULL,
++ CONSTRAINT lcr_rule_target_rule_id_gw_id_idx UNIQUE (rule_id, gw_id)
++);
++
++CREATE INDEX lcr_rule_target_lcr_id_idx ON lcr_rule_target (lcr_id);
++
++INSERT INTO version (table_name, table_version) values ('lcr_rule','1');
++CREATE TABLE lcr_rule (
++ id INTEGER PRIMARY KEY NOT NULL,
++ lcr_id SMALLINT NOT NULL,
++ prefix VARCHAR(16) DEFAULT NULL,
++ from_uri VARCHAR(64) DEFAULT NULL,
++ stopper INTEGER DEFAULT 0 NOT NULL,
++ enabled INTEGER DEFAULT 1 NOT NULL,
++ CONSTRAINT lcr_rule_lcr_id_prefix_from_uri_idx UNIQUE (lcr_id, prefix, from_uri)
++);
++
+diff --git a/utils/kamctl/sqlite/matrix-create.sql b/utils/kamctl/sqlite/matrix-create.sql
+new file mode 100644
+index 0000000..50f2ed8
+--- /dev/null
++++ b/utils/kamctl/sqlite/matrix-create.sql
+@@ -0,0 +1,9 @@
++INSERT INTO version (table_name, table_version) values ('matrix','1');
++CREATE TABLE matrix (
++ first INTEGER NOT NULL,
++ second SMALLINT NOT NULL,
++ res INTEGER NOT NULL
++);
++
++CREATE INDEX matrix_matrix_idx ON matrix (first, second);
++
+diff --git a/utils/kamctl/sqlite/msilo-create.sql b/utils/kamctl/sqlite/msilo-create.sql
+new file mode 100644
+index 0000000..7234112
+--- /dev/null
++++ b/utils/kamctl/sqlite/msilo-create.sql
+@@ -0,0 +1,16 @@
++INSERT INTO version (table_name, table_version) values ('silo','5');
++CREATE TABLE silo (
++ id INTEGER PRIMARY KEY NOT NULL,
++ src_addr VARCHAR(128) DEFAULT '' NOT NULL,
++ dst_addr VARCHAR(128) DEFAULT '' NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ inc_time INTEGER DEFAULT 0 NOT NULL,
++ exp_time INTEGER DEFAULT 0 NOT NULL,
++ snd_time INTEGER DEFAULT 0 NOT NULL,
++ ctype VARCHAR(32) DEFAULT 'text/plain' NOT NULL,
++ body BYTEA DEFAULT '' NOT NULL
++);
++
++CREATE INDEX silo_account_idx ON silo (username, domain);
++
+diff --git a/utils/kamctl/sqlite/mtree-create.sql b/utils/kamctl/sqlite/mtree-create.sql
+new file mode 100644
+index 0000000..9b6f56f
+--- /dev/null
++++ b/utils/kamctl/sqlite/mtree-create.sql
+@@ -0,0 +1,8 @@
++INSERT INTO version (table_name, table_version) values ('mtree','1');
++CREATE TABLE mtree (
++ id INTEGER PRIMARY KEY NOT NULL,
++ tprefix VARCHAR(32) DEFAULT '' NOT NULL,
++ tvalue VARCHAR(128) DEFAULT '' NOT NULL,
++ CONSTRAINT mtree_tprefix_idx UNIQUE (tprefix)
++);
++
+diff --git a/utils/kamctl/sqlite/pdt-create.sql b/utils/kamctl/sqlite/pdt-create.sql
+new file mode 100644
+index 0000000..46b517a
+--- /dev/null
++++ b/utils/kamctl/sqlite/pdt-create.sql
+@@ -0,0 +1,9 @@
++INSERT INTO version (table_name, table_version) values ('pdt','1');
++CREATE TABLE pdt (
++ id INTEGER PRIMARY KEY NOT NULL,
++ sdomain VARCHAR(128) NOT NULL,
++ prefix VARCHAR(32) NOT NULL,
++ domain VARCHAR(128) DEFAULT '' NOT NULL,
++ CONSTRAINT pdt_sdomain_prefix_idx UNIQUE (sdomain, prefix)
++);
++
+diff --git a/utils/kamctl/sqlite/permissions-create.sql b/utils/kamctl/sqlite/permissions-create.sql
+new file mode 100644
+index 0000000..ff3ac56
+--- /dev/null
++++ b/utils/kamctl/sqlite/permissions-create.sql
+@@ -0,0 +1,21 @@
++INSERT INTO version (table_name, table_version) values ('trusted','5');
++CREATE TABLE trusted (
++ id INTEGER PRIMARY KEY NOT NULL,
++ src_ip VARCHAR(50) NOT NULL,
++ proto VARCHAR(4) NOT NULL,
++ from_pattern VARCHAR(64) DEFAULT NULL,
++ tag VARCHAR(64)
++);
++
++CREATE INDEX trusted_peer_idx ON trusted (src_ip);
++
++INSERT INTO version (table_name, table_version) values ('address','4');
++CREATE TABLE address (
++ id INTEGER PRIMARY KEY NOT NULL,
++ grp SMALLINT DEFAULT 1 NOT NULL,
++ ip_addr VARCHAR(15) NOT NULL,
++ mask SMALLINT DEFAULT 32 NOT NULL,
++ port SMALLINT DEFAULT 0 NOT NULL,
++ tag VARCHAR(64)
++);
++
+diff --git a/utils/kamctl/sqlite/presence-create.sql b/utils/kamctl/sqlite/presence-create.sql
+new file mode 100644
+index 0000000..fe89b36
+--- /dev/null
++++ b/utils/kamctl/sqlite/presence-create.sql
+@@ -0,0 +1,92 @@
++INSERT INTO version (table_name, table_version) values ('presentity','3');
++CREATE TABLE presentity (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) NOT NULL,
++ domain VARCHAR(64) NOT NULL,
++ event VARCHAR(64) NOT NULL,
++ etag VARCHAR(64) NOT NULL,
++ expires INTEGER NOT NULL,
++ received_time INTEGER NOT NULL,
++ body BYTEA NOT NULL,
++ sender VARCHAR(128) NOT NULL,
++ CONSTRAINT presentity_presentity_idx UNIQUE (username, domain, event, etag)
++);
++
++INSERT INTO version (table_name, table_version) values ('active_watchers','9');
++CREATE TABLE active_watchers (
++ id INTEGER PRIMARY KEY NOT NULL,
++ presentity_uri VARCHAR(128) NOT NULL,
++ watcher_username VARCHAR(64) NOT NULL,
++ watcher_domain VARCHAR(64) NOT NULL,
++ to_user VARCHAR(64) NOT NULL,
++ to_domain VARCHAR(64) NOT NULL,
++ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
++ event_id VARCHAR(64),
++ to_tag VARCHAR(64) NOT NULL,
++ from_tag VARCHAR(64) NOT NULL,
++ callid VARCHAR(128) NOT NULL,
++ local_cseq INTEGER NOT NULL,
++ remote_cseq INTEGER NOT NULL,
++ contact VARCHAR(128) NOT NULL,
++ record_route TEXT,
++ expires INTEGER NOT NULL,
++ status INTEGER DEFAULT 2 NOT NULL,
++ reason VARCHAR(64) NOT NULL,
++ version INTEGER DEFAULT 0 NOT NULL,
++ socket_info VARCHAR(64) NOT NULL,
++ local_contact VARCHAR(128) NOT NULL,
++ CONSTRAINT active_watchers_active_watchers_idx UNIQUE (presentity_uri, callid, to_tag, from_tag)
++);
++
++INSERT INTO version (table_name, table_version) values ('watchers','3');
++CREATE TABLE watchers (
++ id INTEGER PRIMARY KEY NOT NULL,
++ presentity_uri VARCHAR(128) NOT NULL,
++ watcher_username VARCHAR(64) NOT NULL,
++ watcher_domain VARCHAR(64) NOT NULL,
++ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
++ status INTEGER NOT NULL,
++ reason VARCHAR(64),
++ inserted_time INTEGER NOT NULL,
++ CONSTRAINT watchers_watcher_idx UNIQUE (presentity_uri, watcher_username, watcher_domain, event)
++);
++
++INSERT INTO version (table_name, table_version) values ('xcap','3');
++CREATE TABLE xcap (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) NOT NULL,
++ domain VARCHAR(64) NOT NULL,
++ doc BYTEA NOT NULL,
++ doc_type INTEGER NOT NULL,
++ etag VARCHAR(64) NOT NULL,
++ source INTEGER NOT NULL,
++ doc_uri VARCHAR(128) NOT NULL,
++ port INTEGER NOT NULL,
++ CONSTRAINT xcap_account_doc_type_idx UNIQUE (username, domain, doc_type, doc_uri)
++);
++
++CREATE INDEX xcap_source_idx ON xcap (source);
++
++INSERT INTO version (table_name, table_version) values ('pua','6');
++CREATE TABLE pua (
++ id INTEGER PRIMARY KEY NOT NULL,
++ pres_uri VARCHAR(128) NOT NULL,
++ pres_id VARCHAR(64) NOT NULL,
++ event INTEGER NOT NULL,
++ expires INTEGER NOT NULL,
++ desired_expires INTEGER NOT NULL,
++ flag INTEGER NOT NULL,
++ etag VARCHAR(64) NOT NULL,
++ tuple_id VARCHAR(64),
++ watcher_uri VARCHAR(128) NOT NULL,
++ call_id VARCHAR(128) NOT NULL,
++ to_tag VARCHAR(64) NOT NULL,
++ from_tag VARCHAR(64) NOT NULL,
++ cseq INTEGER NOT NULL,
++ record_route TEXT,
++ contact VARCHAR(128) NOT NULL,
++ remote_contact VARCHAR(128) NOT NULL,
++ version INTEGER NOT NULL,
++ extra_headers TEXT NOT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/purple-create.sql b/utils/kamctl/sqlite/purple-create.sql
+new file mode 100644
+index 0000000..b58c53e
+--- /dev/null
++++ b/utils/kamctl/sqlite/purple-create.sql
+@@ -0,0 +1,9 @@
++INSERT INTO version (table_name, table_version) values ('purplemap','1');
++CREATE TABLE purplemap (
++ id INTEGER PRIMARY KEY NOT NULL,
++ sip_user VARCHAR(128) NOT NULL,
++ ext_user VARCHAR(128) NOT NULL,
++ ext_prot VARCHAR(16) NOT NULL,
++ ext_pass VARCHAR(64)
++);
++
+diff --git a/utils/kamctl/sqlite/registrar-create.sql b/utils/kamctl/sqlite/registrar-create.sql
+new file mode 100644
+index 0000000..68f2adc
+--- /dev/null
++++ b/utils/kamctl/sqlite/registrar-create.sql
+@@ -0,0 +1,22 @@
++INSERT INTO version (table_name, table_version) values ('aliases','1004');
++CREATE TABLE aliases (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT NULL,
++ contact VARCHAR(255) DEFAULT '' NOT NULL,
++ received VARCHAR(128) DEFAULT NULL,
++ path VARCHAR(128) DEFAULT NULL,
++ expires TIMESTAMP WITHOUT TIME ZONE DEFAULT '2020-05-28 21:32:15' NOT NULL,
++ q REAL DEFAULT 1.0 NOT NULL,
++ callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
++ cseq INTEGER DEFAULT 13 NOT NULL,
++ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
++ flags INTEGER DEFAULT 0 NOT NULL,
++ cflags INTEGER DEFAULT 0 NOT NULL,
++ user_agent VARCHAR(255) DEFAULT '' NOT NULL,
++ socket VARCHAR(64) DEFAULT NULL,
++ methods INTEGER DEFAULT NULL
++);
++
++CREATE INDEX aliases_alias_idx ON aliases (username, domain, contact);
++
+diff --git a/utils/kamctl/sqlite/rls-create.sql b/utils/kamctl/sqlite/rls-create.sql
+new file mode 100644
+index 0000000..b15120d
+--- /dev/null
++++ b/utils/kamctl/sqlite/rls-create.sql
+@@ -0,0 +1,42 @@
++INSERT INTO version (table_name, table_version) values ('rls_presentity','0');
++CREATE TABLE rls_presentity (
++ id INTEGER PRIMARY KEY NOT NULL,
++ rlsubs_did VARCHAR(255) NOT NULL,
++ resource_uri VARCHAR(128) NOT NULL,
++ content_type VARCHAR(64) NOT NULL,
++ presence_state BYTEA NOT NULL,
++ expires INTEGER NOT NULL,
++ updated INTEGER NOT NULL,
++ auth_state INTEGER NOT NULL,
++ reason VARCHAR(64) NOT NULL,
++ CONSTRAINT rls_presentity_rls_presentity_idx UNIQUE (rlsubs_did, resource_uri)
++);
++
++CREATE INDEX rls_presentity_updated_idx ON rls_presentity (updated);
++
++INSERT INTO version (table_name, table_version) values ('rls_watchers','1');
++CREATE TABLE rls_watchers (
++ id INTEGER PRIMARY KEY NOT NULL,
++ presentity_uri VARCHAR(128) NOT NULL,
++ to_user VARCHAR(64) NOT NULL,
++ to_domain VARCHAR(64) NOT NULL,
++ watcher_username VARCHAR(64) NOT NULL,
++ watcher_domain VARCHAR(64) NOT NULL,
++ event VARCHAR(64) DEFAULT 'presence' NOT NULL,
++ event_id VARCHAR(64),
++ to_tag VARCHAR(64) NOT NULL,
++ from_tag VARCHAR(64) NOT NULL,
++ callid VARCHAR(64) NOT NULL,
++ local_cseq INTEGER NOT NULL,
++ remote_cseq INTEGER NOT NULL,
++ contact VARCHAR(64) NOT NULL,
++ record_route TEXT,
++ expires INTEGER NOT NULL,
++ status INTEGER DEFAULT 2 NOT NULL,
++ reason VARCHAR(64) NOT NULL,
++ version INTEGER DEFAULT 0 NOT NULL,
++ socket_info VARCHAR(64) NOT NULL,
++ local_contact VARCHAR(128) NOT NULL,
++ CONSTRAINT rls_watchers_rls_watcher_idx UNIQUE (presentity_uri, callid, to_tag, from_tag)
++);
++
+diff --git a/utils/kamctl/sqlite/siptrace-create.sql b/utils/kamctl/sqlite/siptrace-create.sql
+new file mode 100644
+index 0000000..a784d0b
+--- /dev/null
++++ b/utils/kamctl/sqlite/siptrace-create.sql
+@@ -0,0 +1,20 @@
++INSERT INTO version (table_name, table_version) values ('sip_trace','2');
++CREATE TABLE sip_trace (
++ id INTEGER PRIMARY KEY NOT NULL,
++ time_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
++ callid VARCHAR(255) DEFAULT '' NOT NULL,
++ traced_user VARCHAR(128) DEFAULT '' NOT NULL,
++ msg TEXT NOT NULL,
++ method VARCHAR(50) DEFAULT '' NOT NULL,
++ status VARCHAR(128) DEFAULT '' NOT NULL,
++ fromip VARCHAR(50) DEFAULT '' NOT NULL,
++ toip VARCHAR(50) DEFAULT '' NOT NULL,
++ fromtag VARCHAR(64) DEFAULT '' NOT NULL,
++ direction VARCHAR(4) DEFAULT '' NOT NULL
++);
++
++CREATE INDEX sip_trace_traced_user_idx ON sip_trace (traced_user);
++CREATE INDEX sip_trace_date_idx ON sip_trace (time_stamp);
++CREATE INDEX sip_trace_fromip_idx ON sip_trace (fromip);
++CREATE INDEX sip_trace_callid_idx ON sip_trace (callid);
++
+diff --git a/utils/kamctl/sqlite/speeddial-create.sql b/utils/kamctl/sqlite/speeddial-create.sql
+new file mode 100644
+index 0000000..64e1ae6
+--- /dev/null
++++ b/utils/kamctl/sqlite/speeddial-create.sql
+@@ -0,0 +1,14 @@
++INSERT INTO version (table_name, table_version) values ('speed_dial','2');
++CREATE TABLE speed_dial (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ sd_username VARCHAR(64) DEFAULT '' NOT NULL,
++ sd_domain VARCHAR(64) DEFAULT '' NOT NULL,
++ new_uri VARCHAR(128) DEFAULT '' NOT NULL,
++ fname VARCHAR(64) DEFAULT '' NOT NULL,
++ lname VARCHAR(64) DEFAULT '' NOT NULL,
++ description VARCHAR(64) DEFAULT '' NOT NULL,
++ CONSTRAINT speed_dial_speed_dial_idx UNIQUE (username, domain, sd_domain, sd_username)
++);
++
+diff --git a/utils/kamctl/sqlite/standard-create.sql b/utils/kamctl/sqlite/standard-create.sql
+new file mode 100644
+index 0000000..0add99d
+--- /dev/null
++++ b/utils/kamctl/sqlite/standard-create.sql
+@@ -0,0 +1,5 @@
++CREATE TABLE version (
++ table_name VARCHAR(32) NOT NULL,
++ table_version INTEGER DEFAULT 0 NOT NULL
++);
++
+diff --git a/utils/kamctl/sqlite/uac-create.sql b/utils/kamctl/sqlite/uac-create.sql
+new file mode 100644
+index 0000000..f0cf80d
+--- /dev/null
++++ b/utils/kamctl/sqlite/uac-create.sql
+@@ -0,0 +1,16 @@
++INSERT INTO version (table_name, table_version) values ('uacreg','1');
++CREATE TABLE uacreg (
++ id INTEGER PRIMARY KEY NOT NULL,
++ l_uuid VARCHAR(64) DEFAULT '' NOT NULL,
++ l_username VARCHAR(64) DEFAULT '' NOT NULL,
++ l_domain VARCHAR(128) DEFAULT '' NOT NULL,
++ r_username VARCHAR(64) DEFAULT '' NOT NULL,
++ r_domain VARCHAR(128) DEFAULT '' NOT NULL,
++ realm VARCHAR(64) DEFAULT '' NOT NULL,
++ auth_username VARCHAR(64) DEFAULT '' NOT NULL,
++ auth_password VARCHAR(64) DEFAULT '' NOT NULL,
++ auth_proxy VARCHAR(64) DEFAULT '' NOT NULL,
++ expires INTEGER DEFAULT 0 NOT NULL,
++ CONSTRAINT uacreg_l_uuid_idx UNIQUE (l_uuid)
++);
++
+diff --git a/utils/kamctl/sqlite/uri_db-create.sql b/utils/kamctl/sqlite/uri_db-create.sql
+new file mode 100644
+index 0000000..8e291fc
+--- /dev/null
++++ b/utils/kamctl/sqlite/uri_db-create.sql
+@@ -0,0 +1,10 @@
++INSERT INTO version (table_name, table_version) values ('uri','1');
++CREATE TABLE uri (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ uri_user VARCHAR(64) DEFAULT '' NOT NULL,
++ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
++ CONSTRAINT uri_account_idx UNIQUE (username, domain, uri_user)
++);
++
+diff --git a/utils/kamctl/sqlite/userblacklist-create.sql b/utils/kamctl/sqlite/userblacklist-create.sql
+new file mode 100644
+index 0000000..34d9eb1
+--- /dev/null
++++ b/utils/kamctl/sqlite/userblacklist-create.sql
+@@ -0,0 +1,21 @@
++INSERT INTO version (table_name, table_version) values ('userblacklist','1');
++CREATE TABLE userblacklist (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT '' NOT NULL,
++ prefix VARCHAR(64) DEFAULT '' NOT NULL,
++ whitelist SMALLINT DEFAULT 0 NOT NULL
++);
++
++CREATE INDEX userblacklist_userblacklist_idx ON userblacklist (username, domain, prefix);
++
++INSERT INTO version (table_name, table_version) values ('globalblacklist','1');
++CREATE TABLE globalblacklist (
++ id INTEGER PRIMARY KEY NOT NULL,
++ prefix VARCHAR(64) DEFAULT '' NOT NULL,
++ whitelist SMALLINT DEFAULT 0 NOT NULL,
++ description VARCHAR(255) DEFAULT NULL
++);
++
++CREATE INDEX globalblacklist_globalblacklist_idx ON globalblacklist (prefix);
++
+diff --git a/utils/kamctl/sqlite/usrloc-create.sql b/utils/kamctl/sqlite/usrloc-create.sql
+new file mode 100644
+index 0000000..6eb7d07
+--- /dev/null
++++ b/utils/kamctl/sqlite/usrloc-create.sql
+@@ -0,0 +1,22 @@
++INSERT INTO version (table_name, table_version) values ('location','1004');
++CREATE TABLE location (
++ id INTEGER PRIMARY KEY NOT NULL,
++ username VARCHAR(64) DEFAULT '' NOT NULL,
++ domain VARCHAR(64) DEFAULT NULL,
++ contact VARCHAR(255) DEFAULT '' NOT NULL,
++ received VARCHAR(128) DEFAULT NULL,
++ path VARCHAR(128) DEFAULT NULL,
++ expires TIMESTAMP WITHOUT TIME ZONE DEFAULT '2020-05-28 21:32:15' NOT NULL,
++ q REAL DEFAULT 1.0 NOT NULL,
++ callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
++ cseq INTEGER DEFAULT 13 NOT NULL,
++ last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
++ flags INTEGER DEFAULT 0 NOT NULL,
++ cflags INTEGER DEFAULT 0 NOT NULL,
++ user_agent VARCHAR(255) DEFAULT '' NOT NULL,
++ socket VARCHAR(64) DEFAULT NULL,
++ methods INTEGER DEFAULT NULL
++);
++
++CREATE INDEX location_account_contact_idx ON location (username, domain, contact);
++
+--
+1.7.4.5
+
diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index 823feb5fc..f37cb2128 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=kamailio
pkgver=3.1.3
-pkgrel=1
+pkgrel=2
pkgdesc="Open Source SIP Server"
url="http://www.kamailio.org/"
pkgusers="kamailio"
@@ -15,12 +15,14 @@ makedepends="bison flex expat-dev postgresql-dev pcre-dev mysql-dev
libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-doc $pkgname-postgres $pkgname-presence $pkgname-pcre
- $pkgname-mediaproxy $pkgname-unixodbc $pkgname-mysql"
+ $pkgname-mediaproxy $pkgname-unixodbc $pkgname-mysql $pkgname-sqlite"
source="http://www.kamailio.org/pub/kamailio/$pkgver/src/kamailio-${pkgver}_src.tar.gz
kamailio.cfg
kamailio.initd
kamailio-3.1-backslash.patch
sqlite.patch
+ 0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
+ 0001-utils-Install-the-sqlite-scripts.patch
0001-modules_k-uac-fix-from-to-restore-for-small-original.patch
"
@@ -118,19 +120,40 @@ _mv_mod_k() {
mysql() {
pkgdesc="MySQL support for kamailio"
depends="kamailio mysql-client"
+ replaces="kamailio"
_mv_mod db_mysql
- mkdir -p "$subpkgdir"/usr/share/kamailio
+ mkdir -p "$subpkgdir"/usr/share/kamailio \
+ "$subpkgdir"/usr/lib/kamailio/kamctl
mv "$pkgdir"/usr/share/kamailio/mysql \
- "$subpkgdir"/usr/share/kamailio/
+ "$subpkgdir"/usr/share/kamailio/ || return 1
+ mv "$pkgdir"/usr/lib/kamailio/kamctl/*.mysql \
+ "$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1
}
postgres() {
pkgdesc="PostgreSQL support for kamailio"
depends="kamailio postgresql-client"
+ replaces="kamailio"
_mv_mod db_postgres
- mkdir -p "$subpkgdir"/usr/share/kamailio
+ mkdir -p "$subpkgdir"/usr/share/kamailio \
+ "$subpkgdir"/usr/lib/kamailio/kamctl
mv "$pkgdir"/usr/share/kamailio/postgres \
"$subpkgdir"/usr/share/kamailio/
+ mv "$pkgdir"/usr/lib/kamailio/kamctl/*.pgsql \
+ "$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1
+}
+
+sqlite() {
+ pkgdesc="Sqlite support for kamailio"
+ depends="kamailio sqlite"
+ replaces="kamailio"
+ _mv_mod_k db_sqlite || return 1
+ mkdir -p "$subpkgdir"/usr/share/kamailio \
+ "$subpkgdir"/usr/lib/kamailio/kamctl
+ mv "$pkgdir"/usr/share/kamailio/sqlite \
+ "$subpkgdir"/usr/share/kamailio/ || return 1
+ mv "$pkgdir"/usr/lib/kamailio/kamctl/*.sqlite \
+ "$subpkgdir"/usr/lib/kamailio/kamctl/ || return 1
}
pcre() {
@@ -161,4 +184,6 @@ a3c959ec568c43a905710e7d25cd8c25 kamailio.cfg
c0dc4e13d9e57feb99f016d3ee443c0b kamailio.initd
8454687f047f703c5cb443db3a0003a8 kamailio-3.1-backslash.patch
199df21eaa4856dcacdcc438f72765f1 sqlite.patch
+9611a1246bc522cbfa5d8d99b3a55ac8 0001-utils-add-sqlite-support-to-kamctl-kamdbctl.patch
+bc92b472c843e01f4c16bf0078bfae27 0001-utils-Install-the-sqlite-scripts.patch
3f7d63e6ff634157b8b2bab514af65e9 0001-modules_k-uac-fix-from-to-restore-for-small-original.patch"