kamdbctl.dbtext 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #
  2. # Script for adding and dropping Kamailio DBTEXT tables
  3. #
  4. # History:
  5. # 2007-02-14 Branch from mysqldb.sh script and adapt minimal capabilities(Cesc Santasusana)
  6. #
  7. # 2007-05-31 Move common definitions to kamdbctl.base file (henningw)
  8. # 2007-06-13 Move database definitions out of this script, use a common
  9. # control tool for database tasks, like the kamctl (henning)
  10. # path to the database schemas
  11. DATA_DIR="/usr/local/share/kamailio"
  12. if [ -d "$DATA_DIR/dbtext/kamailio" ] ; then
  13. DB_SCHEMA="$DATA_DIR/dbtext/kamailio"
  14. else
  15. DB_SCHEMA="./dbtext/kamailio"
  16. fi
  17. # path to the dbtext database
  18. if [ -z "$DB_PATH" ] ; then
  19. DB_PATH="/usr/local/etc/kamailio/dbtext"
  20. fi
  21. kamailio_drop() # pars: <database name>
  22. {
  23. if [ $# -ne 1 ] ; then
  24. merr "kamailio_drop function takes one param"
  25. exit 1
  26. fi
  27. DB_PATH=$1
  28. minfo "DBTEXT ... erasing all files at: $DB_PATH"
  29. rm -rf $DB_PATH
  30. }
  31. kamailio_create () # pars: <database name>
  32. {
  33. if [ $# -ne 1 ] ; then
  34. merr "kamailio_create function takes one param (DB_PATH)"
  35. exit 1
  36. fi
  37. DB_PATH=$1
  38. minfo "creating DBTEXT tables at: $DB_PATH ..."
  39. mkdir -p $DB_PATH
  40. for TABLE in $STANDARD_TABLES; do
  41. mdbg "Creating core table: $TABLE"
  42. cp $DB_SCHEMA/$TABLE $DB_PATH/$TABLE
  43. if [ $? -ne 0 ] ; then
  44. merr "Creating core tables failed!"
  45. exit 1
  46. fi
  47. done
  48. get_answer $INSTALL_PRESENCE_TABLES "Install presence related tables? (y/n): "
  49. if [ "$ANSWER" = "y" ]; then
  50. presence_create $1
  51. fi
  52. get_answer $INSTALL_EXTRA_TABLES "Install tables for $EXTRA_MODULES? (y/n): "
  53. if [ "$ANSWER" = "y" ]; then
  54. extra_create $1
  55. fi
  56. }
  57. presence_create () # pars: <database name>
  58. {
  59. if [ $# -ne 1 ] ; then
  60. merr "presence_create function takes one param (DB_PATH)"
  61. exit 1
  62. fi
  63. DB_PATH=$1
  64. minfo "creating DBTEXT presence tables at: $DB_PATH ..."
  65. mkdir -p $DB_PATH
  66. for TABLE in $PRESENCE_TABLES; do
  67. mdbg "Creating presence table: $TABLE"
  68. cp $DB_SCHEMA/$TABLE $DB_PATH/$TABLE
  69. if [ $? -ne 0 ] ; then
  70. merr "Creating presence tables failed!"
  71. exit 1
  72. fi
  73. done
  74. } # end presence_create
  75. extra_create () # pars: <database name>
  76. {
  77. if [ $# -ne 1 ] ; then
  78. merr "extra_create function takes one param"
  79. exit 1
  80. fi
  81. minfo "creating DBTEXT extra tables at: $DB_PATH ..."
  82. for TABLE in $EXTRA_TABLES; do
  83. mdbg "Creating extra table: $TABLE"
  84. cp $DB_SCHEMA/$TABLE $DB_PATH/$TABLE
  85. if [ $? -ne 0 ] ; then
  86. merr "Creating extra tables failed!"
  87. exit 1
  88. fi
  89. done
  90. } # end extra_create