Browse code

iptel.cfg removed from cvs

Jiri Kuthan authored on 27/05/2003 23:11:48
Showing 2 changed files
1 1
deleted file mode 100644
... ...
@@ -1,554 +0,0 @@
1
-#
2
-# $Id$
3
-#
4
-# iptel.org real world configuration
5
-#
6
-
7
-# ----------- global configuration parameters ------------------------
8
-
9
-debug=3
10
-fork=yes
11
-port=5060
12
-log_stderror=no
13
-memlog=4
14
-
15
-listen=195.37.77.101
16
-
17
-# uncomment to override config values for test 
18
-/*
19
-debug=4             # debug level (cmd line: -ddd)
20
-fork=no
21
-port=5068
22
-log_stderror=yes	# (cmd line: -E)
23
-*/
24
-
25
-check_via=yes       # (cmd. line: -v)
26
-dns=no              # (cmd. line: -r)
27
-rev_dns=no          # (cmd. line: -R)
28
-children=4
29
-fifo="/tmp/ser_fifo"
30
-# if changing fifo mode to a more restrictive value, put
31
-# decimal value in there, e.g. dec(rw|rw|rw)=dec(666)=438
32
-#fifo_mode=438
33
-
34
-# ------------------ module loading ----------------------------------
35
-
36
-loadmodule "../new_ser/modules/tm/tm.so"
37
-loadmodule "../new_ser/modules/sl/sl.so"
38
-loadmodule "../new_ser/modules/acc/acc.so"
39
-loadmodule "../new_ser/modules/rr/rr.so"
40
-loadmodule "../new_ser/modules/maxfwd/maxfwd.so"
41
-loadmodule "../new_ser/modules/mysql/mysql.so"
42
-loadmodule "../new_ser/modules/usrloc/usrloc.so"
43
-loadmodule "../new_ser/modules/registrar/registrar.so"
44
-loadmodule "../new_ser/modules/auth/auth.so"
45
-loadmodule "../new_ser/modules/textops/textops.so"
46
-
47
-# ----------------- setting module-specific parameters ---------------
48
-
49
-# -- usrloc params --
50
-
51
-/* 0 -- dont use mysql, 1 -- write_through, 2--write_back */
52
-modparam("usrloc", "db_mode",   2)
53
-modparam("usrloc", "timer_interval", 10)
54
-modparam("usrloc", "db_url","sql://ser:heslo@dbhost/ser")
55
-
56
-# -- auth params --
57
-
58
-#modparam("auth", "calculate_ha1", yes)
59
-
60
-modparam("auth", "db_url","sql://ser:heslo@dbhost/ser")
61
-modparam("auth", "user_column",   "user")
62
-# nonce generation secret; particularly useful if multiple servers
63
-# in a proxy farm are configured to authenticate
64
-#modparam("auth", "secret", "43sjkl33T9kjj_5jvlA384hg")
65
-
66
-modparam("auth", "nonce_expire",  300)
67
-modparam("auth", "retry_count",   5)
68
-
69
-# -- acc params --
70
-# report ACKs too for sake of completeness -- as we account PSTN
71
-# destinations which are RR, ACKs should show up
72
-modparam("acc", "report_ack", 1)
73
-modparam("acc", "log_level", 1)
74
-# that is the flag for which we will account -- don't forget to
75
-# set the same one :-)
76
-/* Usage of flags is as follows: 1==should account(all to gateway), 
77
-   2==should rr (all to gateway, MESSAGES, etc), 3==should report 
78
-   on missed calls (transactions to iptel.org's users), 4==destination
79
-   user wishes to use voicemail
80
-*/
81
-modparam("acc", "acc_flag", 1 )
82
-modparam("acc", "missed_flag", 3 )
83
-
84
-# -- tm params --
85
-modparam("tm", "fr_timer", 20 )
86
-modparam("tm", "fr_inv_timer", 90 )
87
-modparam("tm", "wt_timer", 20 )
88
-modparam("tm", "uac_from", "sip:daemon@iptel.org" )
89
-
90
-# -------------------------  request routing logic -------------------
91
-
92
-# main routing logic
93
-
94
-route{
95
-
96
-	/* ********* ROUTINE CHECKS  ********************************** */
97
-
98
-	# filter too old messages
99
-	if (!mf_process_maxfwd_header("10")) {
100
-		log("LOG: Too many hops\n");
101
-		sl_send_reply("483","Too Many Hops");
102
-		break;
103
-	};
104
-	if (len_gt( max_len )) {
105
-		sl_send_reply("513", "Wow -- Message too large");
106
-		break;
107
-	};
108
-
109
-	# Make sure that requests dont advertise addresses 
110
-	# from private IP space (RFC1918) in Contact HF
111
-	# (note: does not match with folded lines)
112
-	if (search("^(Contact|m): .*@(192\.168\.|10\.|172\.16)")) {
113
-		# allow RR-ed requests, as these may indicate that
114
-		# a NAT-enabled proxy takes care of it; unless it is
115
-		# a REGISTER
116
-		if ((method=="REGISTER" || ! search("^Record-Route:")) 
117
-					&& !( src_ip==192.168.0.0/16 ||
118
-						src_ip==10.0.0.0/8 || src_ip==172.16.0.0/12 )) {
119
-			log("LOG: Someone trying to register from private IP again\n");
120
-			sl_send_reply("479", "We dont accept private IP contacts" );
121
-			break;
122
-		};
123
-	};
124
-
125
-	/* ********* RR ********************************** */
126
-
127
-	/* Do strict routing if route headers present */
128
-	rewriteFromRoute();
129
-
130
-	/* ********* DIVERSION ********************************** */
131
-	/* apply all diversions before we proceed with processing of
132
-	   requests for us
133
-	*/
134
-
135
-
136
-	/* IM gateway diversions */
137
-	if (search("[\n\r]((To)|t):.*@icq\.iptel\.org")
138
-	| search("[\n\r]((To)|t):.*@msn\.iptel\.org")
139
-	| search("[\n\r]((To)|t):.*@aim\.iptel\.org")
140
-	| search("[\n\r]((To)|t):.*@yahoo\.iptel\.org")
141
-	| search("[\n\r]((To)|t):.*@jabber\.iptel\.org") )
142
-	{
143
-		append_hf("P-hint: IMGW\r\n");
144
-		if (!t_relay_to("195.37.77.100", "5070")) {
145
-			sl_reply_error();
146
-		};
147
-		break;
148
-	};
149
-
150
-	/* divert voicemail requests */
151
-	if (uri=~"mail\.iptel\.org" | uri=~":5066"| uri=~":6060") {
152
-		sethost("iptel.org");
153
-		append_hf("P-hint: VOICEMAIL\r\n");
154
-		if ( !t_relay_to("fox.iptel.org", "6060")) {
155
-			sl_reply_error();
156
-		};
157
-		break;
158
-	};
159
-
160
-	# this host is excempted from default processing for our domain
161
-	# for testing purposes
162
-	if (uri=~"@bat\.iptel\.org") {
163
-		append_hf("P-hint: BATTEST\r\n");
164
-		forward("bat.iptel.org", 5060);
165
-		break;
166
-	};
167
-
168
-	/* ********* RR ********************************** */
169
-
170
-	# look at whether we need record-routing; 
171
-	# - we need it for calls  from gateways (otherwise, subsequent 
172
-	#   requests from the other # party will attempt to contact gateway 
173
-	#  	directly through blocked ports)
174
-	# - we need it for Windows Messanger's IM sessions to cross
175
-	#   some firewalls -- we force all MESSAGEs to go via our server
176
-	#   to avoid blocking port numbers (some firewalls can do
177
-	#   standard SIP but are puzzled by Microsoft's use of obsoleted
178
-	#   IM session model)
179
-	# - some other places may decide to set the record-routing
180
-	#   flag (2 chosen) too; particularly, INVITEs to our gw
181
-	if ( (src_ip==195.37.77.110 & method=="INVITE") || method=="MESSAGE" || method=="INFO" )  {
182
-		setflag(2);
183
-	};
184
-
185
-
186
-	/*  *********  check for requests targeted out of our domain... ******* */
187
-	# sign of our domain: there is @ (username), :
188
-    # (nothing) or . (host) in front of our domain name	;
189
-	# if none of these cases matches, proceed with proessing of
190
-	# outbound requests in route[2]
191
-	if (!(uri=~"[@:\.]iptel\.org([;:].*)*" 
192
-			# ... some phones put IP address in URI instead ...
193
-			| uri=~"[@:\.]195\.37\.77\.101([;:].*)*" 
194
-			# ... and we serve our gateway too (we RR requests to it, so that
195
-			# its address may show up in subsequent requests after
196
-			# rewriteFromRoute
197
-			| uri=~"@195\.37\.77\.110([;:].*)*" )) {
198
-		route(2);
199
-		break;
200
-	};
201
-
202
-
203
-	/* ************ requests for our domain ********** */
204
-
205
-
206
-	/* now, the request is for sure for our domain */
207
-
208
-	# registers always MUST be authenticated to
209
-	# avoid stealing incoming calls	
210
-	if (method=="REGISTER") {
211
-
212
-		# Make sure that user's dont register infinite loops
213
-		# (note: does not match with folded lines)
214
-		if (search("^(Contact|m): .*@(195\.37\.77\.101|iptel\.org)")) {
215
-			log(1, "LOG: alert: someone trying to set aor==contact\n");
216
-			sl_send_reply("476", "No Server Address in Contacts Allowed" );
217
-			break;
218
-		};
219
-		if (search("^(Contact|m): .*195\.37\.77\.110")) {
220
-			log(1, "LOG: alert: protected contacts\n");
221
-			sl_send_reply("476", "No Server Address in Contacts Allowed" );
222
-			break;
223
-		};
224
-
225
-		# prohibit attempts to grab someone else's To address 
226
-		# using  valid credentials; the only exception is the user
227
-		# 'replciator' permitted to generate 3-rd party registrations
228
-
229
-		if (!www_authorize(	"iptel.org" /* realm */, 
230
-			 				"subscriber" /* table name */ )) {
231
-			# challenge if none or invalid credentials
232
- 			www_challenge(	"iptel.org" /* realm */, 
233
-							"0" /* no qop -- some phones can't deal with it */);
234
-			break;
235
-		};
236
-
237
-		if (!is_user("replicator") & !check_to()) {
238
-			log("LOG: To Cheating attempt\n");
239
-			sl_send_reply("403", "That is ugly -- use To=id next time");
240
-			break;
241
-		};
242
-		# it is an authenticated request, update Contact database now
243
-		if (!save("location")) {
244
-			sl_reply_error();
245
-		};
246
-		/* XXX not tested yet
247
-		t_replicate("bat.iptel.org", "5060");
248
-		*/
249
-		break;
250
-	};
251
-
252
-	/* some UACs might be fooled by Contacts our UACs 
253
-	   generate to make MSN happy (web-im, e.g.) --
254
-	   tell its urneachable
255
-	*/
256
-	if (uri=~"sip:daemon@" ) {
257
-		sl_send_reply("410", "daemon is gone");
258
-		break;
259
-	};
260
-
261
-	# various aliases (might use a database in future)
262
-	lookup("aliases");
263
-	# check again, if it is still for our domain after aliases
264
-	# we have to include '.iptel.org' not to proceed to outbound
265
-	# authentication for calls to mail.iptel.org and other hosts
266
-	# served by us
267
-	if ( !(uri=~"[@:\.]iptel\.org([;:].*)*" | 
268
-		uri=~"[@:\.]195\.37\.77\.101([;:].*)*" |
269
-		uri=~"@195\.37\.77\.110([;:].*)*" )) {
270
-		route(5);
271
-		break;
272
-	};
273
-
274
-	# now check if it's about PSTN destinations through our gateway;
275
-	# note that 8.... is exempted for numerical non-gw destinations
276
-	if (uri=~"sip:\+?[0-79][0-9]*@.*") {
277
-		route(3);
278
-		break;
279
-	}; 
280
-
281
-	# does the user wish redirection on no availability? (i.e., is he
282
-	# in the voicemail group?) -- determine it now and store it in
283
-	# flag 4, before we rewrite the flag using UsrLoc
284
-	if (is_user_in("Request-URI", "voicemail")) {
285
-		setflag(4);
286
-	} ;
287
-
288
-	# native SIP destinations are handled using our USRLOC DB
289
-	if (!lookup("location")) {
290
-		# handle user which was not found ...
291
-		route(4);
292
-		break;
293
-	};
294
-	# check whether some inventive user has uploaded  gateway 
295
-	# contacts to UsrLoc to bypass our authorization logic
296
-	if (uri=~"@195\.37\.77\.110([;:].*)*" ) {
297
-		log(1, "LOG: Weird! Gateway address in UsrLoc!\n");
298
-		route(3);
299
-		break;
300
-	};
301
-
302
-	# if user is on-line and is in voicemail group, enable redirection
303
-	if (method=="INVITE" && isflagset(4)) {
304
-		t_on_negative("1");
305
-	};
306
-
307
-	/* ... and also report on missed calls ... note that reporting
308
-       on missed calls is mutually exclusive with silent C timer
309
-    */
310
-	setflag(3);
311
-
312
-
313
-
314
-	# add RR to messages which were previously labeled for that
315
-	if (isflagset(2)) {
316
-		addRecordRoute();
317
-	};
318
-
319
-	# we now know we may, we know where, let it go out now!
320
-	append_hf("P-hint: USRLOC\r\n");
321
-	if (!t_relay()) {
322
-		sl_reply_error();
323
-		break;
324
-	};
325
-}
326
-#------------------- OUTBOUND ----------------------------------------
327
-
328
-# routing logic for outbound requests targeted out of our domain
329
-# (beware, messages to our users can end up here too: for example,
330
-#  an INVITE may be UsrLoc-ed, then the other party uses outbound
331
-#  proxy with r-uri=the usr_loced addredd (typically IP))
332
-route[2] {
333
-	# outbound requests are allowed only for our users -- we don't
334
-	# support relaying and don't like strangers bothering us
335
-	# with resolving DNS; except our gateway
336
-	if (!(src_ip==195.37.77.110) & 
337
-		!(proxy_authorize(	"iptel.org" /* realm */,
338
-						"subscriber" /* table name */ ))) {
339
-		# ACK/CANCEL have inherently no security -- just log if
340
-		# included credentials are wrong and proceed
341
-		if (method=="ACK" ) {
342
-			log("LOG: failed outbound authentication for ACK granted\n");
343
-		} else if (method=="CANCEL") {
344
-			log("LOG: failed outbound authentication for CANCEL granted\n");
345
-		} else {
346
-			proxy_challenge("iptel.org" /* realm */, "0" /* no-qop */);
347
-			break;
348
-		};
349
-	};
350
-	# to maintain credibility of our proxy, we check From in INVITEs to be
351
-	# equal to credential id  so that user john.doe does not put bill.gates
352
-	# in his From; we don't do that for other requests: within a dialogue,
353
-	# subsequent transactions coming from the other side will have in From
354
-	# To of the original transaction to match the dialog; it may be 
355
-	# however different from user's default From and digest; example:
356
-	# user_a sends INVITE to secretary; secretary is translated to user_b;
357
-	# user_b accepts and later BYEs; to match the dialog, it puts
358
-	# secretary in From and sends user_b's credentials -- check_from
359
-	# would fail
360
-	if (!src_ip==195.37.77.110 & method=="INVITE" & !check_from()) {
361
-		log("LOG: From Cheating attempt\n");
362
-		sl_send_reply("403", "That is ugly -- use From=id next time (OB)");
363
-		break;
364
-	};
365
-
366
-	if (isflagset(2)) {
367
-		addRecordRoute();
368
-		;
369
-	};
370
-	append_hf("P-hint: OUTBOUND\r\n");
371
-	if (!t_relay()) {
372
-		sl_reply_error();
373
-		break;
374
-	};
375
-}
376
-
377
-#------- ALIASED OUTBOUND --------------------------------------------
378
-
379
-# routing logic for inbound requests aliased outbound; unlike
380
-# with real outbound requests we do not force authentication
381
-# as these calls are server by our server and we do not want
382
-# to disqualify unathenticated request originatiors from other
383
-# domains
384
-route[5] {
385
-	append_hf("P-hint: ALIASED-OUTBOUND\r\n");
386
-	if (!t_relay()) {
387
-		sl_reply_error();
388
-		break;
389
-	};
390
-}
391
-
392
-#----------------- PSTN ----------------------------------------------
393
-
394
-# logic for calls to the PSTN
395
-route[3] {
396
-	# if it is a MESSAGE pass it "as is" over to our SMS gateway
397
-	# (which unfortunately lives at a different host due to
398
-	# lack of serial interfaces)
399
-	if (method=="MESSAGE") {
400
-		# set accounting
401
-		setflag(1);
402
-		rewritehostport("195.37.77.100:5070");
403
-		append_hf("P-hint: SMS\r\n");
404
-		if (!t_relay()) {
405
-			sl_reply_error(); 
406
-		};
407
-		break;
408
-	};
409
-	# continue with requests to PSTN gateway ...
410
-
411
-	# the international + prefix
412
-	if (uri=~"sip:\+" ) {
413
-		strip(1);
414
-		prefix("000");
415
-	};
416
-	# free call destinations ... no authentication needed
417
-	if ( is_user_in("Request-URI", "free-pstn")  /* free destinations */
418
-			|  uri=~"sip:[79][0-9][0-9][0-9]@.*"  /* local PBX */
419
-			| uri=~"sip:98[0-9][0-9][0-9][0-9]") {
420
-		# just log it, no authentication
421
-		setflag(1);
422
-	} else {
423
-		# all other PSTN destinations only for authenticated users
424
-		# (Cisco GW, which has no digest support, is authenticated
425
-		# by its IP address -- that's for sure not very strong;
426
-		# wth confirmed that we filter packets coming from outside
427
-		# and bearing SRC IP address of our network)
428
-		# we are forgiving about ACK/CANCEL as digest provides no
429
-		# real security for them
430
-		if (!(src_ip==195.37.77.110 | method==ACK | method=="CANCEL" )) {
431
-			if (!proxy_authorize(	"iptel.org" /* realm */,
432
-								"subscriber" /* table name */))  {
433
-				proxy_challenge( "iptel.org" /* realm */, "0" /* no qop */ );
434
-				break;
435
-			# let's check from=id ... avoids accounting confusion
436
-			} else if (method=="INVITE" & !check_from()) {
437
-				log("LOG: From Cheating attempt\n");
438
-				sl_send_reply("403", "That is ugly -- use From=id next time (gw)");
439
-				break;
440
-			};
441
-		};
442
-
443
-		# authorize only for INVITEs -- RR/Contact may result in weird
444
-		# things showing up in d-uri that would break our logic; our
445
-		# major concern is INVITE which causes PSTN costs anyway
446
-
447
-		if (method=="INVITE") {
448
-
449
-			# does the authenticated user have a permission for local
450
-			# calls? (i.e., is he in the "local" group?)
451
-			if (uri=~"sip:0[1-9][0-9]+@.*") {
452
-				if (!is_in_group("local")) {
453
-					sl_send_reply("403", "Local Toodle Noodle...");
454
-					break;
455
-				};
456
-			# the same for long-distance
457
-			} else if (uri=~"sip:00[1-9][0-9]+@.*") {
458
-				if (uri=~"sip:001[089]" | uri=~"sip:00900.*" ) {
459
-					sl_send_reply("403", "Added Value Destinations not permitted...");
460
-					break;
461
-				};
462
-				if (!is_in_group("ld")) {
463
-					sl_send_reply("403", "LD Toodle Noodle...");
464
-					break;
465
-				};
466
-			# the same for international calls
467
-			} else if (uri=~"sip:000[1-9][0-9]+@.*") {
468
-				if (!is_in_group("int")) {
469
-					sl_send_reply("403", "International Toodle Noodle...");
470
-					break;
471
-				};
472
-			# everything else (e.g., interplanetary calls) is denied
473
-			} else {
474
-				sl_send_reply("403", "interplanetary Toodle Noodle...");
475
-				break;
476
-			};
477
-
478
-		}; # INVITE to authorized PSTN
479
-
480
-		# we passed all authorization checks for PSTN -- move on!
481
-		# tag this transaction for accounting
482
-		setflag(1);
483
-
484
-	}; # authorized PSTN
485
-
486
-	# requests to gateway must be record-routed because the GW accepts
487
-	# only reqeusts coming from our proxy
488
-	if (isflagset(2) || method=="INVITE")
489
-		addRecordRoute();
490
-
491
-	# if you have passed through all the checks, let your call go to GW!
492
-
493
-	rewritehostport("195.37.77.110:5060");
494
-
495
-	append_hf("P-hint: GATEWAY\r\n");
496
-	if (!t_relay()) {
497
-		sl_reply_error(); 
498
-		break; 
499
-	};
500
-
501
-}
502
-
503
-
504
-/* *********** handling of unavailable user ******************* */
505
-
506
-/* handling of users who are off-line */
507
-route[4] {
508
-	# user not found -- act as stateful UAS to avoid reporting
509
-	# on each INVITE retranmission
510
-	if (method=="INVITE" || method=="ACK" 
511
-			|| method=="BYE" || method=="CANCEL" ) {
512
-
513
-		/* requests to voicemail users will be fwded to voicemail */
514
-		if (isflagset(4)) {
515
-			rewritehostport("mail.iptel.org:6060");
516
-			append_hf("P-hint: OFFLINE-VOICEMAIL\r\n");
517
-			if (!t_relay()) {
518
-				sl_reply_error();
519
-			};
520
-		} else { /* non-voicemail users get 404 */
521
-			if (t_newtran()) {
522
-				if (method=="ACK") {
523
-					log("oops -- ACK to a non-existent transaction");
524
-					drop;
525
-				};
526
-				# we reply statefuly to avoid accounting of all
527
-				# retransmissions
528
-				if (!t_reply("404", "Not Found")) {
529
-					sl_reply_error();
530
-				};
531
-			} else {
532
-				sl_reply_error();
533
-			};
534
-		};
535
-		/* we account missed calls for all off-line users */
536
-		if (method=="INVITE") acc_request("404 Not Found");
537
-		break;
538
-	};
539
-	# non-VoIP messages: just return 404 statelessly
540
-	sl_send_reply("404", "Not Found");
541
-}
542
-
543
-# initiate serial forking to voicemail for users who registered for it
544
-# (those users will be accounted for missed calls too since the 
545
-# accounting flag #3 is set)
546
-# note: accounting relates to the status immediately after a final 
547
-# negative reply came back, i.e., the order of execution is
548
-# 1) account failed transaction 2) set up serial forking to voicemail
549
-reply_route[1] {
550
-	/* XX: note: unsafe if preloaded routes without username used */
551
-	revert_uri();
552
-	rewritehostport("mail.iptel.org:6060");
553
-	append_branch();
554
-}
... ...
@@ -1,4 +1,4 @@
1
-#!/bin/sh 
1
+#!/bin/sh
2 2
 #
