14.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # loads a carrierroute config for loadbalancing from config file
  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=14.cfg
  23. if ! (check_kamailio && check_module "carrierroute" ); then
  24. exit 0
  25. fi ;
  26. cp $CFG $CFG.bak
  27. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null
  28. ret=$?
  29. sleep 1
  30. TMPFILE=`mktemp -t kamailio-test.XXXXXXXXXX`
  31. if [ "$ret" -eq 0 ] ; then
  32. $CTL fifo cr_dump_routes > $TMPFILE
  33. ret=$?
  34. fi ;
  35. if [ "$ret" -eq 0 ] ; then
  36. tmp=`grep -v "Printing routing information:
  37. Printing tree for carrier 'default' (1)
  38. Printing tree for domain 'register' (1)
  39. NULL: 0.000 %, 'test1': OFF, '0', '', '', ''
  40. NULL: 50.000 %, 'test2.localdomain': ON, '0', '', '', ''
  41. NULL: 50.000 %, 'test3.localdomain': ON, '0', '', '', ''
  42. Printing tree for domain 'proxy' (2)
  43. 2: 87.610 %, 'test7.localdomain': ON, '0', '', '', ''
  44. 2: 12.516 %, 'test8.localdomain': ON, '0', '', '', ''
  45. 42: 70.070 %, 'test4': ON, '0', '', '', ''
  46. 42: 20.020 %, 'test5.localdomain': ON, '0', '', '', ''
  47. 42: 10.010 %, 'test6.localdomain': ON, '0', '', '', ''
  48. 49: 0.000 %, 'test5.localdomain': OFF, '0', '', '', ''
  49. 49: 44.444 %, 'test4': ON, '0', '', '', ''
  50. 49: 55.556 %, 'test6.localdomain': ON, '0', '', '', ''
  51. Printing tree for domain 'other' (3)
  52. NULL: 0.000 %, 'test1': OFF, '0', '', '', ''
  53. NULL: 50.000 %, 'test2.localdomain': OFF, '0', '', '', ''
  54. Rule is backed up by: test3.localdomain
  55. NULL: 50.000 %, 'test3.localdomain': ON, '0', '', '', ''
  56. Rule is backup for: test2.localdomain" $TMPFILE`
  57. if [ "$tmp" = "" ] ; then
  58. ret=0
  59. else
  60. ret=1
  61. fi ;
  62. fi ;
  63. kill_kamailio
  64. mv $CFG.bak $CFG
  65. rm -f $TMPFILE
  66. exit $ret