33.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. # test cfgutils and pv 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. . include/common
  21. . include/require.sh
  22. if ! (check_netcat && check_kamailio); then
  23. exit 0
  24. fi;
  25. if ( have_netcat_quit_timer_patch ); then
  26. NCOPTS='-q 1'
  27. else
  28. NCOPTS='-w 2'
  29. fi;
  30. CFG=33.cfg
  31. CORE=$(sysctl kern.corefile 2> /dev/null)
  32. echo $CORE | grep '^kern.corefile: %N\.core' > /dev/null
  33. ret=$?
  34. if [ $ret -eq 0 ] ; then
  35. CORE='kamailio.core'
  36. else
  37. CORE='core'
  38. fi
  39. if [ -e $CORE ] ; then
  40. echo "core file found, not run"
  41. exit 0
  42. fi;
  43. cp $CFG $CFG.bak
  44. ulimit -c unlimited
  45. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null
  46. ret=$?
  47. sleep 1
  48. if [ $ret -eq 0 ] ; then
  49. $CTL rpc cfgutils.check_config_hash | grep '"result":"Identical hash"' > /dev/null
  50. ret=$?
  51. fi;
  52. echo " " >> $CFG
  53. if [ $ret -eq 0 ] ; then
  54. $CTL rpc cfgutils.check_config_hash | grep '"result":"Identical hash"' > /dev/null
  55. ret=$?
  56. fi
  57. if [ ! $ret -eq 0 ] ; then
  58. # send a message
  59. cat register.sip | nc $NCOPTS -u 127.0.0.1 5060 > /dev/null
  60. fi
  61. sleep 1
  62. kill_kamailio 2> /dev/null
  63. ret=$?
  64. if [ $ret -eq 0 ] ; then
  65. ret=1
  66. else
  67. ret=0
  68. fi
  69. if [ ! -e $CORE ] ; then
  70. ret=1
  71. fi
  72. rm -f $CORE
  73. mv $CFG.bak $CFG
  74. exit $ret