exec_s5b.cfg 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #
  2. # $Id$
  3. #
  4. # simple quick-start config script
  5. #
  6. fork=no
  7. log_stderror=yes
  8. # ----------- global configuration parameters ------------------------
  9. loadmodule "modules/sl/sl.so"
  10. loadmodule "modules/tm/tm.so"
  11. loadmodule "modules/usrloc/usrloc.so"
  12. loadmodule "modules/registrar/registrar.so"
  13. loadmodule "modules/exec/exec.so"
  14. # ----------------- setting module-specific parameters ---------------
  15. route{
  16. # uri for my domain ?
  17. if (uri==myself) {
  18. if (method=="REGISTER") {
  19. save("location");
  20. break;
  21. };
  22. # native SIP destinations are handled using our USRLOC DB
  23. if (!lookup("location")) {
  24. # proceed to email notification
  25. if (method=="INVITE") route(1)
  26. else sl_send_reply("404", "Not Found");
  27. break;
  28. };
  29. };
  30. # user found, forward to his current uri now; if any
  31. # forwarding error occurs (e.g., busy or cancelled received
  32. # from downstream), proceed to failure_route[1]
  33. t_on_failure("1");
  34. if (!t_relay()) {
  35. sl_reply_error();
  36. };
  37. }
  38. /* handling of missed calls */
  39. route[1] {
  40. # don't continue if it is a retransmission
  41. if ( !t_newtran()) {
  42. sl_reply_error();
  43. break;
  44. };
  45. # external script: lookup user, if user exists, send
  46. # an email notification to him
  47. if (!exec_msg('
  48. QUERY="select email_address from subscriber
  49. where username=\"$SIP_OUSER\"";
  50. EMAIL=`mysql -Bsuser -pheslo -e "$QUERY" ser`;
  51. if [ -z "$EMAIL" ] ; then exit 1; fi ;
  52. echo "SIP request received from $SIP_HF_FROM for $SIP_OUSER" |
  53. mail -s "request for you" $EMAIL '))
  54. {
  55. # exec returned error ... user does not exist
  56. # send a stateful reply
  57. t_reply("404", "User does not exist");
  58. } else {
  59. t_reply("600", "No messages for this user");
  60. };
  61. break;
  62. }
  63. failure_route[1] {
  64. # just call exec, that's it
  65. exec_msg('
  66. QUERY="select email_address from subscriber
  67. where username=\"$SIP_OUSER\"";
  68. EMAIL=`mysql -Bsuser -pheslo -e "$QUERY" ser`;
  69. if [ -z "$EMAIL" ] ; then exit 1; fi ;
  70. echo "SIP request received from $SIP_HF_FROM for $SIP_OUSER" |
  71. mail -s "request for you" $EMAIL ') ;
  72. t_relay();
  73. }