3 3
 # $Id$
4 4
 #
... ...
@@ -10,7 +10,7 @@
10 10
 # chkconfig: 2345 20 80
11 11
 # description: controls execution of SIP router
12 12
 # processname: sr
13
-# config: /etc/sip_router.cfg
13
+# config: /etc/ser/iptel.cfg
14 14
 
15 15
 # Source function library.
16 16
 . /etc/rc.d/init.d/functions
... ...
@@ -22,7 +22,7 @@
22 22
 BINNAME=sr
23 23
 HM=/home/srouter
24 24
 SERDIR=$HM/sip_router
25
-ETC=$SERDIR/etc/iptel.cfg
25
+ETC=/etc/ser/iptel.cfg
26 26
 PIDFILE=/var/run/sr.pid
27 27
 NOTIFY=sr@iptel.org
28 28
 USR=510
... ...
@@ -30,7 +30,6 @@ GRP=510
30 30
 
31 31
 MONIT=/usr/local/bin/monit
32 32
 MONITRC=/usr/local/etc/monitrc
33
-MONITPID=/var/run/monit.pid
34 33
 
35 34
 RETVAL=0
36 35
 
... ...
@@ -55,55 +54,59 @@ ser_start() {
55 55
 	fi
56 56
 	cd $MYDIR
57 57
 	#ulimit -c 1000000
58
+	echo "Starting SIP router: "
58 59
 	$BIN -f $ETC -w $MYDIR -P $PIDFILE
59 60
 	RETVAL=$?
61
+	echo
62
+}
63
+
64
+ser_stop() {
65
+	echo "Stopping SIP router: "
66
+	killproc $BINNAME
67
+	RETVAL=$?
68
+	echo
69
+}
70
+
71
+monit_start() {
72
+   echo "Command Monit to start Ser..."
73
+   ${MONIT} -c ${MONITRC} start ser
74
+   RETVAL=$?
75
+   echo
76
+}
77
+
78
+monit_stop() {
79
+   echo "Command Monit to stop Ser..."
80
+   ${MONIT} -c ${MONITRC} stop ser
81
+   RETVAL=$?
82
+   echo
60 83
 }
