Project

General

Profile

Download (19.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/****h* pfSense/service-utils
3
 * NAME
4
 *   service-utils.inc - Service facility
5
 * DESCRIPTION
6
 *   This file contains various functions used by the pfSense service facility.
7
 * HISTORY
8
 *   $Id$
9
 ******
10
 *
11
 * Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com)
12
 * All rights reserved.
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are met:
15
 *
16
 * 1. Redistributions of source code must retain the above copyright notice,
17
 * this list of conditions and the following disclaimer.
18
 *
19
 * 2. Redistributions in binary form must reproduce the above copyright
20
 * notice, this list of conditions and the following disclaimer in the
21
 * documentation and/or other materials provided with the distribution.
22
 *
23
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
 * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
 * RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
 * POSSIBILITY OF SUCH DAMAGE.
33
 *
34
 */
35

    
36
/*
37
	pfSense_BUILDER_BINARIES:	/bin/pgrep /bin/sh /usr/bin/killall
38
	pfSense_MODULE:	utils
39
*/
40
require_once("globals.inc");
41
require_once("captiveportal.inc");
42
require_once("openvpn.inc");
43
require_once("ipsec.inc");
44
require_once("vpn.inc");
45
require_once("vslb.inc");
46

    
47
define("RCFILEPREFIX", "/usr/local/etc/rc.d/");
48
function write_rcfile($params) {
49
	global $g;
50

    
51
	$rcfile_fullname = RCFILEPREFIX . $params['file'];
52
	if (!file_exists($rcfile_fullname) && !touch($rcfile_fullname))
53
		return false;
54

    
55
	if (!is_writable($rcfile_fullname) || empty($params['start']))
56
		return false;
57

    
58
	$towrite = "#!/bin/sh\n";
59
	$towrite .= "# This file was automatically generated\n# by the {$g['product_name']} service handler.\n\n";
60

    
61
	/* write our rc functions */
62
	$towrite .= "rc_start() {\n";
63
	$towrite .= "\t{$params['start']}\n";
64
	$towrite .= "}\n\n";
65
	if(!empty($params['stop'])) {
66
		$tokill =& $params['stop'];
67
	} else if(!empty($params['executable'])) {
68
		/* just nuke the executable */
69
		$tokill = "/usr/bin/killall {$params['executable']}";
70
	} else {
71
		/* make an educated guess (bad) */
72
		$tokill = array_pop(explode('/', array_shift(explode(' ', $params['start']))));
73
	}
74
	$towrite .= "rc_stop() {\n";
75
	$towrite .= "\t{$tokill}\n";
76
	$towrite .= "}\n\n";
77

    
78
	/* begin rcfile logic */
79
	$towrite .= "case \$1 in\n\tstart)\n\t\trc_start\n\t\t;;\n\tstop)\n\t\trc_stop\n\t\t;;\n\trestart)\n\t\trc_stop\n\t\trc_start\n\t\t;;\nesac\n\n";
80

    
81
	file_put_contents($rcfile_fullname, $towrite);
82
	@chmod("{$rcfile_fullname}", 0755);
83

    
84
	return;
85
}
86

    
87
function start_service($name) {
88
	global $config;
89

    
90
	if (empty($name))
91
		return;
92

    
93
	/* make sure service is stopped before starting */
94
	stop_service($name);
95
	sleep(2);
96

    
97
	$rcfile_fullname = RCFILEPREFIX . $name . '.sh';
98
	if(file_exists($rcfile_fullname)) {
99
		mwexec_bg("/bin/sh {$rcfile_fullname} start");
100
		return;
101
	}
102
	if($config['installedpackages']['service']) {
103
		foreach($config['installedpackages']['service'] as $service) {
104
			if(strtolower($service['name']) == strtolower($name)) {
105
				if($service['rcfile']) {
106
					$prefix = RCFILEPREFIX;
107
					if (!empty($service['prefix'])) {
108
						$prefix =& $service['prefix'];
109
					}
110
					if(file_exists("{$prefix}{$service['rcfile']}")) {
111
						mwexec_bg("{$prefix}{$service['rcfile']} start");
112
					}
113
				}
114
				if (!empty($service['startcmd']))
115
					eval($service['startcmd']);
116
				break;
117
			}
118
		}
119
	}
120
}
121

    
122
function stop_service($name) {
123
	global $config;
124

    
125
	if (empty($name))
126
		return;
127

    
128
	if ($config['installedpackages']['service']) {
129
		foreach($config['installedpackages']['service'] as $service) {
130
			if(strtolower($service['name']) == strtolower($name)) {
131
				if($service['rcfile']) {
132
					$prefix = RCFILEPREFIX;
133
					if(!empty($service['prefix'])) {
134
						$prefix =& $service['prefix'];
135
					}
136
					if(file_exists("{$prefix}{$service['rcfile']}")) {
137
						mwexec("{$prefix}{$service['rcfile']} stop");
138
					}
139
					return;
140
				}
141
				if (!empty($service['stopcmd']))
142
					eval($service['stopcmd']);
143

    
144
				if(!($service['rcfile'] or $service['stopcmd'])) {
145
					if(is_process_running("{$service['executable']}"))
146
						mwexec("/usr/bin/killall {$service['executable']}");
147
					return;
148
				}
149
				break;
150
			}
151
		}
152
	}
153
	/* finally if we get here lets simply kill the service name */
154
	if(is_process_running("{$name}"))
155
		mwexec("/usr/bin/killall {$name}");
156
}
157

    
158
function restart_service($name) {
159
	global $config;
160

    
161
	if (empty($name))
162
		return;
163

    
164
	stop_service($name);
165
	start_service($name);
166

    
167
	if($config['installedpackages']['service']) {
168
		foreach($config['installedpackages']['service'] as $service) {
169
			if(strtolower($service['name']) == strtolower($name)) {
170
				if($service['restartcmd']) {
171
					eval($service['restartcmd']);
172
				}
173
				break;
174
			}
175
		}
176
	}
177
}
178

    
179
function is_pid_running($pidfile) {
180
	if (!file_exists($pidfile))
181
		return false;
182

    
183
	return (isvalidpid($pidfile));
184
}
185

    
186
function is_dhcp_running($interface) {
187
	$status = find_dhclient_process($interface);
188
	if($status <> "")
189
		return true;
190
	return false;
191
}
192

    
193
function restart_service_if_running($service) {
194
	global $config;
195
	if(is_service_running($service))
196
		restart_service($service);
197
	return;
198
}
199

    
200
function is_service_enabled($service_name) {
201
	global $config;
202
	if ($service_name == "")
203
		return false;
204
	if (isset($config['installedpackages'][$service_name]['config'][0]['enable']) &&
205
		((empty($config['installedpackages'][$service_name]['config'][0]['enable'])) ||
206
		 ($config['installedpackages'][$service_name]['config'][0]['enable'] === 'off')))
207
		return false;
208
	return true;
209
}
210

    
211
function is_service_running($service, $ps = "") {
212
	global $config;
213

    
214
	if(is_array($config['installedpackages']['service'])) {
215
		foreach($config['installedpackages']['service'] as $aservice) {
216
			if(strtolower($service) == strtolower($aservice['name'])) {
217
				if ($aservice['custom_php_service_status_command'] <> "") {
218
					eval("\$rc={$aservice['custom_php_service_status_command']};");
219
					return $rc;
220
				}
221
				if(empty($aservice['executable']))
222
					return false;
223
				if (is_process_running($aservice['executable']))
224
					return true;
225

    
226
				return false;
227
			}
228
		}
229
	}
230

    
231
	if (is_process_running($service))
232
		return true;
233

    
234
	return false;
235
}
236

    
237
function get_services() {
238
	global $config;
239
	if (is_array($config['installedpackages']['service']))
240
		$services = $config['installedpackages']['service'];
241
	else
242
		$services = array();
243

    
244
	/*    Add services that are in the base.
245
	 *
246
	 */
247
	if(is_radvd_enabled()) {
248
		$pconfig = array();
249
		$pconfig['name'] = "radvd";
250
		$pconfig['description'] = gettext("Router Advertisement Daemon");
251
		$services[] = $pconfig;
252
	}
253

    
254
	if(isset($config['dnsmasq']['enable'])) {
255
		$pconfig = array();
256
		$pconfig['name'] = "dnsmasq";
257
		$pconfig['description'] = gettext("DNS Forwarder");
258
		$services[] = $pconfig;
259
	}
260

    
261
	$pconfig = array();
262
	$pconfig['name'] = "ntpd";
263
	$pconfig['description'] = gettext("NTP clock sync");
264
	$services[] = $pconfig;
265

    
266
	if (is_array($config['captiveportal'])) {
267
		foreach ($config['captiveportal'] as $zone => $setting) {
268
			if (isset($setting['enable'])) {
269
				$pconfig = array();
270
				$pconfig['name'] = "captiveportal";
271
				$pconfig['zone'] = $zone;
272
				$pconfig['description'] = gettext("Captive Portal") . ": ".htmlspecialchars($setting['zone']);
273
				$services[] = $pconfig;
274
			}
275
		}
276
	}
277

    
278
	$iflist = array();
279
	$ifdescrs = get_configured_interface_list();
280
	foreach ($ifdescrs as $if) {
281
		$oc = $config['interfaces'][$if];
282
		if ($oc['if'] && (!link_interface_to_bridge($if)))
283
			$iflist[$if] = $if;
284
	}
285
	$show_dhcprelay = false;
286
	foreach($iflist as $if) {
287
		if(isset($config['dhcrelay'][$if]['enable']))
288
			$show_dhcprelay = true;
289
	}
290

    
291
	if($show_dhcprelay == true) {
292
		$pconfig = array();
293
		$pconfig['name'] = "dhcrelay";
294
		$pconfig['description'] = gettext("DHCP Relay");
295
		$services[] = $pconfig;
296
	}
297

    
298
	if(is_dhcp_server_enabled()) {
299
		$pconfig = array();
300
		$pconfig['name'] = "dhcpd";
301
		$pconfig['description'] = gettext("DHCP Service");
302
		$services[] = $pconfig;
303
	}
304

    
305
	if(isset($config['snmpd']['enable'])) {
306
		$pconfig = array();
307
		$pconfig['name'] = "bsnmpd";
308
		$pconfig['description'] = gettext("SNMP Service");
309
		$services[] = $pconfig;
310
	}
311

    
312
	if (is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) {
313
		$pconfig = array();
314
		$pconfig['name'] = "igmpproxy";
315
		$pconfig['description'] = gettext("IGMP proxy");
316
		$services[] = $pconfig;
317
	}
318

    
319
	if (isset($config['installedpackages']['miniupnpd']) && $config['installedpackages']['miniupnpd']['config'][0]['enable']) {
320
		$pconfig = array();
321
		$pconfig['name'] = "miniupnpd";
322
		$pconfig['description'] = gettext("UPnP Service");
323
		$services[] = $pconfig;
324
	}
325

    
326
	if (isset($config['installedpackages']['routed']) && $config['installedpackages']['routed']['config'][0]['enable']) {
327
		$pconfig = array();
328
		$pconfig['name'] = "routed";
329
		$pconfig['description'] = gettext("RIP Daemon");
330
		$services[] = $pconfig;
331
	}
332

    
333
	if (isset($config['ipsec']['enable'])) {
334
		$pconfig = array();
335
		$pconfig['name'] = "racoon";
336
		$pconfig['description'] = gettext("IPsec VPN");
337
		$services[] = $pconfig;
338
	}
339

    
340
	foreach (array('server', 'client') as $mode) {
341
		if (is_array($config['openvpn']["openvpn-{$mode}"])) {
342
			foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
343
				if (!isset($setting['disable'])) {
344
					$pconfig = array();
345
					$pconfig['name'] = "openvpn";
346
					$pconfig['mode'] = $mode;
347
					$pconfig['id'] = $id;
348
					$pconfig['vpnid'] = $setting['vpnid'];
349
					$pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
350
					$services[] = $pconfig;
351
				}
352
			}
353
		}
354
	}
355

    
356
	if (count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
357
		$pconfig = array();
358
		$pconfig['name'] = "relayd";
359
		$pconfig['description'] = gettext("Server load balancing daemon");
360
		$services[] = $pconfig;
361
	}
362
	return $services;
363
}
364

    
365
function find_service_by_name($name) {
366
	$services = get_services();
367
	foreach ($services as $service)
368
		if ($service["name"] == $name)
369
			return $service;
370
	return array();
371
}
372

    
373
function find_service_by_openvpn_vpnid($vpnid) {
374
	$services = get_services();
375
	foreach ($services as $service)
376
		if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid))
