From 3b8e258d7a6c881ad71172477e5c761520e38339 Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Tue, 16 Apr 2019 20:56:48 +0300 Subject: [PATCH] opensipsctl: remove fifo and unixsock support most of this functionality has been already moved in the new opensips-cli tool --- Makefile | 15 - packaging/freebsd/Makefile | 8 +- packaging/netbsd/PLIST | 3 - packaging/openbsd/pkg/PLIST | 3 - packaging/redhat_fedora/opensips.spec | 3 - packaging/solaris/base-Prototype | 3 - packaging/solaris/prototype | 3 - packaging/solaris/tls-Prototype | 3 - packaging/suse/opensips.spec.SuSE | 3 - scripts/opensipsctl | 1024 +------------------------ scripts/opensipsctl.8 | 50 +- scripts/opensipsctl.base | 128 +--- scripts/opensipsctl.ctlbase | 74 -- scripts/opensipsctl.fifo | 239 ------ scripts/opensipsctl.unixsock | 118 --- scripts/opensipsctlrc | 13 - scripts/osipsconsolerc | 103 --- 17 files changed, 7 insertions(+), 1786 deletions(-) delete mode 100644 scripts/opensipsctl.ctlbase delete mode 100644 scripts/opensipsctl.fifo delete mode 100644 scripts/opensipsctl.unixsock delete mode 100644 scripts/osipsconsolerc diff --git a/Makefile b/Makefile index a999777f374..a15e4a10c8a 100644 --- a/Makefile +++ b/Makefile @@ -545,21 +545,6 @@ install-bin: $(bin_prefix)/$(bin_dir) opensipsmc utils $(INSTALL_CFG) /tmp/opensipsctl.base \ $(modules_prefix)/$(lib_dir)/opensipsctl/opensipsctl.base rm -fr /tmp/opensipsctl.base - sed -e "s#/usr/local#$(bin-target)#g" \ - < scripts/opensipsctl.ctlbase > /tmp/opensipsctl.ctlbase - $(INSTALL_CFG) /tmp/opensipsctl.ctlbase \ - $(modules_prefix)/$(lib_dir)/opensipsctl/opensipsctl.ctlbase - rm -fr /tmp/opensipsctl.ctlbase - sed -e "s#/usr/local#$(bin-target)#g" \ - < scripts/opensipsctl.fifo > /tmp/opensipsctl.fifo - $(INSTALL_CFG) /tmp/opensipsctl.fifo \ - $(modules_prefix)/$(lib_dir)/opensipsctl/opensipsctl.fifo - rm -fr /tmp/opensipsctl.fifo - sed -e "s#/usr/local#$(bin-target)#g" \ - < scripts/opensipsctl.unixsock > /tmp/opensipsctl.unixsock - $(INSTALL_CFG) /tmp/opensipsctl.unixsock \ - $(modules_prefix)/$(lib_dir)/opensipsctl/opensipsctl.unixsock - rm -fr /tmp/opensipsctl.unixsock sed -e "s#/usr/local#$(bin-target)#g" \ < scripts/opensipsctl.sqlbase > /tmp/opensipsctl.sqlbase $(INSTALL_CFG) /tmp/opensipsctl.sqlbase \ diff --git a/packaging/freebsd/Makefile b/packaging/freebsd/Makefile index 2c1a46fc46c..5d440a2d353 100644 --- a/packaging/freebsd/Makefile +++ b/packaging/freebsd/Makefile @@ -25,11 +25,9 @@ MAKE_ENV= CC="${CC}" \ PTHREAD_LIBS="${PTHREAD_LIBS}" PLIST_FILES= sbin/opensips sbin/opensipsctl sbin/opensipsdbctl sbin/opensipsunix \ - lib/opensips/opensipsctl/opensipsctl.base lib/opensips/opensipsctl/opensipsctl.ctlbase \ - lib/opensips/opensipsctl/opensipsctl.dbtext lib/opensips/opensipsctl/opensipsctl.fifo \ - lib/opensips/opensipsctl/opensipsctl.sqlbase lib/opensips/opensipsctl/opensipsctl.unixsock \ - lib/opensips/opensipsctl/opensipsdbctl.base lib/opensips/opensipsctl/opensipsdbctl.dbtext \ - etc/opensips/opensipsctlrc + lib/opensips/opensipsctl/opensipsctl.base lib/opensips/opensipsctl/opensipsctl.dbtext \ + lib/opensips/opensipsctl/opensipsctl.sqlbase lib/opensips/opensipsctl/opensipsdbctl.base \ + lib/opensips/opensipsctl/opensipsdbctl.dbtext etc/opensips/opensipsctlrc PLIST_DIRS= lib/opensips/modules lib/opensips/opensipsctl lib/opensips diff --git a/packaging/netbsd/PLIST b/packaging/netbsd/PLIST index 1b5aabd9b80..a483079a88d 100644 --- a/packaging/netbsd/PLIST +++ b/packaging/netbsd/PLIST @@ -66,9 +66,6 @@ lib/opensips/modules/xlog.so lib/opensips/modules/xmpp.so lib/opensipsctl/opensipsctl.base lib/opensipsctl/opensipsctl.sqlbase -lib/opensipsctl/opensipsctl.ctlbase -lib/opensipsctl/opensipsctl.fifo -lib/opensipsctl/opensipsctl.unixsock lib/opensipsctl/opensipsctl.mysql share/doc/opensips/README share/doc/opensips/INSTALL diff --git a/packaging/openbsd/pkg/PLIST b/packaging/openbsd/pkg/PLIST index c056b0eb510..0f50ae13ef4 100644 --- a/packaging/openbsd/pkg/PLIST +++ b/packaging/openbsd/pkg/PLIST @@ -66,9 +66,6 @@ lib/opensips/modules/xlog.so lib/opensips/modules/xmpp.so lib/opensipsctl/opensipsctl.base lib/opensipsctl/opensipsctl.sqlbase -lib/opensipsctl/opensipsctl.ctlbase -lib/opensipsctl/opensipsctl.fifo -lib/opensipsctl/opensipsctl.unixsock lib/opensipsctl/opensipsctl.mysql share/doc/opensips/README share/doc/opensips/INSTALL diff --git a/packaging/redhat_fedora/opensips.spec b/packaging/redhat_fedora/opensips.spec index 5cf76202113..bb6eb937da0 100644 --- a/packaging/redhat_fedora/opensips.spec +++ b/packaging/redhat_fedora/opensips.spec @@ -893,11 +893,8 @@ fi %config(noreplace) %{_sysconfdir}/opensips/tls/user/user-privkey.pem %{_libdir}/opensips/opensipsctl/opensipsctl.base -%{_libdir}/opensips/opensipsctl/opensipsctl.ctlbase %{_libdir}/opensips/opensipsctl/opensipsctl.dbtext -%{_libdir}/opensips/opensipsctl/opensipsctl.fifo %{_libdir}/opensips/opensipsctl/opensipsctl.sqlbase -%{_libdir}/opensips/opensipsctl/opensipsctl.unixsock %{_libdir}/opensips/opensipsctl/opensipsdbctl.base %{_libdir}/opensips/opensipsctl/opensipsdbctl.dbtext diff --git a/packaging/solaris/base-Prototype b/packaging/solaris/base-Prototype index 72660a5ab5e..9cfe1dda870 100644 --- a/packaging/solaris/base-Prototype +++ b/packaging/solaris/base-Prototype @@ -129,9 +129,6 @@ f none /opt/opensips/lib64/opensips/modules/xcap_client.so 0755 root root f none /opt/opensips/lib64/opensips/modules/xlog.so 0755 root root d none /opt/opensips/lib64/opensips/opensipsctl 0755 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.base 0644 root root -f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.ctlbase 0644 root root -f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.fifo 0644 root root -f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.unixsock 0644 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.sqlbase 0644 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsdbctl.base 0644 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.dbtext 0644 root root diff --git a/packaging/solaris/prototype b/packaging/solaris/prototype index 2617568db6d..9c9898f9734 100644 --- a/packaging/solaris/prototype +++ b/packaging/solaris/prototype @@ -60,10 +60,7 @@ f none lib/opensips/modules/xlog.so 0755 bin bin f none lib/opensips/modules/xmpp.so 0755 bin bin d none lib/opensipsctl 0644 bin bin f none lib/opensipsctl/opensipsctl.base 0644 bin bin -f none lib/opensipsctl/opensipsctl.ctlbase 0644 bin bin f none lib/opensipsctl/opensipsctl.sqlbase 0644 bin bin -f none lib/opensipsctl/opensipsctl.fifo 0644 bin bin -f none lib/opensipsctl/opensipsctl.unixsock 0644 bin bin f none lib/opensipsctl/opensipsctl.mysql 0644 bin bin d none doc 0755 bin bin d none doc/opensips 0755 bin bin diff --git a/packaging/solaris/tls-Prototype b/packaging/solaris/tls-Prototype index b8e3e860d7c..fb58d931133 100644 --- a/packaging/solaris/tls-Prototype +++ b/packaging/solaris/tls-Prototype @@ -148,9 +148,6 @@ f none /opt/opensips/lib64/opensips/modules/xlog.so 0755 root root f none /opt/opensips/lib64/opensips/modules/tlsops.so 0755 root root d none /opt/opensips/lib64/opensips/opensipsctl 0755 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.base 0644 root root -f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.ctlbase 0644 root root -f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.fifo 0644 root root -f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.unixsock 0644 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.sqlbase 0644 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsdbctl.base 0644 root root f none /opt/opensips/lib64/opensips/opensipsctl/opensipsctl.dbtext 0644 root root diff --git a/packaging/suse/opensips.spec.SuSE b/packaging/suse/opensips.spec.SuSE index a9b1438d6cd..be6b232bc14 100644 --- a/packaging/suse/opensips.spec.SuSE +++ b/packaging/suse/opensips.spec.SuSE @@ -360,13 +360,10 @@ sbin/insserv etc/init.d/ %{_sbindir}/opensipsdbctl %{_libdir}/opensips/opensipsctl/dbtextdb/dbtextdb.py %{_libdir}/opensipsctl/opensipsctl.base -%{_libdir}/opensipsctl/opensipsctl.ctlbase %{_libdir}/opensipsctl/opensipsctl.db_berkeley %{_libdir}/opensipsctl/opensipsctl.dbtext %{_libdir}/opensipsctl/opensipsctl.oracle %{_libdir}/opensipsctl/opensipsctl.sqlbase -%{_libdir}/opensipsctl/opensipsctl.fifo -%{_libdir}/opensipsctl/opensipsctl.unixsock %{_libdir}/opensipsctl/opensipsdbctl.base %{_libdir}/opensipsctl/opensipsdbctl.db_berkeley %{_libdir}/opensipsctl/opensipsdbctl.dbtext diff --git a/scripts/opensipsctl b/scripts/opensipsctl index 0927fb5a365..a9855b45813 100755 --- a/scripts/opensipsctl +++ b/scripts/opensipsctl @@ -139,35 +139,6 @@ elif [ -n "$DBENGINE" ] ; then mwarn "database engine not found - tried '$DBENGINE'" fi -# -##### ------------------------------------------------ ##### -### CTLENGINE -# -CTLENGINELOADED=0 -if [ -z $CTLENGINE ] ; then - CTLENGINE="FIFO" -fi -case $CTLENGINE in - FIFO|fifo) - if [ -f "$MYLIBDIR/opensipsctl.fifo" ]; then - . "$MYLIBDIR/opensipsctl.fifo" - CTLENGINELOADED=1 - fi - ;; - UNIXSOCK|unixsock) - if [ -f "$MYLIBDIR/opensipsctl.unixsock" ]; then - . "$MYLIBDIR/opensipsctl.unixsock" - CTLENGINELOADED=1 - fi - ;; -esac - -if [ $CTLENGINELOADED -eq 1 ] ; then - mdbg "Control engine '$CTLENGINE' loaded" -else - mwarn "no control engine found - tried '$CTLENGINE'" -fi - # ##### ------------------------------------------------ ##### ### common functions @@ -197,13 +168,6 @@ require_dbengine() { fi } -require_ctlengine() { - if [ $CTLENGINELOADED -eq 0 ] ; then - merr "This command requires a control engine - none was loaded" - exit -1 - fi -} - # ##### ------------------------------------------------ ##### ### combined functions (require db and/or ctl) @@ -881,21 +845,6 @@ $AVP_USER_COLUMN='$OSIPSUSER' AND $AVP_DOMAIN_COLUMN='$OSIPSDOMAIN'" esac } # end avpops() -# -##### ------------------------------------------------ ##### -### cisco restart -# -cisco_restart() { - require_ctlengine - myhost=`get_my_host` - RET=`$CTLCMD t_uac_dlg NOTIFY "$1" "." \ - "From: sip:daemon@$myhost" \ - "To: <$1>" "Event: check-sync" \ - "Contact: " "." "." | - head -1 ` - print_status $RET -} - # ##### ------------------------------------------------ ##### ### DB operations @@ -966,14 +915,6 @@ db_ops() { # domain() { case $1 in - reload) - require_ctlengine - $CTLCMD domain_reload - ;; - show) - require_ctlengine - $CTLCMD domain_dump - ;; showdb) require_dbengine QUERY="select * FROM $DOMAIN_TABLE ; " @@ -1026,14 +967,6 @@ domain() { # address() { case $1 in - reload) - require_ctlengine - $CTLCMD address_reload - ;; - dump) - require_ctlengine - $CTLCMD address_dump - ;; show) require_dbengine QUERY="select * FROM $ADDRESS_TABLE ; " @@ -1113,708 +1046,6 @@ address() { esac } -# -##### ------------------------------------------------ ##### -### CARRIERROUTE management -# -cr() { - require_dbengine - require_ctlengine - case $1 in - show) - mecho "cr routing tree" - QUERY="select * FROM $ROUTE_TREE_TABLE ORDER BY $CARRIERROUTE_ROUTE_TREE_PREFIX_COLUMN; " - $DBCMD "$QUERY" - mecho "cr routes" - QUERY="select * FROM $CARRIERROUTE_TABLE ORDER BY \ - $CARRIERROUTE_CARRIERROUTE_CARRIER_COLUMN,\ - $CARRIERROUTE_CARRIERROUTE_SCAN_PREFIX_COLUMN,\ - $CARRIERROUTE_CARRIERROUTE_DOMAIN_COLUMN,\ - $CARRIERROUTE_CARRIERROUTE_PROB_COLUMN;" - $DBCMD "$QUERY" - ;; - reload) - $CTLCMD cr_reload_routes - ;; - - dump) - $CTLCMD cr_dump - ;; - - addrt) - shift - if [ $# -ne 2 ] ; then - merr "cr - missing route_tree" - exit 1 - fi - QUERY="insert into $ROUTE_TREE_TABLE - ( $CARRIERROUTE_ROUTE_TREE_PREFIX_COLUMN, \ - $CARRIERROUTE_ROUTE_TREE_CARRIER_COLUMN) \ - VALUES ($1, '$2');" - $DBCMD "$QUERY" - if [ $? -ne 0 ] ; then - merr "cr - SQL Error" - exit 1 - fi - minfo "execute '$0 cr reload' to synchronize cache and database" - ;; - - rmrt) - shift - if [ $# -ne 1 ] ; then - merr "cr - missing route_tree to be removed" - exit 1 - fi - QUERY="delete from $ROUTE_TREE_TABLE where $CARRIERROUTE_ROUTE_TREE_CARRIER_COLUMN='$1';" - $DBCMD "$QUERY" - if [ $? -ne 0 ] ; then - merr "cr - SQL Error" - exit 1 - fi - minfo "execute '$0 cr reload' to synchronize cache and database" - ;; - - addcarrier) - shift - if [ $# -lt 4 ] ; then - merr "cr - too few parameters" - exit 1 - fi - PROB=1 - STRIP=0 - REWRITE_PREFIX= - REWRITE_SUFFIX= - COMMENT= - FLAGS=0 - MASK=0 - if [ $# -gt 4 ] ; then - PROB=$5 - if [ $# -gt 5 ] ; then - STRIP=$6 - if [ $# -gt 6 ] ; then - REWRITE_PREFIX=$7 - if [ $# -gt 7 ] ; then - REWRITE_SUFFIX=$8 - if [ $# -gt 8 ] ; then - COMMENT=$9 - if [ $# -gt 9 ] ; then - FLAGS=${10} - if [ $# -gt 10 ] ; then - MASK=${11} - fi - fi - fi - fi - fi - fi - fi - CARRIER=$1 - SCAN_PREFIX=$2 - DOMAIN=$3 - REWRITE_HOST=$4 - echo $FLAGS - echo $MASK - QUERY="insert into $CARRIERROUTE_TABLE \ - ( $CARRIERROUTE_CARRIERROUTE_CARRIER_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_SCAN_PREFIX_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_DOMAIN_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_PROB_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_STRIP_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_REWRITE_HOST_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_REWRITE_PREFIX_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_REWRITE_SUFFIX_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_COMMENT_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_FLAGS_COLUMN, \ - $CARRIERROUTE_CARRIERROUTE_MASK_COLUMN ) \ - VALUES ($CARRIER, '$SCAN_PREFIX', '$DOMAIN', $PROB, $STRIP, \ - '$REWRITE_HOST', '$REWRITE_PREFIX', '$REWRITE_SUFFIX', '$COMMENT', \ - $FLAGS, $MASK);" - $DBCMD "$QUERY" - if [ $? -ne 0 ] ; then - merr "cr - SQL Error" - exit 1 - fi - minfo "execute '$0 cr reload' to synchronize cache and database" - ;; - - rmcarrier) - shift - if [ $# -ne 3 ] ; then - merr "cr - too few parameters" - exit 1 - fi - CARRIER=$1 - SCAN_PREFIX=$2 - DOMAIN=$3 - QUERY="delete from $CARRIERROUTE_TABLE where $CARRIERROUTE_CARRIERROUTE_CARRIER_COLUMN='$CARRIER' AND \ - $CARRIERROUTE_CARRIERROUTE_SCAN_PREFIX_COLUMN='$SCAN_PREFIX' AND \ - $CARRIERROUTE_CARRIERROUTE_DOMAIN_COLUMN=$DOMAIN ;" - $DBCMD "$QUERY" - if [ $? -ne 0 ] ; then - merr "cr - SQL Error" - exit 1 - fi - minfo "execute '$0 cr reload' to synchronize cache and database" - ;; - - *) - usage_cr - exit 1 - esac -} - - -# -##### ------------------------------------------------ ##### -### DISPATCHER management -# -dispatcher() { - require_dbengine - require_ctlengine - case $1 in - show) - mecho "dispatcher gateways" - QUERY="select * FROM $DISPATCHER_TABLE ORDER BY $DISPATCHER_SETID_COLUMN; " - $DBCMD "$QUERY" - ;; - addgw) - shift - if [ $# -lt 6 ] ; then - merr "too few parameters" - usage_dispatcher - exit 1 - fi - - if [ $# -gt 6 ] ; then - DISPATCHER_DESCRIPTION=$7 - else - DISPATCHER_DESCRIPTION="" - fi - - DISPATCHER_SETID=$1 - DISPATCHER_DESTINATION=$2 - DISPATCHER_SOCKET=$3 - DISPATCHER_STATE=$4 - DISPATCHER_WEIGHT=$5 - DISPATCHER_ATTRS=$6 - - QUERY="insert into $DISPATCHER_TABLE ($DISPATCHER_SETID_COLUMN, $DISPATCHER_DESTINATION_COLUMN, $DISPATCHER_SOCKET_COLUMN, $DISPATCHER_STATE_COLUMN, $DISPATCHER_WEIGHT_COLUMN, $DISPATCHER_ATTRS_COLUMN, $DISPATCHER_DESCRIPTION_COLUMN) VALUES ($DISPATCHER_SETID, '$DISPATCHER_DESTINATION', '$DISPATCHER_SOCKET', $DISPATCHER_STATE, '$DISPATCHER_WEIGHT', '$DISPATCHER_ATTRS', '$DISPATCHER_DESCRIPTION');" - - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dispatcher - SQL Error" - exit 1 - fi - - $CTLCMD ds_reload - ;; - rmgw) - shift - if [ $# -ne 1 ] ; then - merr "missing gateway id to be removed" - exit 1 - fi - - QUERY="delete from $DISPATCHER_TABLE where $DISPATCHER_ID_COLUMN='$1';" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dispatcher - SQL Error" - exit 1 - fi - - $CTLCMD ds_reload - ;; - reload) - $CTLCMD ds_reload - ;; - - dump) - $CTLCMD ds_list - ;; - - *) - usage_dispatcher - exit 1 - - esac -} - -dr() { - require_dbengine - require_ctlengine - case $1 in - show) - mecho "dr gateways" - QUERY="select * FROM $DR_GATEWAYS_TABLE ORDER BY $DR_GATEWAYS_GWID_COLUMN; " - $DBCMD "$QUERY" - mecho "dr groups" - QUERY="select * FROM $DR_GROUPS_TABLE ORDER BY $DR_GROUPS_GROUPID_COLUMN; " - $DBCMD "$QUERY" - mecho "dr carriers" - QUERY="select * FROM $DR_CARRIERS_TABLE ORDER BY $DR_CARRIERS_CARRIERID_COLUMN; " - $DBCMD "$QUERY" - mecho "dr rules" - QUERY="select * FROM $DR_RULES_TABLE ORDER BY $DR_RULES_GROUPID_COLUMN; " - $DBCMD "$QUERY" - ;; - - addgw) - shift - if [ $# -lt 7 ] ; then - merr "too few parameters" - usage_dr - exit 1 - fi - - if [ $# -gt 7 ] ; then - DR_GATEWAYS_DESCRIPTION=$8 - else - DR_GATEWAYS_DESCRIPTION="" - fi - - DR_GATEWAYS_GWID=$1 - DR_GATEWAYS_TYPE=$2 - DR_GATEWAYS_ADDRESS=$3 - DR_GATEWAYS_STRIP=$4 - DR_GATEWAYS_PRI_PREFIX=$5 - DR_GATEWAYS_ATTRS=$6 - DR_GATEWAYS_PROBE_MODE=$7 - - QUERY="insert into $DR_GATEWAYS_TABLE \ - ( $DR_GATEWAYS_GWID_COLUMN, $DR_GATEWAYS_TYPE_COLUMN, $DR_GATEWAYS_ADDRESS_COLUMN, $DR_GATEWAYS_STRIP_COLUMN, $DR_GATEWAYS_PRI_PREFIX_COLUMN, $DR_GATEWAYS_ATTRS_COLUMN, $DR_GATEWAYS_PROBE_MODE_COLUMN, $DR_GATEWAYS_DESCRIPTION_COLUMN ) \ - VALUES ('$DR_GATEWAYS_GWID', $DR_GATEWAYS_TYPE, '$DR_GATEWAYS_ADDRESS', $DR_GATEWAYS_STRIP, '$DR_GATEWAYS_PRI_PREFIX', '$DR_GATEWAYS_ATTRS', $DR_GATEWAYS_PROBE_MODE, '$DR_GATEWAYS_DESCRIPTION' );" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - rmgw) - shift - if [ $# -ne 1 ] ; then - merr "missing gateway id to be removed" - exit 1 - fi - - QUERY="delete from $DR_GATEWAYS_TABLE where $DR_GATEWAYS_ID_COLUMN='$1';" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - - addcr) - shift - if [ $# -lt 4 ] ; then - merr "too few parameters" - usage_dr - exit 1 - fi - - if [ $# -gt 4 ] ; then - DR_CARRIERS_DESCRIPTION=$5 - else - DR_CARRIERS_DESCRIPTION="" - fi - - DR_CARRIERS_CARRIERID=$1 - DR_CARRIERS_GWLIST=$2 - DR_CARRIERS_FLAGS=$3 - DR_CARRIERS_ATTRS=$4 - - QUERY="insert into $DR_CARRIERS_TABLE \ - ( $DR_CARRIERS_CARRIERID_COLUMN, $DR_CARRIERS_GWLIST_COLUMN, $DR_CARRIERS_FLAGS_COLUMN, $DR_CARRIERS_ATTRS_COLUMN, $DR_CARRIERS_DESCRIPTION_COLUMN ) \ - VALUES ('$DR_CARRIERS_CARRIERID', '$DR_CARRIERS_GWLIST', $DR_CARRIERS_FLAGS, '$DR_CARRIERS_ATTRS', '$DR_CARRIERS_DESCRIPTION' );" - mecho "$QUERY" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - rmcr) - shift - if [ $# -ne 1 ] ; then - merr "missing gateway id to be removed" - exit 1 - fi - - QUERY="delete from $DR_CARRIERS_TABLE where $DR_CARRIERS_ID_COLUMN='$1';" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - - addgrp) - shift - if [ $# -lt 3 ] ; then - merr "too few parameters" - usage_dr - exit 1 - fi - - if [ $# -gt 3 ] ; then - DR_GROUPS_DESCRIPTION=$4 - else - DR_GROUPS_DESCRIPTION="" - fi - - DR_GROUPS_USERNAME=$1 - DR_GROUPS_DOMAIN=$2 - DR_GROUPS_GROUPID=$3 - - QUERY="insert into $DR_GROUPS_TABLE \ - ( $DR_GROUPS_USERNAME_COLUMN, $DR_GROUPS_DOMAIN_COLUMN, $DR_GROUPS_GROUPID_COLUMN, $DR_GROUPS_DESCRIPTION_COLUMN ) \ - VALUES ('$DR_GROUPS_USERNAME', '$DR_GROUPS_DOMAIN', $DR_GROUPS_GROUPID, '$DR_GROUPS_DESCRIPTION' );" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - rmgrp) - shift - if [ $# -ne 1 ] ; then - merr "missing gateway id to be removed" - exit 1 - fi - - QUERY="delete from $DR_GROUPS_TABLE where $DR_GROUPS_ID_COLUMN='$1';" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - - addrule) - shift - if [ $# -lt 7 ] ; then - merr "too few parameters" - usage_dr - exit 1 - fi - - if [ $# -gt 7 ] ; then - DR_RULES_DESCRIPTION=$8 - else - DR_RULES_DESCRIPTION="" - fi - - DR_RULES_GROUPID=$1 - DR_RULES_PREFIX=$2 - DR_RULES_TIMEREC=$3 - DR_RULES_PRIORITY=$4 - DR_RULES_ROUTEID=$5 - DR_RULES_GWLIST=$6 - DR_RULES_ATTRS=$7 - - QUERY="insert into $DR_RULES_TABLE \ - ( $DR_RULES_GROUPID_COLUMN, $DR_RULES_PREFIX_COLUMN, $DR_RULES_TIMEREC_COLUMN, $DR_RULES_PRIORITY_COLUMN, $DR_RULES_ROUTEID_COLUMN, $DR_RULES_GWLIST_COLUMN, $DR_RULES_ATTRS_COLUMN, $DR_RULES_DESCRIPTION_COLUMN ) \ - VALUES ('$DR_RULES_GROUPID', '$DR_RULES_PREFIX', '$DR_RULES_TIMEREC', $DR_RULES_PRIORITY, '$DR_RULES_ROUTEID', '$DR_RULES_GWLIST', '$DR_RULES_ATTRS', '$DR_RULES_DESCRIPTION' );" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - rmrule) - shift - if [ $# -ne 1 ] ; then - merr "missing rule id to be removed" - exit 1 - fi - - QUERY="delete from $DR_RULES_TABLE where $DR_RULES_RULEID_COLUMN='$1';" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dr - SQL Error" - exit 1 - fi - - $CTLCMD dr_reload - ;; - - reload) - $CTLCMD dr_reload - ;; - - gw_status) - $CTLCMD dr_gw_status - ;; - - carrier_status) - $CTLCMD dr_carrier_status - ;; - - *) - usage_dr - exit 1 - - esac -} - -# -##### ------------------------------------------------ ##### -### DIALPLAN management -# -dialplan() { - require_dbengine - require_ctlengine - case $1 in - show) - shift - if [ $# -gt 0 ] ; then - mecho "dialplan $1 tables" - QUERY="select * FROM $DIALPLAN_TABLE WHERE $DIALPLAN_DPID_COLUMN=$1 ORDER BY $DIALPLAN_PR_COLUMN ; " - else - mecho "dialplan tables" - QUERY="select * FROM $DIALPLAN_TABLE ORDER BY $DIALPLAN_DPID_COLUMN, $DIALPLAN_PR_COLUMN; " - fi - $DBCMD "$QUERY" - ;; - - addrule) - shift - if [ $# -lt 8 ] ; then - merr "too few parameters" - usage_dialplan - exit 1 - fi - - DIALPLAN_DPID=$1 - DIALPLAN_PR=$2 - DIALPLAN_MATCH_OP=$3 - case $DIALPLAN_MATCH_OP in - equal) - DIALPLAN_MATCH_OP=0 - ;; - regexp) - DIALPLAN_MATCH_OP=1 - ;; - *) - merr "dialplan - unexpected $DIALPLAN_MATCH_OP for operating matching. Use 'equal' or 'regexp'!" - exit 1 - esac - DIALPLAN_MATCH_EXP=$4 - DIALPLAN_MATCH_FLAGS=$5 - DIALPLAN_SUBST_EXP=$6 - DIALPLAN_REPL_EXP=$7 - DIALPLAN_ATTRS=$8 - - QUERY="insert into $DIALPLAN_TABLE \ - ( $DIALPLAN_DPID_COLUMN, $DIALPLAN_PR_COLUMN, $DIALPLAN_MATCH_OP_COLUMN, \ - $DIALPLAN_MATCH_EXP_COLUMN, $DIALPLAN_MATCH_FLAGS_COLUMN, \ - $DIALPLAN_SUBST_EXP_COLUMN, $DIALPLAN_REPL_EXP_COLUMN, \ - $DIALPLAN_ATTRS_COLUMN ) \ - VALUES ( $DIALPLAN_DPID, $DIALPLAN_PR, $DIALPLAN_MATCH_OP, \ - '$DIALPLAN_MATCH_EXP', $DIALPLAN_MATCH_FLAGS, '$DIALPLAN_SUBST_EXP', \ - '$DIALPLAN_REPL_EXP', '$DIALPLAN_ATTRS')"; - mecho "$QUERY" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dialplan - SQL Error" - exit 1 - fi - - $CTLCMD dp_reload - ;; - - rm) - QUERY="delete from $DIALPLAN_TABLE; " - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dialplan - SQL Error" - exit 1 - fi - - $CTLCMD dp_reload - ;; - - rmdpid) - shift - if [ $# -lt 1 ] ; then - merr "too few parameters" - usage_dialplan - exit 1 - fi - - DIALPLAN_DPID=$1 - - QUERY="delete from $DIALPLAN_TABLE where $DIALPLAN_DPID_COLUMN=$DIALPLAN_DPID; " - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dialplan - SQL Error" - exit 1 - fi - - $CTLCMD dp_reload - ;; - - rmrule) - shift - if [ $# -lt 2 ] ; then - merr "too few parameters" - usage_dialplan - exit 1 - fi - - DIALPLAN_DPID=$1 - DIALPLAN_PR=$2 - - QUERY="delete from $DIALPLAN_TABLE where $DIALPLAN_DPID_COLUMN=$DIALPLAN_DPID AND $DIALPLAN_PR_COLUMN=$DIALPLAN_PR; " - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "dialplan - SQL Error" - exit 1 - fi - - $CTLCMD dp_reload - ;; - - reload) - $CTLCMD dp_reload - ;; - - *) - usage_dialplan - exit 1 - - esac -} - -# -##### ------------------------------------------------ ##### -### REGISTRANT management -# -registrant() { - require_dbengine - require_ctlengine - case $1 in - show) - mecho "registrant table" - QUERY="select * FROM $REGISTRANT_TABLE ORDER BY $REGISTRANT_AOR_COLUMN; " - $DBCMD "$QUERY" - ;; - - dump) - $CTLCMD reg_list - ;; - - add) - shift - if [ $# -lt 9 ] ; then - merr "too few parameters" - usage_dialplan - exit 1 - fi - - REGISTRANT_REGISTRAR=$1 - REGISTRANT_PROXY=$2 - REGISTRANT_AOR=$3 - REGISTRANT_THIRD_PARTY_REGISTRANT=$4 - REGISTRANT_USERNAME=$5 - REGISTRANT_PASSWORD=$6 - REGISTRANT_BINDING_URI=$7 - REGISTRANT_BINDING_PARAMS=$8 - REGISTRANT_EXPIRY=$9 - REGISTRANT_FORCED_SOCKET=${10} - - QUERY="insert into $REGISTRANT_TABLE\ - ( $REGISTRANT_REGISTRAR_COLUMN,\ - $REGISTRANT_PROXY_COLUMN, $REGISTRANT_AOR_COLUMN,\ - $REGISTRANT_THIRD_PARTY_REGISTRANT_COLUMN,\ - $REGISTRANT_USERNAME_COLUMN,\ - $REGISTRANT_PASSWORD_COLUMN,\ - $REGISTRANT_BINDING_URI_COLUMN,\ - $REGISTRANT_BINDING_PARAMS_COLUMN,\ - $REGISTRANT_EXPIRY_COLUMN,\ - $REGISTRANT_FORCED_SOCKET_COLUMN)\ - VALUES ( '$REGISTRANT_REGISTRAR', '$REGISTRANT_PROXY',\ - '$REGISTRANT_AOR',\ - '$REGISTRANT_THIRD_PARTY_REGISTRANT',\ - '$REGISTRANT_USERNAME', '$REGISTRANT_PASSWORD',\ - '$REGISTRANT_BINDING_URI',\ - '$REGISTRANT_BINDING_PARAMS',\ - $REGISTRANT_EXPIRY, '$REGISTRANT_FORCED_SOCKET')"; - #mecho "$QUERY" - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "registrant - SQL Error" - exit 1 - fi - - #$CTLCMD reg_reload - ;; - rm) - QUERY="delete from $REGISTRANT_TABLE; " - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "registrant - SQL Error" - exit 1 - fi - - #$CTLCMD reg_reload - ;; - - rmaor) - shift - if [ $# -lt 1 ] ; then - merr "too few parameters" - usage_registrant - exit 1 - fi - - REGISTRANT_ID=$1 - - QUERY="delete from $REGISTRANT_TABLE where $REGISTRANT_ID_COLUMN=$REGISTRANT_ID; " - $DBCMD "$QUERY" - - if [ $? -ne 0 ] ; then - merr "registrant - SQL Error" - exit 1 - fi - - #$CTLCMD reg_reload - ;; - *) - usage_registrant - exit 1 - esac -} # ##### ------------------------------------------------ ##### @@ -1884,18 +1115,6 @@ opensips_stop() { fi } -# -##### ------------------------------------------------ ##### -### options_ping -# -options_ping() { - myhost=`get_my_host` - require_ctlengine - CMD="t_uac_dlg OPTIONS \"$1\" \".\" \".\" \"From:sip:daemon@$myhost"$'\r\n'"To:<$1>"$'\r\n'"Contact:sip:daemon@$myhost"$'\r\n'"\"" - RET=`$CTLCMD $CMD | head -1` - print_status $RET -} - # ##### ------------------------------------------------ ##### ### rpid management @@ -2295,169 +1514,10 @@ WHERE $SUBSCRIBER_COLUMN='$OSIPSUSER' and $REALM_COLUMN='$OSIPSDOMAIN';" fi ;; - rm) - if [ $# -ne 2 ] ; then - usage_subscriber - exit 1 - fi - - require_ctlengine - shift - - is_user $1 - if [ $? -ne 0 ] ; then - merr "non-existent user '$1'" - exit 1 - fi - - # begin with remove all user's privileges - acl revoke $1 > /dev/null 2>&1 - - # destroy db-aliases - QUERY="delete from $DA_TABLE where $DA_USER_COLUMN='$OSIPSUSER' \ -and $DA_DOMAIN_COLUMN='$OSIPSDOMAIN';" - $DBCMD "$QUERY" - - - # destroy the user now - QUERY="delete from $SUB_TABLE where $SUBSCRIBER_COLUMN='$OSIPSUSER' \ -and $REALM_COLUMN='$OSIPSDOMAIN';" - $DBCMD "$QUERY" - - # and also all his contacts - $0 ul rm $1 > /dev/null 2>&1 - ;; esac } -# -##### ================================================ ##### -### USRLOC management -# -usrloc() { - if [ $# -lt 2 ] ; then - merr "usrloc - too few parameters" - usage_usrloc - exit 1 - fi - - require_ctlengine - - if [ "$1" = "ul" ] ; then - USRLOC_TABLE="$UL_TABLE" - if [ -z $USRLOC_TABLE ] ; then - USRLOC_TABLE=location - fi - CHECK_SUB=0 - elif [ "$1" = "usrloc" ] ; then - USRLOC_TABLE="$UL_TABLE" - if [ -z $USRLOC_TABLE ] ; then - USRLOC_TABLE=location - fi - CHECK_SUB=0 - else - merr "usrloc - unknown subcommand '$1'" - usage_usrloc - exit 1 - fi - shift - - case "$1" in - show) - if [ $# -eq 2 ] ; then - if [ "$2" = "--brief" ] ; then - $CTLCMD ul_dump brief - else - set_user $2 - $CTLCMD ul_show_contact \ - $USRLOC_TABLE "$OSIPSUSER@$OSIPSDOMAIN" - fi - elif [ $# -eq 1 ] ; then - $CTLCMD ul_dump - else - merr "wrong number of params" - usage_usrloc - exit 1 - fi - exit $? - ;; - add) - if [ $# -eq 3 ] ; then - # expires 0 means persistent contact - UL_EXPIRES=0 - UL_FLAGS=0 - BR_FLAGS=0 - elif [ $# -eq 4 ] ; then - UL_EXPIRES=$4 - UL_FLAGS=0 - BR_FLAGS=0 - else - usage_usrloc - exit 1 - fi - shift - check_uri "$2" - - if [ $? -ne 0 ] ; then - merr "$2 is not a valid URI" - exit 1 - fi - - set_user $1 - if [ $CHECK_SUB -ne 0 ] ; then - is_user $1 - if [ $? -eq 0 ] ; then - merr "overlap of alias with an existing subscriber name" - exit 1; - fi - fi - - check_alias $OSIPSUSER $OSIPSDOMAIN - if [ $ALIAS_EXISTS -eq 1 ] ; then - if [ $CHECK_SUB -ne 0 ] ; then - minfo "alias already defined" - else - merr "AOR is an alias" - fi - exit 1 - fi - - $CTLCMD ul_add "$USRLOC_TABLE" "$OSIPSUSER@$OSIPSDOMAIN" "$2" \ -"$UL_EXPIRES" "1.00" "0" "$UL_FLAGS" "$BR_FLAGS" "$ALL_METHODS" - exit $? - ;; - rm) - if [ $# -eq 2 ] ; then - shift - set_user $1 - $CTLCMD ul_rm $USRLOC_TABLE "$OSIPSUSER@$OSIPSDOMAIN" - - elif [ $# -eq 3 ] ; then - shift - set_user $1 - check_uri "$2" - if [ $? -ne 0 ] ; then - merr "$2 is not a valid SIP URI (sip:[user@]domain)" - exit 1 - fi - - $CTLCMD ul_rm_contact $USRLOC_TABLE "$OSIPSUSER@$OSIPSDOMAIN" "$2" - - else - merr "wrong number of params" - usage_usrloc - exit 1 - fi - ;; - - *) - usage_usrloc - exit 1 - ;; - esac -} - ##### ================================================ ##### ### TLS CA management # @@ -2618,22 +1678,7 @@ opensips_trap() { >$LOG_FILE if [ -z "$TRAP_PIDS" ]; then - # we cannot timeout a shell function -- run it as a subshell - ($CTLCMD ps >$LOG_FILE; rm $PID_FILE) & - ctlpid=$! - echo $ctlpid >$PID_FILE - (sleep 1.5; if [ -e $PID_FILE ]; then pkill -P $ctlpid; fi) &>/dev/null & - killerpid=$! - wait $ctlpid - pkill -P $killerpid - - if [ $(stat -c %s $LOG_FILE) -eq 0 ]; then - # all failed - one last desperate attempt at obtaining the pids - echo "opensipsctl 'ps' command timed out!" - osips_pids=($(pidof opensips | xargs -n1 | sort -n)) - else - osips_pids=($(sed -e 's/.*PID=\([0-9]*\).*/\1/' $LOG_FILE)) - fi + osips_pids=($(pidof opensips | xargs -n1 | sort -n)) else osips_pids=($(echo $TRAP_PIDS | xargs -n1 | sort -n)) fi @@ -2699,14 +1744,6 @@ case $1 in avpops "$@" ;; - cisco_restart) - if [ $# -ne 2 ] ; then - usage_cisco_restart - exit 1 - fi - cisco_restart $2 - ;; - db) shift db_ops "$@" @@ -2727,64 +1764,6 @@ case $1 in address "$@" ;; - fifo|unixsock) - require_ctlengine - shift - $CTLCMD "$@" - ;; - - cr) - shift - cr "$@" - ;; - - dispatcher) - shift - dispatcher "$@" - ;; - - dr) - shift - dr "$@" - ;; - - dialplan) - shift - dialplan "$@" - ;; - - registrant) - shift - registrant "$@" - ;; - - monitor|console|moni|con) - require_ctlengine - $OPENSIPS_MONITOR "$@" - ;; - - online) - require_ctlengine - $CTLCMD ul_dump | $EGREP -i aor | awk '{print $2}' | sort | sort -mu - exit $? - ;; - - ping) - # error handling is hacked -- filter_fl should not - # consume positive status -- that should be done by - # calling app - if [ $# -ne 2 ] ; then - usage_ping - exit 1 - fi - options_ping $2 - ;; - - ps) - require_ctlengine - $CTLCMD ps - ;; - restart) opensips_stop restart sleep 2 @@ -2805,7 +1784,6 @@ case $1 in ;; trap) - require_ctlengine opensips_trap ;; diff --git a/scripts/opensipsctl.8 b/scripts/opensipsctl.8 index 4bccea82f3f..192cf8d1f69 100644 --- a/scripts/opensipsctl.8 +++ b/scripts/opensipsctl.8 @@ -16,7 +16,7 @@ opensipsctl \- opensips control tool .B opensipsctl is a shell script to control .B OpenSIPS SIP server -It can be used to manage users, domains, aliases and other server options +It can be used to manage users, aliases and other server options .SH FILES .PD 0 @@ -31,21 +31,8 @@ It can be used to manage users, domains, aliases and other server options .TP 12 .B \-h Displays a short usage description, including all available options. -.TP -.B moni -show internal status -.TP -.B ps -show running processes -.TP -.B fifo -send raw FIFO commands -.TP .B ping ping a URI (OPTIONS) -.TP -.B cisco_restart -restart a Cisco phone (NOTIFY) .TP 16 .I SUBSCRIBER management: .TP @@ -91,21 +78,6 @@ remove an alias (*) .B alias_db help help message .TP -.B dispatcher show -show dispatcher gateways -.TP -.B dispatcher reload -reload dispatcher gateways -.TP -.B dispatcher dump -show in memory dispatcher gateways -.TP -.B dispatcher addgw [description] -add gateway -.TP -.B dispatcher rmgw -delete gateway -.TP .B speeddial show show speeddial details .TP @@ -149,29 +121,9 @@ grant user membership (*) .B acl revoke [] grant user membership(s) (*) -.TP 16 -.I USRLOC (User Location) management -.TP -.B ul show [] -show in-RAM online users -.TP -.B ul rm [] -delete user's UsrLoc entries -.TP -.B ul add -introduce a permanent UrLoc entry -.TP -.B ul add -introduce a temporary UrLoc entry -.TP -.B showdb [] -show online users flushed in DB .TP 16 .I DOMAIN management .TP -.B domain show -show list of served domains -.TP .B domain add add a new served domain .TP diff --git a/scripts/opensipsctl.base b/scripts/opensipsctl.base index e91edf0858f..9afb1099844 100644 --- a/scripts/opensipsctl.base +++ b/scripts/opensipsctl.base @@ -400,26 +400,6 @@ EOF } USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_acl" -usage_cr() { - echo - mecho " -- command 'cr' - manage carrierroute tables" - echo -cat < ..................... add a tree - cr rmrt ....................................... rm a tree - cr addcarrier ................ - ............... - .........................add a carrier - (prob, strip, rewrite_prefix, rewrite_suffix,................... - flags, mask and comment are optional arguments) ............... - cr rmcarrier ................ rm a carrier -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_cr" - usage_rpid() { echo mecho " -- command 'rpid' - manage Remote-Party-ID (RPID)" @@ -434,24 +414,21 @@ USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_rpid" usage_subscriber() { echo - mecho " -- command 'add|passwd|rm' - manage subscribers" + mecho " -- command 'add|passwd' - manage subscribers" echo cat < .......... add a new subscriber (*) passwd ......... change user's password (*) - rm ...................... delete a user (*) EOF } USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_subscriber" usage_address() { echo - mecho " -- command 'add|dump|reload|rm|show' - manage address" + mecho " -- command 'add|rm|show' - manage address" echo cat < [] [] ....................... add a new entry ....................... (from_pattern and tag are optional arguments) @@ -461,93 +438,6 @@ EOF } USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_address" -usage_dr() { - echo - mecho " -- command 'dr' - manage dynamic routing" - echo -cat <
- - ................................. add gateway - dr rmgw ....................... delete gateway - dr addgrp - ................................. add gateway group - dr rmgrp ...................... delete gateway group - dr addcr - ........................... add carrier - dr rmcr ....................... delete carrier - dr addrule - - ................................. add rule - dr rmrule ................. delete rule - dr reload .......................... reload dr tables - dr gw_status ....................... show gateway status - dr carrier_status .................. show carrier status -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_dr" - -usage_dispatcher() { - echo - mecho " -- command 'dispatcher' - manage dispatcher" - echo -cat < [description] - .......................... add gateway - dispatcher rmgw ................ delete gateway -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_dispatcher" - -usage_dialplan() { - echo - mecho " -- command 'dialplan' - manage dialplans" - echo -cat < .............. show dialplan tables - dialplan reload ................... reload dialplan tables - dialplan addrule - - .................... add a rule - dialplan rm ....................... removes the entire dialplan table - dialplan rmdpid ............ removes all the gived dpid entries - dialplan rmrule ..... removes all the gived dpid/prio entries -EOF -} - -usage_registrant() { - echo - mecho " -- command 'registrant' - manage registrants" - echo -cat < - - . add a registrant - registrant rm ........................... removes the entire registrant table - registrant rmaor ................... removes the gived aor id -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_registrant" - ##### ----------------------------------------------- ##### #### Common functions @@ -675,20 +565,6 @@ print_status() { fi } -# process output from FIFO/Unixsock server; if everything is ok -# skip the first "ok" line and proceed to returned -# parameters -filter_fl() -{ -# tail +2 - - $AWK 'BEGIN {line=0;IGNORECASE=1;} - {line++} - NR == 1 && /^200 OK/ { next } - /^$/ { next } - { print }' -} - # params: user, realm, password # output: HA1 _gen_ha1() diff --git a/scripts/opensipsctl.ctlbase b/scripts/opensipsctl.ctlbase deleted file mode 100644 index 893c00ea037..00000000000 --- a/scripts/opensipsctl.ctlbase +++ /dev/null @@ -1,74 +0,0 @@ -# -# $Id: opensipsctl.ctlbase 3511 2008-01-08 10:20:46Z henningw $ -# -# sc: opensips control; tool for maintaining opensips -# -#=================================================================== - -##### ----------------------------------------------- ##### -### common variables and functions for CTL engines -# - -# period in which stats are reprinted -if [ -z "$WATCH_PERIOD" ] ; then - WATCH_PERIOD=2 -fi - -# -##### ------------------------------------------------ ##### -### usage functions -# -usage_cisco_restart() { - echo - mecho " -- command 'cisco_restart' - restart CISCO phone (NOTIFY)" - echo -cat < ................ restart phone configured for -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_cisco_restart" - -usage_online() { - echo - mecho " -- command 'online' - dump online users from memory" - echo -cat < ......................... ping with SIP OPTIONS -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_ping" - -usage_usrloc() { - echo - mecho " -- command 'ul' - manage user location records" - echo -cat <]................ show in-RAM online users - ul show --brief..................... show in-RAM online users in short format - ul rm [].... delete user's usrloc entries - ul add ............ introduce a permanent usrloc entry - ul add .. introduce a temporary usrloc entry -EOF -} -USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_usrloc" - diff --git a/scripts/opensipsctl.fifo b/scripts/opensipsctl.fifo deleted file mode 100644 index 70cf7cbe583..00000000000 --- a/scripts/opensipsctl.fifo +++ /dev/null @@ -1,239 +0,0 @@ -# -# $Id$ -# -# opensips control tool for maintaining opensips -# -#=================================================================== - -##### ----------------------------------------------- ##### -### FIFO specific variables and functions -# - -##### ----------------------------------------------- ##### -### load CTL base -# -if [ -f "$MYLIBDIR/opensipsctl.ctlbase" ]; then - . "$MYLIBDIR/opensipsctl.ctlbase" -else - mwarn "Cannot load CTL core functions '$MYLIBDIR/opensipsctl.ctlbase' ..." - # exit -1 -fi - -# -##### ----------------------------------------------- ##### -### parameters -# -if [ -z "$OSIPS_FIFO" ]; then - OSIPS_FIFO=/tmp/opensips_fifo -fi - -# -##### ----------------------------------------------- ##### -### functions -# -usage_fifo() { - echo - mecho " -- command 'fifo'" - echo -cat < /dev/null 2>&1 && break - done - name=osips_rply_$suffix - path=$CHROOT_DIR/tmp/$name - - # construct the command now - CMD=":$name:{\"jsonrpc\":\"2.0\",\"method\":\"$1\",\"id\":\"$suffix\""; - shift - if [ -n "${1}" ]; then - PARAMS=",\"params\":[\"${1}\"" - shift - while [ -n "${1}" ] ; do - PARAMS="${PARAMS},\"${1}\"" - shift - done - PARAMS="${PARAMS}]" - else - PARAMS="" - fi - CMD="${CMD}${PARAMS}}" - - trap "rm -f $path; kill 0" INT TERM - - # start reader now so that it is ready for replies - # immediately after a request was sent out - cat $path | python -c "import json,sys; print(json.dumps(json.load(sys.stdin), indent=3))" & - - # TODO: handle errors - - if [ -n "$FLOCK" ]; then - # on most systems, the umask is 0002 or 0022. This makes it difficult - # to run 'opensipsctl' on different users (root, then opensips), as - # the latter will not have write access to the lockfile - OLD_UMASK=$(umask) - umask 0 - - ( - # prevent interwoven writes to the FIFO file from - # opensipsctl processes running in parallel - $FLOCK -x -w 10 200 || exit 1 - - # issue FIFO request (printf taken to deal with \n) - printf "$CMD" > $OSIPS_FIFO - ) 200>$CHROOT_DIR/tmp/$(echo $OSIPS_FIFO | sed 's#/#%#g').lock - - umask $OLD_UMASK - else - # issue FIFO request (printf taken to deal with \n) - printf "$CMD" > $OSIPS_FIFO - fi - - # wait for the reader to complete - wait - rm $path - - mdbg "FIFO command was:\n$CMD" -} - - -CTLCMD=fifo_cmd - -fifo_opensips_monitor() { - name=opensips_receiver_$$ - path=$CHROOT_DIR/tmp/$name - if [ ! -w $OSIPS_FIFO ]; then - merr "Error opening OpenSIPS's FIFO $OSIPS_FIFO" - merr "Make sure you have the line 'modparam(\"mi_fifo\", \"fifo_name\", \"$OSIPS_FIFO\")' in your config" - merr "and also have loaded the mi_fifo module." - exit 1 - fi - if ! test -p $path; then - mkfifo $path - if [ $? -ne 0 ] ; then - merr "monitor - error opening read fifo $path" - exit 1 - fi - chmod a+w $path - fi - trap "rm $path; clear; echo monitor ^C-ed; exit 1" 2 - attempt=0 - if [ "$2" = "" ]; then - loops=-1; - else - loops=$2; - fi - clear - while [ $loops -ne $attempt ] ; do - attempt=`$EXPR $attempt + 1` - #clear - tput clear - - # print_stats $name $path $attempt - mecho "[cycle #: $attempt; if constant make sure server lives]" - - cat < $path | filter_fl & - cat > $OSIPS_FIFO < $OSIPS_FIFO << EOF -:uptime:$name - -EOF - wait - echo - - mecho "Transaction Statistics: " - cat < $path | filter_fl & - cat > $OSIPS_FIFO < $OSIPS_FIFO < $OSIPS_FIFO <