Module: sip-router
Branch: master
Commit: e395c9bb0131d7fce80af67c54cd813532e5f2ed
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e395c9b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Mar 3 18:16:54 2014 +0100
kamctl: db connect - new command for db management subset
- execute to command line client tool and stay connected using the
attributes from kamctlrc
- handy when kamctlrc is set, to avoid typing all the attributes when
willing to connect to kamailio database
---
utils/kamctl/kamctl | 7 +++++++
utils/kamctl/kamctl.mysql | 7 +++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 519da55..30dddcf 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -1010,6 +1010,13 @@ db_ops() {
QUERY="SELECT * FROM $1 WHERE $2=$3\\G;"
$DBROCMD "$QUERY"
;;
+ connect)
+ shift
+ if [ -z "$DBCMDCONNECT" ] ; then
+ merr "extension not implemented"
+ exit 1
+ fi
+ $DBCMDCONNECT
*)
usage_db_ops
exit 1
diff --git a/utils/kamctl/kamctl.mysql b/utils/kamctl/kamctl.mysql
index e533e9c..1b25d2a 100644
--- a/utils/kamctl/kamctl.mysql
+++ b/utils/kamctl/kamctl.mysql
@@ -42,7 +42,14 @@ mysql_ro_query() {
$MYSQL $2 -h $DBHOST -u $DBROUSER "-p$DBROPW" -e "$1 ;" $DBNAME
}
+mysql_connect() {
+ # if password not yet queried, query it now
+ prompt_pw "MySQL password for user '$DBRWUSER@$DBHOST'"
+ $MYSQL $2 -h $DBHOST -u $DBRWUSER "-p$DBRWPW" $DBNAME
+}
+
DBCMD=mysql_query
DBROCMD=mysql_ro_query
DBRAWPARAMS="-B"
+DBCMDCONNECT=mysql_connect