377
			return $service;
378
	return array();
379
}
380

    
381
function find_service_by_cp_zone($zone) {
382
	$services = get_services();
383
	foreach ($services as $service)
384
		if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone))
385
			return $service;
386
	return array();
387
}
388

    
389
function service_name_compare($a, $b) {
390
	if (strtolower($a['name']) == strtolower($b['name']))
391
		return 0;
392
	return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
393
}
394

    
395
function get_pkg_descr($package_name) {
396
	global $config;
397
	if (is_array($config['installedpackages']['package'])) {
398
		foreach($config['installedpackages']['package'] as $pkg) {
399
			if($pkg['name'] == $package_name)
400
				return $pkg['descr'];
401
		}
402
	}
403
	return gettext("Not available.");
404
}
405

    
406
function get_service_status($service) {
407
	global $g;
408
	switch ($service['name']) {
409
		case "openvpn":
410
			$running = is_pid_running("{$g['varrun_path']}/openvpn_{$service['mode']}{$service['vpnid']}.pid");
411
			break;
412
		case "captiveportal":
413
			$running = is_pid_running("{$g['varrun_path']}/lighty-{$service['zone']}-CaptivePortal.pid");
414
			if (isset($config['captiveportal'][$service['zone']]['httpslogin']))
415
				$running = $running && is_pid_running("{$g['varrun_path']}/lighty-{$service['zone']}-CaptivePortal-SSL.pid");
416
			break;
417
		case "vhosts-http":
418
			$running = is_pid_running("{$g['varrun_path']}/vhosts-http.pid");
419
			break;
420
		default:
421
			$running = is_service_running($service['name']);
422
	}
423
	return $running;
424
}
425

    
426
function get_service_status_icon($service, $withtext = true, $smallicon = false) {
427
	global $g;
428
	$output = "";
429
	if(get_service_status($service)) {
430
		$statustext = gettext("Running");
431
		$output .= '<td class="listr" align="center">' . "\n";
432
		$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/";
433
		$output .= ($smallicon) ? "icon_pass.gif" : "icon_service_running.gif";
434
		$output .= "\" alt=\"status\" />";
435
		if ($withtext)
436
			$output .= "&nbsp;&nbsp;" . $statustext;
437
		$output .= "</td>\n";
438
	} else {
439
		$service_enabled = is_service_enabled($service['name']);
440
		$statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled");
441
		$output .= '<td class="listbg" align="center">' . "\n";
442
		$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/";
443
		$output .= ($smallicon) ? "icon_block.gif" : "icon_service_stopped.gif";
444
		$output .= "\" alt=\"status\" />";
445
		if ($withtext)
446
			$output .= "&nbsp;&nbsp;" . "<font color=\"white\">{$statustext}</font>";
447
		$output .= "</td>\n";
448
	}
449
	return $output;
450
}
451

    
452
function get_service_control_links($service, $addname = false) {
453
	global $g;
454
	$output = "";
455
	$stitle = ($addname) ? $service['name'] . " " : "";
456
	if(get_service_status($service)) {
457
		switch ($service['name']) {
458
			case "openvpn":
459
				$output .= "<a href='status_services.php?mode=restartservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}'>";
460
				break;
461
			case "captiveportal":
462
				$output .= "<a href='status_services.php?mode=restartservice&amp;service={$service['name']}&amp;zone={$service['zone']}'>";
463
				break;
464
			default:
465
				$output .= "<a href='status_services.php?mode=restartservice&amp;service={$service['name']}'>";
466
		}
467
		$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Restart %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_restart.gif' alt='restart' /></a>\n";
468
		switch ($service['name']) {
469
			case "openvpn":
470
				$output .= "<a href='status_services.php?mode=stopservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}'>";
471
				break;
472
			case "captiveportal":
473
				$output .= "<a href='status_services.php?mode=stopservice&amp;service={$service['name']}&amp;zone={$service['zone']}'>";
474
				break;
475
			default:
476
				$output .= "<a href='status_services.php?mode=stopservice&amp;service={$service['name']}'>";
477
		}
478
		$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Stop %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_stop.gif' alt='stop' />";
479
		$output .= "</a>";
480
	} else {
481
		$service_enabled = is_service_enabled($service['name']);
482
		switch ($service['name']) {
483
			case "openvpn":
484
				$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}'>";
485
				break;
486
			case "captiveportal":
487
				$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}&amp;zone={$service['zone']}'>";
488
				break;
489
			default:
490
				if ($service_enabled)
491
					$output .= "<a href='status_services.php?mode=startservice&amp;service={$service['name']}'>";
492
		}
