Module: sip-router
Branch: master
Commit: cff8540d95c53ee3972205e838f4528f67f9357b
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cff8540…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Sep 20 11:04:46 2010 +0200
kamctl: more auto-discovery for sercmd
- try locations like same dir with kamctl, or ../sercmd/ in case is run
from sources
- default names for sercmd commands are 'sercmd' and 'sercmd_mi' to
match tool name as ser is another application, old names can still be
used
---
utils/kamctl/kamctl | 41 ++++++++++++++++++++++++++++++++++-------
utils/kamctl/kamctl.ser | 12 ++++--------
utils/kamctl/kamctl.ser_mi | 10 +++-------
3 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 09a0fb8..e5252a5 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -6,6 +6,9 @@
#
#===================================================================
+### version for this script
+VERSION='3.1.0'
+
PATH=$PATH:/usr/local/sbin/
# for testing only, please don't enable this in production environments
@@ -36,9 +39,6 @@ if [ -z "$ETCDIR" ] ; then
ETCDIR="/usr/local/etc/kamailio"
fi
-### version for this script
-VERSION='$Revision$'
-
if [ -z "$MYDIR" ] ; then
MYDIR=`dirname $0`
fi
@@ -50,6 +50,33 @@ if [ -z "$MYLIBDIR" ] ; then
fi
fi
+# locate sercmd
+if [ -z "$SERCMD" ] ; then
+ # try same dir as kamctl
+ SERCMD="$MYDIR/sercmd"
+ if [ ! -f "$SERCMD" -o ! -x "$SERCMD" ] ; then
+ # try standard location installed from sources
+ SERCMD="/usr/local/sbin/sercmd"
+ if [ ! -f "$SERCMD" -o ! -x "$SERCMD" ] ; then
+ # try source tree location
+ SERCMD="$MYDIR/../sercmd/sercmd"
+ if [ ! -f "$SERCMD" -o ! -x "$SERCMD" ] ; then
+ # try locate it with which
+ SERCMD=`which sercmd`
+ if [ ! -f "$SERCMD" -o ! -x "$SERCMD" ] ; then
+ merr "sercmd tool not found"
+ exit -1;
+ fi
+ fi
+ fi
+ fi
+else
+ if [ ! -f "$SERCMD" -o ! -x "$SERCMD" ] ; then
+ merr "SERCMD does not point to an executable file"
+ exit -1;
+ fi
+fi
+
##### ------------------------------------------------ #####
### load base functions
#
@@ -127,7 +154,7 @@ case $CTLENGINE in
CTLENGINELOADED=1
fi
;;
- SER_MI|ser_mi)
+ SER_MI|ser_mi|SERCMD_MI|sercmd_mi|SERCMDMI|sercmdmi)
if [ -f "$MYLIBDIR/kamctl.ser_mi" ]; then
. "$MYLIBDIR/kamctl.ser_mi"
CTLENGINELOADED=1
@@ -136,7 +163,7 @@ case $CTLENGINE in
esac
#### ------------------------------------------------- #####
-### Load sercm interface
+### Load sercmd interface
#
if [ -f "$MYLIBDIR/kamctl.ser" ]; then
. "$MYLIBDIR/kamctl.ser"
@@ -2326,13 +2353,13 @@ case $1 in
trusted "$@"
;;
- fifo|unixsock|ser_mi)
+ fifo|unixsock|ser_mi|sercmd_mi|sercmdmi)
require_ctlengine
shift
$CTLCMD "$@"
;;
- ser)
+ ser|sercmd)
shift
$SERCTLCMD "$@"
;;
diff --git a/utils/kamctl/kamctl.ser b/utils/kamctl/kamctl.ser
index b70deed..f84c8f0 100644
--- a/utils/kamctl/kamctl.ser
+++ b/utils/kamctl/kamctl.ser
@@ -23,10 +23,6 @@ fi
##### ----------------------------------------------- #####
### parameters
#
-SERCMD=`which sercmd`
-if [ -z "$SERCMD" ] ; then
- SERCMD="/usr/local/sbin/sercmd"
-fi
#
##### ----------------------------------------------- #####
@@ -34,10 +30,10 @@ fi
#
usage_ser() {
echo
- mecho " -- command 'ser'"
+ mecho " -- command 'sercmd'"
echo
cat <<EOF
- ser ............................... send command thru sercmd
+ sercmd ............................. send command through sercmd
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ser"
@@ -45,10 +41,10 @@ USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ser"
ser_cmd()
{
- mdbg "entering ser_mi_cmd $*"
+ mdbg "entering ser_cmd $*"
if [ "$#" -lt 1 ]; then
- merr "ser_cmd must take at least command name as parameter"
+ merr "sercmd must take at least command name as parameter"
exit 1
fi
diff --git a/utils/kamctl/kamctl.ser_mi b/utils/kamctl/kamctl.ser_mi
index fdf247c..aad7dad 100644
--- a/utils/kamctl/kamctl.ser_mi
+++ b/utils/kamctl/kamctl.ser_mi
@@ -23,10 +23,6 @@ fi
##### ----------------------------------------------- #####
### parameters
#
-SERCMD=`which sercmd`
-if [ -z "$SERCMD" ] ; then
- SERCMD="/usr/local/sbin/sercmd"
-fi
#
##### ----------------------------------------------- #####
@@ -34,10 +30,10 @@ fi
#
usage_ser_mi() {
echo
- mecho " -- command 'ser_mi'"
+ mecho " -- command 'sercmd_mi'"
echo
cat <<EOF
- ser ............................... send mi command thru sercmd
+ sercmd_mi ............................. send mi command through sercmd
EOF
}
USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ser_mi"
@@ -48,7 +44,7 @@ ser_mi_cmd()
mdbg "entering ser_mi_cmd $*"
if [ "$#" -lt 1 ]; then
- merr "ser_cmd must take at least command name as parameter"
+ merr "sercmd_mi must take at least command name as parameter"
exit 1
fi