2
0

24.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # creates a postgres database with kamailiodbctl and deletes it again
  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. # Needs a mysql database, the root user password must be given
  21. # in the file 'dbrootpw' in the test directory
  22. . include/common
  23. if [ ! -f ~/.pgpass ] ; then
  24. echo "no .pgpass file, not run"
  25. exit 0
  26. fi ;
  27. tmp_name=""$RANDOM"_kamailiodb_tmp"
  28. cd ../../utils/kamctl/
  29. # setup config file
  30. cp $CTLRC $CTLRC.bak
  31. sed -i "s/# DBENGINE=MYSQL/DBENGINE=PGSQL/g" $CTLRC
  32. sed -i "s/# INSTALL_EXTRA_TABLES=ask/INSTALL_EXTRA_TABLES=yes/g" $CTLRC
  33. sed -i "s/# INSTALL_PRESENCE_TABLES=ask/INSTALL_PRESENCE_TABLES=yes/g" $CTLRC
  34. cp $DBCTL $DBCTL.bak
  35. sed -i "s/TEST=\"false\"/TEST=\"true\"/g" $DBCTL
  36. ./$DBCTL create $tmp_name &> /dev/null
  37. ret=$?
  38. if [ "$ret" -eq 0 ] ; then
  39. ./$DBCTL drop $tmp_name &> /dev/null
  40. ret=$?
  41. fi ;
  42. # cleanup
  43. mv $CTLRC.bak $CTLRC
  44. mv $DBCTL.bak $DBCTL
  45. cd -
  46. exit $ret