40.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # check pike module
  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. # Needs a default kamailio database setup for mysql
  21. source include/common
  22. source include/require
  23. source include/database
  24. CFG=40.cfg
  25. SRV=5060
  26. UAS=5070
  27. UAC=5080
  28. if ! (check_sipp && check_kamailio && check_module "db_mysql" && check_mysql); then
  29. exit 0
  30. fi ;
  31. # add an registrar entry to the db;
  32. $MYSQL "INSERT INTO location (username,contact,socket,user_agent,cseq,q) VALUES (\"foo\",\"sip:[email protected]:$UAS\",\"udp:127.0.0.1:$UAS\",\"ser_test\",1,-1);"
  33. # start
  34. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG &> /dev/null
  35. ret=$?
  36. # this should work
  37. if [ "$ret" -eq 0 ]; then
  38. sipp -sn uas -bg -i 127.0.0.1 -m 10 -p $UAS &> /dev/null
  39. sipp -sn uac -s foo 127.0.0.1:$SRV -i 127.0.0.1 -m 10 -p $UAC &> /dev/null
  40. ret=$?
  41. fi;
  42. # this should be trigger the blocking
  43. if [ "$ret" -eq 0 ]; then
  44. killall -9 sipp > /dev/null 2>&1
  45. sipp -sn uas -bg -i 127.0.0.1 -m 11 -p $UAS &> /dev/null
  46. sipp -sn uac -s foo 127.0.0.1:$SRV -i 127.0.0.1 -m 11 -p $UAC &> /dev/null
  47. ret=$?
  48. fi;
  49. # this should work again after the timeout
  50. if [ "$ret" -eq 1 ]; then
  51. sleep 7
  52. killall -9 sipp > /dev/null 2>&1
  53. sipp -sn uas -bg -i 127.0.0.1 -m 15 -p $UAS &> /dev/null
  54. sipp -sn uac -s foo 127.0.0.1:$SRV -i 127.0.0.1 -m 15 -p $UAC &> /dev/null
  55. ret=$?
  56. fi;
  57. sleep 1
  58. kill_kamailio
  59. killall -9 sipp > /dev/null 2>&1
  60. $MYSQL "DELETE FROM location WHERE ((contact = \"sip:[email protected]:$UAS\") and (user_agent = \"ser_test\"));"
  61. exit $ret