Module: kamailio
Branch: master
Commit: d3b7f0d390dd430d40a1d47112f076f4b21e3afe
URL:
https://github.com/kamailio/kamailio/commit/d3b7f0d390dd430d40a1d47112f076f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-09-29T09:58:04+02:00
kamctl: added db subcommand to mange records in version table
---
Modified: utils/kamctl/kamctl
Modified: utils/kamctl/kamctl.sqlbase
---
Diff:
https://github.com/kamailio/kamailio/commit/d3b7f0d390dd430d40a1d47112f076f…
Patch:
https://github.com/kamailio/kamailio/commit/d3b7f0d390dd430d40a1d47112f076f…
---
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 3aaecbd15a..569ddd8f3b 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -1050,6 +1050,32 @@ db_ops() {
fi
$DBCMDCONNECT
;;
+ version)
+ shift
+ if [ $# -ne 3 ] ; then
+ merr "missing parameters"
+ exit 1
+ fi
+ case $1 in
+ add)
+ QUERY="INSERT INTO version (table_name, table_version) VALUES ('$2',
$3);"
+ $DBCMD "$QUERY"
+ ;;
+ set)
+ QUERY="DELETE FROM version WHERE table_name='$2';"
+ $DBCMD "$QUERY"
+ QUERY="INSERT INTO version (table_name, table_version) VALUES ('$2',
$3);"
+ $DBCMD "$QUERY"
+ ;;
+ update)
+ QUERY="UPDATE version SET table_version=$3 WHERE
table_name='$2';"
+ $DBCMD "$QUERY"
+ ;;
+ *)
+ usage_db_ops
+ exit 1
+ esac
+ ;;
*)
usage_db_ops
exit 1
diff --git a/utils/kamctl/kamctl.sqlbase b/utils/kamctl/kamctl.sqlbase
index 2aef9801af..f821d2a799 100644
--- a/utils/kamctl/kamctl.sqlbase
+++ b/utils/kamctl/kamctl.sqlbase
@@ -67,6 +67,9 @@ cat <<EOF
db nmatch <table> <key> <value>...... display record from table that
has
........................... column key equal to value as non-string
db connect .......................... connect to db server via cli
+ db version add <table> <value> ...... add new value in version table
+ db version set <table> <value> ...... set value in version table
+ db version update <table> <value> ... update value in version table
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_db_ops"
@@ -79,7 +82,7 @@ usage_speeddial() {
cat <<EOF
speeddial show <speeddial-id> ....... show speeddial details
speeddial list <sip-id> ............. list speeddial for uri
- speeddial add <sip-id> <sd-id> <new-uri> [<desc>] ...
+ speeddial add <sip-id> <sd-id> <new-uri> [<desc>] ...
........................... add a speedial (*)
speeddial rm <sip-id> <sd-id> ....... remove a speeddial (*)
speeddial help ...................... help message