17.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # load all modules without external dependencies with db_berkeley
  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. if ! (check_kamailio && check_module "db_berkeley" ); then
  23. exit 0
  24. fi ;
  25. CFG=17.cfg
  26. tmp_name=""$RANDOM"_kamailiodb_tmp"
  27. printf "loadmodule \"db_berkeley/db_berkeley.so\"" > $CFG
  28. cat 2.cfg >> $CFG
  29. printf "modparam(\"$DB_ALL_MOD\", \"db_url\", \"berkeley://`pwd`/$CTL_DIR/$tmp_name\")" >> $CFG
  30. printf "\nrequest_route {\n ;\n}" >> $CFG
  31. # setup config file
  32. cp $CTLRC $CTLRC.bak
  33. sed -i'' -e "s/# DBENGINE=MYSQL/DBENGINE=DB_BERKELEY/g" $CTLRC
  34. sed -i'' -e "s/# INSTALL_EXTRA_TABLES=ask/INSTALL_EXTRA_TABLES=yes/g" $CTLRC
  35. sed -i'' -e "s/# INSTALL_PRESENCE_TABLES=ask/INSTALL_PRESENCE_TABLES=yes/g" $CTLRC
  36. sed -i'' -e "s/# INSTALL_DBUID_TABLES=ask/INSTALL_DBUID_TABLES=yes/g" $CTLRC
  37. cp $DBCTL $DBCTL.bak
  38. sed -i'' -e "s/TEST=\"false\"/TEST=\"true\"/g" $DBCTL
  39. CRT_DIR=`pwd`
  40. cd $CTL_DIR
  41. $DBCTL create $tmp_name > /dev/null
  42. ret=$?
  43. cd $CRT_DIR
  44. if [ "$ret" -eq 0 ] ; then
  45. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -a no > /dev/null
  46. ret=$?
  47. fi ;
  48. sleep 1
  49. kill_kamailio
  50. # cleanup
  51. cd $CTL_DIR
  52. $DBCTL drop $tmp_name > /dev/null
  53. cd $CRT_DIR
  54. mv $CTLRC.bak $CTLRC
  55. mv $DBCTL.bak $DBCTL
  56. rm $CFG
  57. exit $ret