29.sh 1.9 KB

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