21.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # tests the authentification via auth_db
  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=21.cfg
  27. # add an registrar entry to the db;
  28. $MYSQL "INSERT INTO subscriber (username, domain, password) VALUES (\"alice\",\"localhost\",\"alice\");"
  29. $BIN -L $MOD_DIR -Y $RUN_DIR -P $PIDFILE -w . -f $CFG -E -e -dd > /dev/null 2>&1
  30. ret=$?
  31. sleep 1
  32. if [ "$ret" -eq 0 ] ; then
  33. sipp -s alice 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 1 -auth_uri alice@localhost -p 5061 -sf reg_auth.xml -ap alice > /dev/null 2>&1 &
  34. ret=$?
  35. fi
  36. if [ "$ret" -eq 0 ] ; then
  37. sipp -s alice 127.0.0.1:5059 -i 127.0.0.1 -m 1 -f 1 -auth_uri alice@localhost -p 5061 -sf inv_auth.xml -ap alice > /dev/null 2>&1 &
  38. ret=$?
  39. fi
  40. sleep 1
  41. #cleanup
  42. kill_kamailio
  43. killall -9 sipp > /dev/null 2>&1
  44. $MYSQL "DELETE FROM subscriber WHERE((username = \"alice\") and (domain = \"localhost\"));"
  45. exit $ret;