46.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. #Check configuration framework implementation in k modules
  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. . include/database.sh
  23. if ! (check_sipp && check_kamailio && check_module "db_mysql" && check_mysql ); then
  24. exit 0
  25. fi ;
  26. CFG=11.cfg
  27. SRV=5060
  28. UAS=5070
  29. UAC=5080
  30. test_module_int()
  31. {
  32. if [ x$# != x3 ] ; then
  33. echo "wrong number of params : usage test_module module cfg_param value"
  34. return 1
  35. fi
  36. MODNAME="$1"
  37. MODPARAM="$2"
  38. MODVAL="$3"
  39. if [ x$ret = x0 ] ; then
  40. $SERCMD cfg.set_now_int $MODNAME $MODPARAM $MODVAL &>/dev/null
  41. ret=$?
  42. fi
  43. if [ x$ret = x0 ] ; then
  44. val=$($SERCMD cfg.get $MODNAME $MODPARAM)
  45. ret=$?
  46. if [ x"$val" = x$MODVAL ] ; then
  47. # echo "check ok"
  48. ret=0;
  49. else
  50. # echo "check failed"
  51. ret=1
  52. fi
  53. fi
  54. return $ret
  55. }
  56. # add an registrar entry to the db
  57. cp $CFG ${CFG}.bak
  58. echo "loadmodule \"db_mysql/db_mysql.so\"" >>$CFG
  59. echo "loadmodule \"ctl/ctl.so\"" >> $CFG
  60. echo "loadmodule \"cfg_rpc/cfg_rpc.so\"" >> $CFG
  61. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG &> /dev/null
  62. ret=$?
  63. sleep 1
  64. SERCMD="../../utils/sercmd/sercmd"
  65. if [ ! -x $SERCMD ] ; then
  66. ret=1
  67. echo "SERCMD executable not found"
  68. fi
  69. test_module_int registrar default_expires 100
  70. ret=$?
  71. # cleanup
  72. killall -9 sipp > /dev/null 2>&1
  73. kill_kamailio
  74. mv ${CFG}.bak $CFG
  75. exit $ret;