"Fossies" - the Fresh Open Source Software Archive

Member "opensips-3.0.1/test/29.sh" (16 Apr 2019, 1923 Bytes) of package /linux/misc/opensips-3.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "29.sh": 2.4.5_vs_3.0.0.

    1 #!/bin/bash
    2 # tests simple cpl_c script operations with postgres
    3 
    4 # Copyright (C) 2008 1&1 Internet AG
    5 #
    6 # This file is part of opensips, a free SIP server.
    7 #
    8 # opensips is free software; you can redistribute it and/or modify
    9 # it under the terms of the GNU General Public License as published by
   10 # the Free Software Foundation; either version 2 of the License, or
   11 # (at your option) any later version
   12 #
   13 # opensips is distributed in the hope that it will be useful,
   14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16 # GNU General Public License for more details.
   17 #
   18 # You should have received a copy of the GNU General Public License
   19 # along with this program; if not, write to the Free Software
   20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   21 
   22 source include/require
   23 
   24 if ! (check_sipp && check_opensips && check_module "db_postgres" && check_module "cpl_c"); then
   25     exit 0
   26 fi ;
   27 
   28 CFG=28.cfg
   29 CPL=cpl_ignore.xml
   30 TMPFILE=`mktemp -t opensips-test.XXXXXXXXXX`
   31 
   32 cp $CFG $CFG.tmp
   33 echo "loadmodule \"db_postgres/db_postgres.so\"" >> $CFG
   34 echo "modparam(\"cpl_c\", \"db_url\", \"postgres://opensips:opensipsrw@localhost/opensips\")" >> $CFG
   35 
   36 
   37 ../opensips -w . -f $CFG &> /dev/null;
   38 ret=$?
   39 sleep 1
   40 
   41 opensips-cli -x mi LOAD_CPL sip:alice@127.0.0.1 $CPL
   42 
   43 if [ "$ret" -eq 0 ] ; then
   44     sipp -m 1 -f 1 127.0.0.1:5060 -sf cpl_test.xml &> /dev/null;
   45     ret=$?
   46 fi;
   47 
   48 if [ "$ret" -eq 0 ] ; then
   49   opensips-cli -x mi GET_CPL sip:alice@127.0.0.1 > $TMPFILE 
   50   diff $TMPFILE $CPL 
   51   ret=$?
   52 fi; 
   53 
   54 if [ "$ret" -eq 0 ] ; then
   55   opensips-cli -x mi REMOVE_CPL sip:alice@127.0.0.1
   56   opensips-cli -x mi GET_CPL sip:alice@127.0.0.1 > $TMPFILE
   57 fi;
   58 
   59 diff $TMPFILE $CPL &> /dev/null;
   60 ret=$?
   61 
   62 if [ ! "$ret" -eq 0 ] ; then
   63   ret=0
   64 fi;
   65 
   66 #cleanup:
   67 killall -9 opensips &> /dev/null;
   68 killall -9 sipp &> /dev/null;
   69 rm $TMPFILE
   70 mv $CFG.tmp $CFG
   71 
   72 exit $ret;