61 84
 
62 85
 # See how we were called.
63 86
 case "$1" in
64 87
   serstart)
65
-	echo "Starting SIP router only: "
66 88
 	ser_start
67
-	RETVAL=$?
68
-	echo
69 89
 	;;
70 90
   serstop)
71
-	echo "Stopping SIP router only: "
72
-	killproc $BINNAME
73
-	RETVAL=$?
74
-	echo
91
+    ser_stop
75 92
 	;;
76 93
   serrestart)
77
-	$0 serstop
78
-	$0 serstart
79
-	RETVAL=$?
94
+	ser_stop
95
+	echo
96
+	ser_start
80 97
 	;;
81 98
   start)
82
-	echo -n "Starting SIP router and monit: "
83
-	ser_start
84
-	RETVAL=$?
85
-	# ser needs some time to listen
86
-	# but monit test on startup so give ser a little time
87
-	sleep 2
88
-	$MONIT -v -c $MONITRC
89
-	echo
99
+    monit_start
90 100
 	;;
91 101
   stop)
92
-	echo "Stopping SIP router and monit: "
93
-	killall monit
94
-	killproc $BINNAME
95
-	RETVAL=$?
96
-	echo
102
+    monit_stop
97 103
 	;;
98 104
   restart)
99
-	$0 stop
100
-	$0 start
101
-	RETVAL=$?
105
+	monit_stop
106
+	sleep 1
107
+	monit_start
102 108
 	;;
103 109
   *)
104
-	echo "Usage: $0 {start|stop|restart|serstart|serstop|serrestart}"
105
-	echo "  serstart, serstop and serrestart influence only ser."
106
-	echo "  start, stop and restart influence monit and ser."
110
+	echo "Usage: $0 {start|stop|restart}"
107 111
 	exit 1
108 112
 esac
109 113