Module: kamailio Branch: master Commit: 0bd3c9eaf356d65b9620fb7ec8c6ebc1e0a47782 URL: https://github.com/kamailio/kamailio/commit/0bd3c9eaf356d65b9620fb7ec8c6ebc1...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-08-21T12:06:20+02:00
kamctl: added mtree management command
---
Modified: utils/kamctl/kamctl Modified: utils/kamctl/kamctl.base
---
Diff: https://github.com/kamailio/kamailio/commit/0bd3c9eaf356d65b9620fb7ec8c6ebc1... Patch: https://github.com/kamailio/kamailio/commit/0bd3c9eaf356d65b9620fb7ec8c6ebc1...
---
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl index 954eee37ae..acc0d1f741 100755 --- a/utils/kamctl/kamctl +++ b/utils/kamctl/kamctl @@ -1362,6 +1362,64 @@ permissions_address() { }
+# +##### ------------------------------------------------ ##### +### mtree management +# +mtree_management() { + case $1 in + reload) + require_ctlengine + ctl_cmd_run mtree.reload $2 + ;; + dump) + require_ctlengine + ctl_cmd_run mtree.list $2 + ;; + showdb) + require_dbengine + QUERY="select * FROM $2 ; " + $DBROCMD "$QUERY" + ;; + add) + require_dbengine + if [ $# -lt 4 ] ; then + usage_mtree + exit 1 + fi + + QUERY="INSERT INTO $2 \ + (tprefix, tvalue) \ + VALUES ($3, '$4');" + $DBCMD "$QUERY" + if [ $? -ne 0 ] ; then + merr "mtree - SQL Error" + exit 1 + fi + minfo "execute '$0 mtree reload' to synchronize cache and database" + ;; + rm) + require_dbengine + shift + if [ $# -ne 3 ] ; then + usage_address + exit 1 + fi + QUERY="DELETE FROM $2 where tprefix='$3';" + $DBCMD "$QUERY" + if [ $? -ne 0 ] ; then + merr "mtree - SQL Error" + exit 1 + fi + minfo "execute '$0 mtree reload' to synchronize cache and database" + ;; + *) + usage_mtree + exit 1 + esac +} + + # ##### ------------------------------------------------ ##### ### LCR management @@ -2876,6 +2934,11 @@ case $1 in permissions_address "$@" ;;
+ mtree) + shift + mtree_management "$@" + ;; + rpc) require_ctlengine shift diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base index 641449422c..adeceb77fb 100644 --- a/utils/kamctl/kamctl.base +++ b/utils/kamctl/kamctl.base @@ -552,6 +552,22 @@ EOF } USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ksr_srv"
+usage_mtree() { + echo + mecho " -- command 'add|dump|reload|rm|show' - manage mtree" + echo +cat <<EOF + mtree show <tname> .................. show db content + mtree dump [<tname>] ................ show cache content + mtree reload [<tname>] .............. reload db table into cache + mtree add <tname> <tprefix> <tvalue> + ......................... add a new entry + mtree rm <tname> <tprefix> .......... remove entries for given tname and tprefix +EOF +} +USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_mtree" + + ##### ----------------------------------------------- ##### #### Common functions