493
		if ($service_enabled)
494
			$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_start.gif' alt='start' /></a>\n";
495
	}
496
	return $output;
497
}
498

    
499
function service_control_start($name, $extras) {
500
	global $g;
501
	switch($name) {
502
		case 'radvd':
503
			services_radvd_configure();
504
			break;
505
		case 'captiveportal':
506
			$zone = $extras['zone'];
507
			captiveportal_init_webgui_zonename($zone);
508
			break;
509
		case 'ntpd':
510
		case 'openntpd':
511
			system_ntp_configure();
512
			break;
513
		case 'bsnmpd':
514
			services_snmpd_configure();
515
			break;
516
		case 'dnsmasq':
517
			services_dnsmasq_configure();
518
			break;
519
		case 'dhcpd':
520
			services_dhcpd_configure();
521
			break;
522
		case 'igmpproxy':
523
			services_igmpproxy_configure();
524
			break;
525
		case 'miniupnpd':
526
			upnp_action('start');
527
			break;
528
		case 'racoon':
529
			vpn_ipsec_force_reload();
530
			break;
531
		case 'openvpn':
532
			$vpnmode = $extras['vpnmode'];
533
			if (($vpnmode == "server") || ($vpnmode == "client")) {
534
				$id = $extras['id'];
535
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
536
				if (file_exists($configfile))
537
					openvpn_restart_by_vpnid($vpnmode, $id);
538
			}
539
			break;
540
		case 'relayd':
541
			relayd_configure();
542
			break;
543
		default:
544
			start_service($name);
545
			break;
546
	}
547
	return sprintf(gettext("%s has been started."),htmlspecialchars($name));
548
}
549
function service_control_stop($name, $extras) {
550
	global $g;
551
	switch($name) {
552
		case 'radvd':
553
			killbypid("{$g['varrun_path']}/radvd.pid");
554
			break;
555
		case 'captiveportal':
556
			$zone = $extras['zone'];
557
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
558
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
559
			break;
560
		case 'ntpd':
561
			killbyname("ntpd");
562
			break;
563
		case 'openntpd':
564
			killbyname("openntpd");
565
			break;
566
		case 'bsnmpd':
567
			killbypid("{$g['varrun_path']}/snmpd.pid");
568
			break;
569
		case 'choparp':
570
			killbyname("choparp");
571
			break;
572
		case 'dhcpd':
573
			killbyname("dhcpd");
574
			break;
575
		case 'dhcrelay':
576
			killbypid("{$g['varrun_path']}/dhcrelay.pid");
577
			break;
578
		case 'dnsmasq':
579
			killbypid("{$g['varrun_path']}/dnsmasq.pid");
580
			break;
581
		case 'igmpproxy':
582
			killbyname("igmpproxy");
583
			break;
584
		case 'miniupnpd':
585
			upnp_action('stop');
586
			break;
587
		case 'sshd':
588
			killbyname("sshd");
589
			break;
590
		case 'racoon':
591
			exec("killall -9 racoon");
592
			break;
593
		case 'openvpn':
594
			$vpnmode = $extras['vpnmode'];
595
			if (($vpnmode == "server") or ($vpnmode == "client")) {
596
				$id = $extras['id'];
597
				$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid";
598
				killbypid($pidfile);
599
			}
600
			break;
601
		case 'relayd':
602
			mwexec('pkill relayd');
603
			break;
604
		default:
605
			stop_service($name);
606
			break;
607
	}
608
	return sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
609
}
610
function service_control_restart($name, $extras) {
611
	global $g;
612
	switch($name) {
613
		case 'radvd':
614
			services_radvd_configure();
615
			break;
616
		case 'captiveportal':
617
			$zone = $extras['zone'];
618
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
619
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
620
			captiveportal_init_webgui_zonename($zone);
621
			break;
622
		case 'ntpd':
623
		case 'openntpd':
624
			system_ntp_configure();
625
			break;
626
		case 'bsnmpd':
627
			services_snmpd_configure();
628
			break;
629
		case 'dnsmasq':
630
			services_dnsmasq_configure();
631
			break;
632
		case 'dhcpd':
633
			services_dhcpd_configure();
634
			break;
635
		case 'igmpproxy':
636
			services_igmpproxy_configure();
637
			break;
638
		case 'miniupnpd':
639
			upnp_action('restart');
640
			break;
641
		case 'racoon':
642
			vpn_ipsec_force_reload();
643
			break;
644
		case 'openvpn':
645
			$vpnmode = $extras['vpnmode'];
646
			if ($vpnmode == "server" || $vpnmode == "client") {
647
				$id = $extras['id'];
648
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
649
				if (file_exists($configfile))
650
					openvpn_restart_by_vpnid($vpnmode, $id);
651
			}
652
			break;
653
		case 'relayd':
654
			relayd_configure(true);
655
			break;
656
		default:
657
			restart_service($name);
658
			break;
659
	}
660
	return sprintf(gettext("%s has been restarted."),htmlspecialchars($name));
661
}
662

    
663
?>
(48-48/66)