Module: sip-router
Branch: master
Commit: 1cec15e057bdec4455e70af951def19e36a78e8e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1cec15e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Sep 2 14:09:18 2013 +0200
kamctl: added commands to set extra columns in subscriber table
- useful to deal with columns added for load_credentials of auth_db
module
- 'sets' - sets a column with string value
- 'setn' - sets a column with numeric value
---
utils/kamctl/kamctl | 53 ++++++++++++++++++++++++++++++++++++++++++++++
utils/kamctl/kamctl.base | 2 +
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index e25c6f2..6e922c6 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -2254,6 +2254,51 @@ and $REALM_COLUMN='$OSERDOMAIN';"
# and also all his contacts
$0 ul rm $1 > /dev/null 2>&1
;;
+ sets)
+ if [ $# -ne 4 ] ; then
+ usage_subscriber
+ exit 1
+ fi
+ shift
+
+ is_user $1
+ if [ $? -ne 0 ] ; then
+ merr "non-existent user '$1'"
+ exit 1
+ fi
+
+ QUERY="update $SUB_TABLE set $2='$3' \
+WHERE $SUBSCRIBER_COLUMN='$OSERUSER' and
$REALM_COLUMN='$OSERDOMAIN';"
+ $DBCMD "$QUERY"
+ if [ $? -ne 0 ] ; then
+ merr "attribute change failed"
+ else
+ minfo "attribute change succeeded"
+ fi
+ ;;
+ setn)
+ if [ $# -ne 4 ] ; then
+ usage_subscriber
+ exit 1
+ fi
+ shift
+
+ is_user $1
+ if [ $? -ne 0 ] ; then
+ merr "non-existent user '$1'"
+ exit 1
+ fi
+
+ QUERY="update $SUB_TABLE set $2=$3 \
+WHERE $SUBSCRIBER_COLUMN='$OSERUSER' and
$REALM_COLUMN='$OSERDOMAIN';"
+ $DBCMD "$QUERY"
+ if [ $? -ne 0 ] ; then
+ merr "attribute change failed"
+ else
+ minfo "attribute change succeeded"
+ fi
+ ;;
+
esac
}
@@ -2587,6 +2632,14 @@ case $1 in
subscriber "$@"
;;
+ sets)
+ subscriber "$@"
+ ;;
+
+ setn)
+ subscriber "$@"
+ ;;
+
alias|ul|usrloc)
usrloc "$@"
;;
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
index 034ac51..94db676 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
@@ -425,6 +425,8 @@ cat <<EOF
show <username> .................... show subscriber attributes (*)
passwd <username> <passwd> ......... change user's password (*)
rm <username> ...................... delete a user (*)
+ sets <username> <attr> <val> ....... set string attribute (column
value)
+ setn <username> <attr> <val> ....... set numeric attribute (column
value)
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_subscriber"