12.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/sh
  2. # configuration with pseudo-variables, transformations and xlog output
  3. # Copyright (C) 2007 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. CFG=12.cfg
  23. TMPFILE=`mktemp -t kamailio-test.XXXXXXXXXX`
  24. if ! (check_netcat && check_kamailio); then
  25. exit 0
  26. fi ;
  27. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > $TMPFILE 2>&1
  28. ret=$?
  29. if ( have_netcat_quit_timer_patch ); then
  30. NCOPTS='-q 1'
  31. else
  32. NCOPTS='-w 1'
  33. fi
  34. sleep 1
  35. if [ "$ret" -eq 0 ] ; then
  36. # register a user
  37. cat register.sip | nc $NCOPTS -u localhost 5060 > /dev/null
  38. $CTL ul show | grep '"AoR":"1000"' > /dev/null
  39. ret=$?
  40. # unregister the user
  41. cat unregister.sip | nc $NCOPTS -u localhost 5060 > /dev/null
  42. fi ;
  43. if [ "$ret" -eq 0 ] ; then
  44. $CTL ul show | grep '"AoR":"1000"' > /dev/null
  45. ret=$?
  46. if [ "$ret" -eq 0 ] ; then
  47. ret=1
  48. else
  49. ret=0
  50. fi ;
  51. fi ;
  52. if [ "$ret" -eq 0 ] ; then
  53. grep "method: register, transport: UDP:127.0.0.1:5060, user agent: Twinkle/1.0" $TMPFILE > /dev/null
  54. ret=$?
  55. if [ "$ret" -eq 0 ] ; then
  56. grep "Getting identity from FROM URI" $TMPFILE > /dev/null
  57. ret=$?
  58. if [ "$ret" -eq 0 ] ; then
  59. grep "My identity: sip:[email protected]" $TMPFILE > /dev/null
  60. ret=$?
  61. if [ "$ret" -eq 0 ] ; then
  62. grep "var(x): sip:[email protected], MD5 var(x): b6c3d120cfd9e85addf64ee8943f4eec" $TMPFILE > /dev/null
  63. ret=$?
  64. if [ "$ret" -eq 0 ] ; then
  65. grep "Contact header field present" $TMPFILE > /dev/null
  66. ret=$?
  67. if [ "$ret" -eq 0 ] ; then
  68. grep "this is an registration" $TMPFILE > /dev/null
  69. ret=$?
  70. if [ "$ret" -eq 0 ] ; then
  71. grep "this is an unregistration" $TMPFILE > /dev/null
  72. ret=$?
  73. fi;
  74. fi ;
  75. fi ;
  76. fi ;
  77. fi ;
  78. fi ;
  79. fi ;
  80. kill_kamailio
  81. rm $TMPFILE
  82. exit $ret