examples/exec_s5.cfg
5eb5c40d
 #
 # $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 (!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 
eca3bd17
 			where user=\"$SIP_OUSER\"";
5eb5c40d
 		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;
 }