Module: kamailio
Branch: master
Commit: f68a1e9c9f249faee38d29776d5831cbf9e3cce7
URL:
https://github.com/kamailio/kamailio/commit/f68a1e9c9f249faee38d29776d5831c…
Author: Nir Simionovich <nir.simionovich(a)greenfieldtech.net>
Committer: GitHub <noreply(a)github.com>
Date: 2023-07-17T17:26:18+02:00
kamctl: add 2 new options to dispatcher management (#3512)
*kamctl: add support for deleting a gateway or full setid in dispatcher.
* kamctl: small style fix to help screen after previous change
---------
Co-authored-by: Nir Simionovich <nirs(a)cloudonix.io>
---
Modified: utils/kamctl/kamctl
Modified: utils/kamctl/kamctl.base
---
Diff:
https://github.com/kamailio/kamailio/commit/f68a1e9c9f249faee38d29776d5831c…
Patch:
https://github.com/kamailio/kamailio/commit/f68a1e9c9f249faee38d29776d5831c…
---
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 34f6183dfb7..dd09ffb7daf 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -1756,6 +1756,40 @@ dispatcher() {
fi
;;
+ rmip)
+ require_dbengine
+ shift
+ if [ $# -ne 2 ] ; then
+ merr "missing gateway ip address and/or setid to be removed"
+ exit 1
+ fi
+
+ QUERY="delete from $DISPATCHER_TABLE where $DISPATCHER_SETID_COLUMN='$2'
and $DISPATCHER_DESTINATION_COLUMN like 'sip:$1:%';"
+ $DBCMD "$QUERY"
+
+ if [ $? -ne 0 ] ; then
+ merr "dispatcher - SQL Error"
+ exit 1
+ fi
+
+ ;;
+ rmset)
+ require_dbengine
+ shift
+ if [ $# -ne 2 ] ; then
+ merr "missing gateway setid to be removed"
+ exit 1
+ fi
+
+ QUERY="delete from $DISPATCHER_TABLE where
$DISPATCHER_SETID_COLUMN='$1'' and $DISPATCHER_DESTINATION_COLUMN like
'sip:$1:%'';"
+ $DBCMD "$QUERY"
+
+ if [ $? -ne 0 ] ; then
+ merr "dispatcher - SQL Error"
+ exit 1
+ fi
+
+ ;;
reload)
require_ctlengine
ctl_cmd_run dispatcher.reload
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
index 9e37f5551fc..a265c479c04 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
@@ -512,6 +512,8 @@ cat <<EOF
dispatcher add <setid> <destination> [flags] [priority] [attrs]
[description]
.......................... add gateway
dispatcher rm <id> .................. delete gateway
+ dispatcher rmip <ip> <setid>......... delete gateway <ip> in
<setid>
+ dispatcher rmset <setid> ............. delete all gateways in <setid>
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_dispatcher"