File: exec_s5b.cfg

package info (click to toggle)
kamailio 4.2.0-2%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (80 lines) | stat: -rw-r--r-- 2,032 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
# $Id$
#
# simple quick-start config script
#
fork=no
log_stderror=yes
# ----------- global configuration parameters ------------------------

loadmodule "modules/sl/sl.so"
loadmodule "modules/tm/tm.so"
loadmodule "modules/usrloc/usrloc.so"
loadmodule "modules/registrar/registrar.so"
loadmodule "modules/exec/exec.so"

# ----------------- setting module-specific parameters ---------------

route{
	# uri for my domain ?
	if (uri==myself) {

		if (method=="REGISTER") {
			save("location");
			break;
		};

		# native SIP destinations are handled using our USRLOC DB
		if (!lookup("location")) {
			# proceed to email notification
			if (method=="INVITE") route(1)
			else sl_send_reply("404", "Not Found");
			break;
		};
	};
	# user found, forward to his current uri now; if any 
	# forwarding error occurs (e.g., busy or cancelled recevied
	# from downstream), proceed to reply_route[1]
	t_on_failure("1");
	if (!t_relay()) {
		sl_reply_error();
	};
}

/* handling of missed calls */
route[1] {
	# don't continue if it is a retransmission
	if ( !t_newtran()) {
		sl_reply_error();
		break;
	};
	# external script: lookup user, if user exists, send 
	# an email notification to him
     	if (!exec_msg('
		QUERY="select email_address from subscriber 
			where username=\"$SIP_OUSER\"";
		EMAIL=`mysql  -Bsuser -pheslo -e "$QUERY" ser`;
		if [ -z "$EMAIL" ] ; then exit 1; fi ;
		echo "SIP request received from $SIP_HF_FROM for $SIP_OUSER" |
		mail -s "request for you" $EMAIL ')) 
	{
		# exec returned error ... user does not exist
		# send a stateful reply
		t_reply("404", "User does not exist");
	} else {
		t_reply("600", "No messages for this user");
	};
	break;
}

failure_route[1] {
	# just call exec, that's it
   	exec_msg('
		QUERY="select email_address from subscriber 
			where username=\"$SIP_OUSER\"";
		EMAIL=`mysql  -Bsuser -pheslo -e "$QUERY" ser`;
		if [ -z "$EMAIL" ] ; then exit 1; fi ;
		echo "SIP request received from $SIP_HF_FROM for $SIP_OUSER" |
		mail -s "request for you" $EMAIL ') ;
	t_relay();
}