Module: sip-router Branch: master Commit: bc507d28e1168313772142925721b32e1a7b634a URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bc507d28...
Author: Philippe Sultan philippe.sultan@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Jan 25 20:59:23 2013 +0100
kamctl: added command for management of uid_domain records
---
utils/kamctl/kamctl | 76 +++++++++++++++++++++++++++++++++++++++++++ utils/kamctl/kamctl.base | 23 +++++++++++++ utils/kamctl/kamctl.sqlbase | 14 ++++++++ 3 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl index 78116be..9e6b0ba 100755 --- a/utils/kamctl/kamctl +++ b/utils/kamctl/kamctl @@ -1060,6 +1060,77 @@ domain() {
# ##### ------------------------------------------------ ##### +### uid_domain management +# +uid_domain() { + case $1 in + reload) + require_kamcmd + $SERCTLCMD domain.reload + ;; + show) + require_kamcmd + $SERCTLCMD domain.dump + ;; + showdb) + require_dbengine + QUERY="select * FROM $UID_DOMAIN_TABLE ; " + $DBROCMD "$QUERY" + ;; + add) + require_dbengine + shift + if [ $# -lt 1 ] ; then + merr "too few parameters" + exit 1 + fi + + DOMAIN=$1 + DID=$2 + FLAGS=$3 + + if [ -z "$2" ] ; then + DID=$DOMAIN + fi + if [ -z "$3" ] ; then + FLAGS=$(( $SRDB_LOAD_SER | $SRDB_CANON | $SRDB_FOR_SERWEB )) + fi + + if is_value_in_db $UID_DOMAIN_TABLE $UID_DO_DOMAIN_COLUMN $DOMAIN; then + minfo "$1 already in $UID_DOMAIN_TABLE table" + exit 0 + fi + QUERY="insert into $UID_DOMAIN_TABLE ($UID_DO_DID_COLUMN,$UID_DO_DOMAIN_COLUMN,$UID_DO_FLAGS_COLUMN) VALUES ('$DID','$DOMAIN',$FLAGS);" + $DBCMD "$QUERY" + if [ $? -ne 0 ] ; then + merr "uid_domain - SQL Error" + exit 1 + fi + minfo "execute '$0 uid_domain reload' to synchronize cache and database" + ;; + rm) + require_dbengine + shift + if [ $# -ne 1 ] ; then + merr "missing domain parameter" + exit 1 + fi + QUERY="delete from $UID_DOMAIN_TABLE where domain='$1';" + $DBCMD "$QUERY" + if [ $? -ne 0 ] ; then + merr "domain - SQL Error" + exit 1 + fi + minfo "execute '$0 uid_domain reload' to synchronize cache and database" + ;; + *) + usage_uid_domain + exit 1 + esac +} + +# +##### ------------------------------------------------ ##### ### permissions trusted management # permissions_trusted() { @@ -2481,6 +2552,11 @@ case $1 in domain "$@" ;;
+ uid_domain) + shift + uid_domain "$@" + ;; + trusted) shift permissions_trusted "$@" diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base index db4ef9a..589e0a0 100644 --- a/utils/kamctl/kamctl.base +++ b/utils/kamctl/kamctl.base @@ -128,6 +128,21 @@ USERNAME_RE="[-a-zA-Z0-9&=+$,;?/_.!~*'()]+" ##### ----------------------------------------------- ##### #### database tables for SQL databases and DBTEXT
+SRDB_LOAD_SER=$((1 << 0)) # The row should be loaded by SER +SRDB_DISABLED=$((1 << 1)) # The row is disabled +SRDB_CANON=$((1 << 2)) # Canonical entry (domain or uri) +SRDB_IS_TO=$((1 << 3)) # The URI can be used in To +SRDB_IS_FROM=$((1 << 4)) # The URI can be used in From +SRDB_FOR_SERWEB=$((1 << 5)) # Credentials instance can be used by serweb +SRDB_PENDING=$((1 << 6)) +SRDB_DELETED=$((1 << 7)) +SRDB_CALLER_DELETED=$((1 << 8)) # Accounting table +SRDB_CALLEE_DELETED=$((1 << 9)) # Accounting table +SRDB_MULTIVALUE=$((1 << 10)) # Attr_types table +SRDB_FILL_ON_REG=$((1 << 11)) # Attr_types table +SRDB_REQUIRED=$((1 << 12)) # Attr_types table +SRDB_DIR=$((1 << 13)) # Domain_settings table + # UsrLoc Table if [ -z "$UL_TABLE" ] ; then UL_TABLE=location @@ -180,6 +195,14 @@ fi DO_DOMAIN_COLUMN=domain DO_LAST_MODIFIED_COLUMN=last_modified
+# uid_domain table +if [ -z "$UID_DOMAIN_TABLE" ] ; then + UID_DOMAIN_TABLE=uid_domain +fi +UID_DO_DOMAIN_COLUMN=domain +UID_DO_DID_COLUMN=did +UID_DO_FLAGS_COLUMN=flags + # lcr tables if [ -z "$LCR_TABLE" ] ; then LCR_TABLE=lcr diff --git a/utils/kamctl/kamctl.sqlbase b/utils/kamctl/kamctl.sqlbase index 7354517..f07705f 100644 --- a/utils/kamctl/kamctl.sqlbase +++ b/utils/kamctl/kamctl.sqlbase @@ -140,3 +140,17 @@ cat <<EOF EOF } USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_domain" + +uid_usage_domain() { + echo + mecho " -- command 'uid_domain' - manage local domains" + echo +cat <<EOF + uid_domain reload ....................... reload domains from disk + uid_domain show ......................... show current domains in memory + uid_domain showdb ....................... show domains in the database + uid_domain add <domain> [did] [flags].... add the domain to the database + uid_domain rm <domain> .................. delete the domain from the database +EOF +} +USAGE_FUNCTIONS="$USAGE_FUNCTIONS uid_usage_domain"