1 |
c83068f6
|
Colin Smith
|
<?php
|
2 |
09221bc3
|
Renato Botelho
|
/*
|
3 |
ac24dc24
|
Renato Botelho
|
* service-utils.inc
|
4 |
|
|
*
|
5 |
|
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2005-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2005-2006 Colin Smith (ethethlay@gmail.com)
|
8 |
ac24dc24
|
Renato Botelho
|
* All rights reserved.
|
9 |
|
|
*
|
10 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
11 |
|
|
* you may not use this file except in compliance with the License.
|
12 |
|
|
* You may obtain a copy of the License at
|
13 |
ac24dc24
|
Renato Botelho
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
15 |
ac24dc24
|
Renato Botelho
|
*
|
16 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
17 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
18 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19 |
|
|
* See the License for the specific language governing permissions and
|
20 |
|
|
* limitations under the License.
|
21 |
ac24dc24
|
Renato Botelho
|
*/
|
22 |
c83068f6
|
Colin Smith
|
|
23 |
ab1cf455
|
jim-p
|
require_once("globals.inc");
|
24 |
ee6e6011
|
jim-p
|
require_once("captiveportal.inc");
|
25 |
|
|
require_once("openvpn.inc");
|
26 |
|
|
require_once("ipsec.inc");
|
27 |
|
|
require_once("vpn.inc");
|
28 |
|
|
require_once("vslb.inc");
|
29 |
b05a8f35
|
jim-p
|
require_once("gwlb.inc");
|
30 |
523855b0
|
Scott Ullrich
|
|
31 |
e9d66ed4
|
phildd
|
define("RCFILEPREFIX", "/usr/local/etc/rc.d/");
|
32 |
c83068f6
|
Colin Smith
|
function write_rcfile($params) {
|
33 |
c2151973
|
Ermal
|
global $g;
|
34 |
af799b48
|
Renato Botelho
|
|
35 |
6f931ad2
|
Phil Davis
|
safe_mkdir(RCFILEPREFIX);
|
36 |
e9d66ed4
|
phildd
|
$rcfile_fullname = RCFILEPREFIX . $params['file'];
|
37 |
61e047a5
|
Phil Davis
|
if (!file_exists($rcfile_fullname) && !is_link($rcfile_fullname) && !touch($rcfile_fullname)) {
|
38 |
af799b48
|
Renato Botelho
|
return false;
|
39 |
61e047a5
|
Phil Davis
|
}
|
40 |
c2151973
|
Ermal
|
|
41 |
61e047a5
|
Phil Davis
|
if (!is_writable($rcfile_fullname) || empty($params['start'])) {
|
42 |
ba8495f0
|
Ermal
|
return false;
|
43 |
61e047a5
|
Phil Davis
|
}
|
44 |
af799b48
|
Renato Botelho
|
|
45 |
ba8495f0
|
Ermal
|
$towrite = "#!/bin/sh\n";
|
46 |
4dddf8c3
|
Warren Baker
|
$towrite .= "# This file was automatically generated\n# by the {$g['product_name']} service handler.\n\n";
|
47 |
ba8495f0
|
Ermal
|
|
48 |
c83068f6
|
Colin Smith
|
/* write our rc functions */
|
49 |
ba8495f0
|
Ermal
|
$towrite .= "rc_start() {\n";
|
50 |
|
|
$towrite .= "\t{$params['start']}\n";
|
51 |
|
|
$towrite .= "}\n\n";
|
52 |
61e047a5
|
Phil Davis
|
if (!empty($params['stop'])) {
|
53 |
c83068f6
|
Colin Smith
|
$tokill =& $params['stop'];
|
54 |
61e047a5
|
Phil Davis
|
} else if (!empty($params['executable'])) {
|
55 |
a8dbad89
|
Colin Smith
|
/* just nuke the executable */
|
56 |
873c1701
|
Renato Botelho
|
$tokill = "/usr/bin/killall " . escapeshellarg($params['executable']);
|
57 |
c83068f6
|
Colin Smith
|
} else {
|
58 |
a8dbad89
|
Colin Smith
|
/* make an educated guess (bad) */
|
59 |
c83068f6
|
Colin Smith
|
$tokill = array_pop(explode('/', array_shift(explode(' ', $params['start']))));
|
60 |
|
|
}
|
61 |
ba8495f0
|
Ermal
|
$towrite .= "rc_stop() {\n";
|
62 |
|
|
$towrite .= "\t{$tokill}\n";
|
63 |
|
|
$towrite .= "}\n\n";
|
64 |
4685e464
|
Scott Ullrich
|
|
65 |
c83068f6
|
Colin Smith
|
/* begin rcfile logic */
|
66 |
ba8495f0
|
Ermal
|
$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";
|
67 |
|
|
|
68 |
44b19298
|
Ermal
|
@file_put_contents($rcfile_fullname, $towrite);
|
69 |
|
|
unset($towrite);
|
70 |
e9d66ed4
|
phildd
|
@chmod("{$rcfile_fullname}", 0755);
|
71 |
ba8495f0
|
Ermal
|
|
72 |
c83068f6
|
Colin Smith
|
return;
|
73 |
|
|
}
|
74 |
31f346a8
|
Colin Smith
|
|
75 |
58826c73
|
Colin Smith
|
function start_service($name) {
|
76 |
669e1adb
|
Bill Marquette
|
global $config;
|
77 |
ba8495f0
|
Ermal
|
|
78 |
61e047a5
|
Phil Davis
|
if (empty($name)) {
|
79 |
b27ade8e
|
Ermal
|
return;
|
80 |
61e047a5
|
Phil Davis
|
}
|
81 |
b27ade8e
|
Ermal
|
|
82 |
44b19298
|
Ermal
|
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
|
83 |
61e047a5
|
Phil Davis
|
foreach ($config['installedpackages']['service'] as $service) {
|
84 |
|
|
if (strtolower($service['name']) == strtolower($name)) {
|
85 |
|
|
if ($service['rcfile']) {
|
86 |
e9d66ed4
|
phildd
|
$prefix = RCFILEPREFIX;
|
87 |
ba8495f0
|
Ermal
|
if (!empty($service['prefix'])) {
|
88 |
31f346a8
|
Colin Smith
|
$prefix =& $service['prefix'];
|
89 |
|
|
}
|
90 |
61e047a5
|
Phil Davis
|
if (file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) {
|
91 |
ba8495f0
|
Ermal
|
mwexec_bg("{$prefix}{$service['rcfile']} start");
|
92 |
a4ea3340
|
Scott Ullrich
|
}
|
93 |
31f346a8
|
Colin Smith
|
}
|
94 |
61e047a5
|
Phil Davis
|
if (!empty($service['startcmd'])) {
|
95 |
31f346a8
|
Colin Smith
|
eval($service['startcmd']);
|
96 |
61e047a5
|
Phil Davis
|
}
|
97 |
31f346a8
|
Colin Smith
|
break;
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
|
103 |
58826c73
|
Colin Smith
|
function stop_service($name) {
|
104 |
cd72ded3
|
Timo Boettcher
|
global $config;
|
105 |
246a887a
|
Ermal
|
|
106 |
61e047a5
|
Phil Davis
|
if (empty($name)) {
|
107 |
8bf2e9e5
|
Ermal
|
return;
|
108 |
61e047a5
|
Phil Davis
|
}
|
109 |
8bf2e9e5
|
Ermal
|
|
110 |
b4d772dc
|
Ermal Luçi
|
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
|
111 |
61e047a5
|
Phil Davis
|
foreach ($config['installedpackages']['service'] as $service) {
|
112 |
|
|
if (strtolower($service['name']) == strtolower($name)) {
|
113 |
|
|
if ($service['rcfile']) {
|
114 |
e9d66ed4
|
phildd
|
$prefix = RCFILEPREFIX;
|
115 |
61e047a5
|
Phil Davis
|
if (!empty($service['prefix'])) {
|
116 |
cd72ded3
|
Timo Boettcher
|
$prefix =& $service['prefix'];
|
117 |
|
|
}
|
118 |
61e047a5
|
Phil Davis
|
if (file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) {
|
119 |
6ae78f08
|
Marcello Coutinho
|
mwexec("{$prefix}{$service['rcfile']} stop");
|
120 |
098820e2
|
Ermal
|
}
|
121 |
|
|
return;
|
122 |
cd72ded3
|
Timo Boettcher
|
}
|
123 |
61e047a5
|
Phil Davis
|
if (!empty($service['stopcmd'])) {
|
124 |
cd72ded3
|
Timo Boettcher
|
eval($service['stopcmd']);
|
125 |
b8877138
|
doktornotor
|
} elseif (!empty($service['executable'])) {
|
126 |
|
|
mwexec("/usr/bin/killall " . escapeshellarg($service['executable']));
|
127 |
61e047a5
|
Phil Davis
|
}
|
128 |
ba8495f0
|
Ermal
|
|
129 |
cd72ded3
|
Timo Boettcher
|
break;
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
31f346a8
|
Colin Smith
|
}
|
134 |
|
|
|
135 |
58826c73
|
Colin Smith
|
function restart_service($name) {
|
136 |
cd72ded3
|
Timo Boettcher
|
global $config;
|
137 |
ba8495f0
|
Ermal
|
|
138 |
61e047a5
|
Phil Davis
|
if (empty($name)) {
|
139 |
8bf2e9e5
|
Ermal
|
return;
|
140 |
61e047a5
|
Phil Davis
|
}
|
141 |
8bf2e9e5
|
Ermal
|
|
142 |
6855f25d
|
doktornotor
|
if (is_service_running($name)) {
|
143 |
|
|
stop_service($name);
|
144 |
|
|
}
|
145 |
636ab238
|
Colin Smith
|
start_service($name);
|
146 |
ba8495f0
|
Ermal
|
|
147 |
b4d772dc
|
Ermal Luçi
|
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) {
|
148 |
61e047a5
|
Phil Davis
|
foreach ($config['installedpackages']['service'] as $service) {
|
149 |
|
|
if (strtolower($service['name']) == strtolower($name)) {
|
150 |
|
|
if ($service['restartcmd']) {
|
151 |
cd72ded3
|
Timo Boettcher
|
eval($service['restartcmd']);
|
152 |
|
|
}
|
153 |
|
|
break;
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
31f346a8
|
Colin Smith
|
}
|
158 |
ec4e071a
|
Colin Smith
|
|
159 |
cd72ded3
|
Timo Boettcher
|
function is_pid_running($pidfile) {
|
160 |
61e047a5
|
Phil Davis
|
if (!file_exists($pidfile)) {
|
161 |
ba8495f0
|
Ermal
|
return false;
|
162 |
61e047a5
|
Phil Davis
|
}
|
163 |
ba8495f0
|
Ermal
|
|
164 |
17098641
|
Ermal
|
return (isvalidpid($pidfile));
|
165 |
cd72ded3
|
Timo Boettcher
|
}
|
166 |
|
|
|
167 |
8ff8520f
|
Scott Ullrich
|
function is_dhcp_running($interface) {
|
168 |
fda8dc28
|
Seth Mos
|
$status = find_dhclient_process($interface);
|
169 |
61e047a5
|
Phil Davis
|
if ($status != 0) {
|
170 |
ca88e48f
|
Scott Ullrich
|
return true;
|
171 |
61e047a5
|
Phil Davis
|
}
|
172 |
ca88e48f
|
Scott Ullrich
|
return false;
|
173 |
8ff8520f
|
Scott Ullrich
|
}
|
174 |
|
|
|
175 |
0661a033
|
Colin Smith
|
function restart_service_if_running($service) {
|
176 |
|
|
global $config;
|
177 |
61e047a5
|
Phil Davis
|
if (is_service_running($service)) {
|
178 |
0661a033
|
Colin Smith
|
restart_service($service);
|
179 |
61e047a5
|
Phil Davis
|
}
|
180 |
0661a033
|
Colin Smith
|
return;
|
181 |
|
|
}
|
182 |
|
|
|
183 |
ccfc0269
|
phildd
|
function is_service_enabled($service_name) {
|
184 |
|
|
global $config;
|
185 |
61e047a5
|
Phil Davis
|
if ($service_name == "") {
|
186 |
ccfc0269
|
phildd
|
return false;
|
187 |
61e047a5
|
Phil Davis
|
}
|
188 |
762e8cf9
|
jim-p
|
if (is_array($config['installedpackages'])) {
|
189 |
|
|
if (isset($config['installedpackages'][$service_name]['config'][0]['enable']) &&
|
190 |
61e047a5
|
Phil Davis
|
((empty($config['installedpackages'][$service_name]['config'][0]['enable'])) ||
|
191 |
|
|
($config['installedpackages'][$service_name]['config'][0]['enable'] === 'off'))) {
|
192 |
762e8cf9
|
jim-p
|
return false;
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
ccfc0269
|
phildd
|
return true;
|
196 |
|
|
}
|
197 |
|
|
|
198 |
fbeb6d02
|
Colin Smith
|
function is_service_running($service, $ps = "") {
|
199 |
|
|
global $config;
|
200 |
ba8495f0
|
Ermal
|
|
201 |
61e047a5
|
Phil Davis
|
if (is_array($config['installedpackages']['service'])) {
|
202 |
|
|
foreach ($config['installedpackages']['service'] as $aservice) {
|
203 |
|
|
if (strtolower($service) == strtolower($aservice['name'])) {
|
204 |
ba8495f0
|
Ermal
|
if ($aservice['custom_php_service_status_command'] <> "") {
|
205 |
|
|
eval("\$rc={$aservice['custom_php_service_status_command']};");
|
206 |
c2d49311
|
Eirik Oeverby
|
return $rc;
|
207 |
|
|
}
|
208 |
61e047a5
|
Phil Davis
|
if (empty($aservice['executable'])) {
|
209 |
ec4e071a
|
Colin Smith
|
return false;
|
210 |
61e047a5
|
Phil Davis
|
}
|
211 |
|
|
if (is_process_running($aservice['executable'])) {
|
212 |
ba8495f0
|
Ermal
|
return true;
|
213 |
61e047a5
|
Phil Davis
|
}
|
214 |
ba8495f0
|
Ermal
|
|
215 |
|
|
return false;
|
216 |
cd72ded3
|
Timo Boettcher
|
}
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
ba8495f0
|
Ermal
|
|
220 |
61e047a5
|
Phil Davis
|
if (is_process_running($service)) {
|
221 |
ba8495f0
|
Ermal
|
return true;
|
222 |
61e047a5
|
Phil Davis
|
}
|
223 |
ba8495f0
|
Ermal
|
|
224 |
|
|
return false;
|
225 |
ec4e071a
|
Colin Smith
|
}
|
226 |
ff074bf9
|
Scott Ullrich
|
|
227 |
e48cdc01
|
jim-p
|
function get_services() {
|
228 |
|
|
global $config;
|
229 |
61e047a5
|
Phil Davis
|
if (is_array($config['installedpackages']['service'])) {
|
230 |
e48cdc01
|
jim-p
|
$services = $config['installedpackages']['service'];
|
231 |
61e047a5
|
Phil Davis
|
} else {
|
232 |
e48cdc01
|
jim-p
|
$services = array();
|
233 |
61e047a5
|
Phil Davis
|
}
|
234 |
e48cdc01
|
jim-p
|
|
235 |
61e047a5
|
Phil Davis
|
/*
|
236 |
|
|
* Add services that are in the base.
|
237 |
e48cdc01
|
jim-p
|
*/
|
238 |
33232486
|
Warren Baker
|
if (is_radvd_enabled()) {
|
239 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
240 |
|
|
$pconfig['name'] = "radvd";
|
241 |
|
|
$pconfig['description'] = gettext("Router Advertisement Daemon");
|
242 |
|
|
$services[] = $pconfig;
|
243 |
|
|
}
|
244 |
|
|
|
245 |
33232486
|
Warren Baker
|
if (isset($config['dnsmasq']['enable'])) {
|
246 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
247 |
|
|
$pconfig['name'] = "dnsmasq";
|
248 |
|
|
$pconfig['description'] = gettext("DNS Forwarder");
|
249 |
|
|
$services[] = $pconfig;
|
250 |
|
|
}
|
251 |
|
|
|
252 |
33232486
|
Warren Baker
|
if (isset($config['unbound']['enable'])) {
|
253 |
|
|
$pconfig = array();
|
254 |
|
|
$pconfig['name'] = "unbound";
|
255 |
a3fb1412
|
Phil Davis
|
$pconfig['description'] = gettext("DNS Resolver");
|
256 |
33232486
|
Warren Baker
|
$services[] = $pconfig;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
260 |
|
|
$pconfig['name'] = "ntpd";
|
261 |
|
|
$pconfig['description'] = gettext("NTP clock sync");
|
262 |
|
|
$services[] = $pconfig;
|
263 |
|
|
|
264 |
|
|
if (is_array($config['captiveportal'])) {
|
265 |
|
|
foreach ($config['captiveportal'] as $zone => $setting) {
|
266 |
|
|
if (isset($setting['enable'])) {
|
267 |
|
|
$pconfig = array();
|
268 |
|
|
$pconfig['name'] = "captiveportal";
|
269 |
|
|
$pconfig['zone'] = $zone;
|
270 |
e8c516a0
|
Phil Davis
|
$pconfig['description'] = gettext("Captive Portal") . ": " . htmlspecialchars($setting['zone']);
|
271 |
e48cdc01
|
jim-p
|
$services[] = $pconfig;
|
272 |
|
|
}
|
273 |
|
|
}
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
$iflist = array();
|
277 |
|
|
$ifdescrs = get_configured_interface_list();
|
278 |
|
|
foreach ($ifdescrs as $if) {
|
279 |
|
|
$oc = $config['interfaces'][$if];
|
280 |
61e047a5
|
Phil Davis
|
if ($oc['if'] && (!link_interface_to_bridge($if))) {
|
281 |
e48cdc01
|
jim-p
|
$iflist[$if] = $if;
|
282 |
61e047a5
|
Phil Davis
|
}
|
283 |
e48cdc01
|
jim-p
|
}
|
284 |
|
|
|
285 |
33232486
|
Warren Baker
|
if (isset($config['dhcrelay']['enable'])) {
|
286 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
287 |
|
|
$pconfig['name'] = "dhcrelay";
|
288 |
|
|
$pconfig['description'] = gettext("DHCP Relay");
|
289 |
|
|
$services[] = $pconfig;
|
290 |
|
|
}
|
291 |
|
|
|
292 |
33232486
|
Warren Baker
|
if (isset($config['dhcrelay6']['enable'])) {
|
293 |
9590e0de
|
Phil Davis
|
$pconfig = array();
|
294 |
|
|
$pconfig['name'] = "dhcrelay6";
|
295 |
|
|
$pconfig['description'] = gettext("DHCPv6 Relay");
|
296 |
|
|
$services[] = $pconfig;
|
297 |
|
|
}
|
298 |
|
|
|
299 |
33232486
|
Warren Baker
|
if (is_dhcp_server_enabled()) {
|
300 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
301 |
|
|
$pconfig['name'] = "dhcpd";
|
302 |
|
|
$pconfig['description'] = gettext("DHCP Service");
|
303 |
|
|
$services[] = $pconfig;
|
304 |
|
|
}
|
305 |
|
|
|
306 |
b05a8f35
|
jim-p
|
$gateways_arr = return_gateways_array();
|
307 |
|
|
if (is_array($gateways_arr)) {
|
308 |
|
|
$pconfig = array();
|
309 |
69eefb50
|
Renato Botelho
|
$pconfig['name'] = "dpinger";
|
310 |
b05a8f35
|
jim-p
|
$pconfig['description'] = gettext("Gateway Monitoring Daemon");
|
311 |
|
|
$services[] = $pconfig;
|
312 |
|
|
}
|
313 |
|
|
|
314 |
33232486
|
Warren Baker
|
if (isset($config['snmpd']['enable'])) {
|
315 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
316 |
|
|
$pconfig['name'] = "bsnmpd";
|
317 |
|
|
$pconfig['description'] = gettext("SNMP Service");
|
318 |
|
|
$services[] = $pconfig;
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
if (is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) {
|
322 |
|
|
$pconfig = array();
|
323 |
|
|
$pconfig['name'] = "igmpproxy";
|
324 |
|
|
$pconfig['description'] = gettext("IGMP proxy");
|
325 |
|
|
$services[] = $pconfig;
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
if (isset($config['installedpackages']['miniupnpd']) && $config['installedpackages']['miniupnpd']['config'][0]['enable']) {
|
329 |
|
|
$pconfig = array();
|
330 |
|
|
$pconfig['name'] = "miniupnpd";
|
331 |
|
|
$pconfig['description'] = gettext("UPnP Service");
|
332 |
|
|
$services[] = $pconfig;
|
333 |
|
|
}
|
334 |
|
|
|
335 |
dc0f709e
|
Luiz Otavio O Souza
|
if (ipsec_enabled()) {
|
336 |
e48cdc01
|
jim-p
|
$pconfig = array();
|
337 |
8b4abd59
|
Ermal
|
$pconfig['name'] = "ipsec";
|
338 |
e48cdc01
|
jim-p
|
$pconfig['description'] = gettext("IPsec VPN");
|
339 |
|
|
$services[] = $pconfig;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
aaa78416
|
jim-p
|
if (isset($config['system']['enablesshd'])) {
|
343 |
|
|
$pconfig = array();
|
344 |
|
|
$pconfig['name'] = "sshd";
|
345 |
|
|
$pconfig['description'] = gettext("Secure Shell Daemon");
|
346 |
|
|
$services[] = $pconfig;
|
347 |
|
|
}
|
348 |
|
|
|
349 |
e48cdc01
|
jim-p
|
foreach (array('server', 'client') as $mode) {
|
350 |
|
|
if (is_array($config['openvpn']["openvpn-{$mode}"])) {
|
351 |
|
|
foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
|
352 |
|
|
if (!isset($setting['disable'])) {
|
353 |
|
|
$pconfig = array();
|
354 |
|
|
$pconfig['name'] = "openvpn";
|
355 |
|
|
$pconfig['mode'] = $mode;
|
356 |
|
|
$pconfig['id'] = $id;
|
357 |
|
|
$pconfig['vpnid'] = $setting['vpnid'];
|
358 |
e8c516a0
|
Phil Davis
|
$pconfig['description'] = gettext("OpenVPN") . " " . $mode . ": " . htmlspecialchars($setting['description']);
|
359 |
e48cdc01
|
jim-p
|
$services[] = $pconfig;
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
|
|
}
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
if (count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
|
366 |
|
|
$pconfig = array();
|
367 |
|
|
$pconfig['name'] = "relayd";
|
368 |
|
|
$pconfig['description'] = gettext("Server load balancing daemon");
|
369 |
|
|
$services[] = $pconfig;
|
370 |
|
|
}
|
371 |
|
|
return $services;
|
372 |
|
|
}
|
373 |
|
|
|
374 |
76692ad2
|
jim-p
|
function find_service_by_name($name) {
|
375 |
|
|
$services = get_services();
|
376 |
61e047a5
|
Phil Davis
|
foreach ($services as $service) {
|
377 |
|
|
if ($service["name"] == $name) {
|
378 |
76692ad2
|
jim-p
|
return $service;
|
379 |
61e047a5
|
Phil Davis
|
}
|
380 |
|
|
}
|
381 |
76692ad2
|
jim-p
|
return array();
|
382 |
|
|
}
|
383 |
|
|
|
384 |
6d9b1074
|
jim-p
|
function find_service_by_openvpn_vpnid($vpnid) {
|
385 |
|
|
$services = get_services();
|
386 |
61e047a5
|
Phil Davis
|
foreach ($services as $service) {
|
387 |
|
|
if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid)) {
|
388 |
6d9b1074
|
jim-p
|
return $service;
|
389 |
61e047a5
|
Phil Davis
|
}
|
390 |
|
|
}
|
391 |
6d9b1074
|
jim-p
|
return array();
|
392 |
|
|
}
|
393 |
|
|
|
394 |
|
|
function find_service_by_cp_zone($zone) {
|
395 |
|
|
$services = get_services();
|
396 |
61e047a5
|
Phil Davis
|
foreach ($services as $service) {
|
397 |
|
|
if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone)) {
|
398 |
6d9b1074
|
jim-p
|
return $service;
|
399 |
61e047a5
|
Phil Davis
|
}
|
400 |
|
|
}
|
401 |
6d9b1074
|
jim-p
|
return array();
|
402 |
|
|
}
|
403 |
|
|
|
404 |
e48cdc01
|
jim-p
|
function service_name_compare($a, $b) {
|
405 |
61e047a5
|
Phil Davis
|
if (strtolower($a['name']) == strtolower($b['name'])) {
|
406 |
e48cdc01
|
jim-p
|
return 0;
|
407 |
61e047a5
|
Phil Davis
|
}
|
408 |
e48cdc01
|
jim-p
|
return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
|
409 |
|
|
}
|
410 |
|
|
|
411 |
095edfeb
|
Stephen Beaver
|
function service_dispname_compare($a, $b) {
|
412 |
|
|
if (strtolower($a['dispname']) == strtolower($b['dispname'])) {
|
413 |
|
|
return 0;
|
414 |
|
|
}
|
415 |
|
|
return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
|
416 |
|
|
}
|
417 |
|
|
|
418 |
e48cdc01
|
jim-p
|
function get_pkg_descr($package_name) {
|
419 |
|
|
global $config;
|
420 |
|
|
if (is_array($config['installedpackages']['package'])) {
|
421 |
61e047a5
|
Phil Davis
|
foreach ($config['installedpackages']['package'] as $pkg) {
|
422 |
|
|
if ($pkg['name'] == $package_name) {
|
423 |
e48cdc01
|
jim-p
|
return $pkg['descr'];
|
424 |
61e047a5
|
Phil Davis
|
}
|
425 |
e48cdc01
|
jim-p
|
}
|
426 |
|
|
}
|
427 |
|
|
return gettext("Not available.");
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
function get_service_status($service) {
|
431 |
|
|
global $g;
|
432 |
|
|
switch ($service['name']) {
|
433 |
|
|
case "openvpn":
|
434 |
|
|
$running = is_pid_running("{$g['varrun_path']}/openvpn_{$service['mode']}{$service['vpnid']}.pid");
|
435 |
|
|
break;
|
436 |
|
|
case "captiveportal":
|
437 |
cd41643d
|
Renato Botelho
|
$running = is_pid_running("{$g['varrun_path']}/nginx-{$service['zone']}-CaptivePortal.pid");
|
438 |
61e047a5
|
Phil Davis
|
if (isset($config['captiveportal'][$service['zone']]['httpslogin'])) {
|
439 |
cd41643d
|
Renato Botelho
|
$running = $running && is_pid_running("{$g['varrun_path']}/nginx-{$service['zone']}-CaptivePortal-SSL.pid");
|
440 |
61e047a5
|
Phil Davis
|
}
|
441 |
e48cdc01
|
jim-p
|
break;
|
442 |
18725085
|
Ermal
|
case "vhosts-http":
|
443 |
|
|
$running = is_pid_running("{$g['varrun_path']}/vhosts-http.pid");
|
444 |
|
|
break;
|
445 |
9590e0de
|
Phil Davis
|
case "dhcrelay6":
|
446 |
|
|
$running = is_pid_running("{$g['varrun_path']}/dhcrelay6.pid");
|
447 |
|
|
break;
|
448 |
e381cc01
|
Ermal
|
case 'ipsec':
|
449 |
|
|
$running = is_pid_running("{$g['varrun_path']}/charon.pid");
|
450 |
|
|
break;
|
451 |
e48cdc01
|
jim-p
|
default:
|
452 |
|
|
$running = is_service_running($service['name']);
|
453 |
|
|
}
|
454 |
|
|
return $running;
|
455 |
|
|
}
|
456 |
|
|
|
457 |
0a9d81fb
|
NOYB
|
function get_service_status_icon($service, $withtext = true, $smallicon = false, $withthumbs = false, $title = "service_state") {
|
458 |
e48cdc01
|
jim-p
|
$output = "";
|
459 |
0a9d81fb
|
NOYB
|
|
460 |
61e047a5
|
Phil Davis
|
if (get_service_status($service)) {
|
461 |
92421710
|
jim-p
|
$statustext = gettext("Running");
|
462 |
0a9d81fb
|
NOYB
|
$text_class = "text-success";
|
463 |
a03162c8
|
Stephen Beaver
|
$fa_class = "fa fa-check-circle";
|
464 |
0a9d81fb
|
NOYB
|
$fa_class_thumbs = "fa fa-thumbs-o-up";
|
465 |
|
|
$Thumbs_UpDown = "Thumbs up";
|
466 |
e48cdc01
|
jim-p
|
} else {
|
467 |
0a9d81fb
|
NOYB
|
if (is_service_enabled($service['name'])) {
|
468 |
|
|
$statustext = gettext("Stopped");
|
469 |
|
|
$text_class = "text-danger";
|
470 |
a03162c8
|
Stephen Beaver
|
$fa_class = "fa fa-times-circle";
|
471 |
0a9d81fb
|
NOYB
|
} else {
|
472 |
|
|
$statustext = gettext("Disabled");
|
473 |
|
|
$text_class = "text-warning";
|
474 |
|
|
$fa_class = "fa fa-ban";
|
475 |
61e047a5
|
Phil Davis
|
}
|
476 |
0a9d81fb
|
NOYB
|
$fa_class_thumbs = "fa fa-thumbs-o-down";
|
477 |
|
|
$Thumbs_UpDown = "Thumbs down";
|
478 |
|
|
}
|
479 |
|
|
$fa_size = ($smallicon) ? "fa-1x" : "fa-lg";
|
480 |
|
|
|
481 |
|
|
$spacer = ($withthumbs || $withtext) ? " " : "";
|
482 |
|
|
if ($title == "state") {
|
483 |
|
|
$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"{$statustext}\"></i>{$spacer}";
|
484 |
|
|
} elseif ($title == "service_state") {
|
485 |
b3119a61
|
Phil Davis
|
$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext('%1$s Service is %2$s'), $service["name"], $statustext) . "\"></i>{$spacer}";
|
486 |
0a9d81fb
|
NOYB
|
} elseif ($title == "description_state") {
|
487 |
b3119a61
|
Phil Davis
|
$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext('%1$s Service is %2$s'), $service["description"], $statustext) . "\"></i>{$spacer}";
|
488 |
0a9d81fb
|
NOYB
|
} elseif ($title == "description_service_state") {
|
489 |
b3119a61
|
Phil Davis
|
$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext('%1$s, %2$s Service is %3$s'), $service["description"], $service["name"], $statustext) . "\"></i>{$spacer}";
|
490 |
e48cdc01
|
jim-p
|
}
|
491 |
0a9d81fb
|
NOYB
|
|
492 |
|
|
$spacer = ($withtext) ? " " : "";
|
493 |
|
|
if ($withthumbs) {
|
494 |
|
|
$output .= "<i class=\"{$text_class} {$fa_class_thumbs} {$fa_size}\" title=\"{$Thumbs_UpDown}\"></i>{$spacer}";
|
495 |
|
|
}
|
496 |
|
|
|
497 |
|
|
if ($withtext) {
|
498 |
|
|
$output .= "<span class=\"" . $text_class . "\">" . $statustext . "</span>";
|
499 |
|
|
}
|
500 |
|
|
|
501 |
e48cdc01
|
jim-p
|
return $output;
|
502 |
|
|
}
|
503 |
|
|
|
504 |
f4daf025
|
jim-p
|
function get_service_control_links($service, $addname = false) {
|
505 |
49840447
|
PiBa-NL
|
global $g;
|
506 |
e48cdc01
|
jim-p
|
$output = "";
|
507 |
f4daf025
|
jim-p
|
$stitle = ($addname) ? $service['name'] . " " : "";
|
508 |
1180e4f0
|
Sjon Hortensius
|
|
509 |
|
|
switch ($service['name']) {
|
510 |
|
|
case "openvpn":
|
511 |
74b0f23e
|
Stephen Beaver
|
$link = '<a title="%s" href="#" id="openvpn-%s-' . $service['mode'] . '-' . $service['vpnid'] . '" >';
|
512 |
1180e4f0
|
Sjon Hortensius
|
break;
|
513 |
|
|
case "captiveportal":
|
514 |
74b0f23e
|
Stephen Beaver
|
$link = '<a title="%s" href="#" id="captiveportal-%s-' . $service['zone'] . '">';
|
515 |
1180e4f0
|
Sjon Hortensius
|
break;
|
516 |
|
|
default:
|
517 |
ab7e04c7
|
Colin Fleming
|
$link = '<a title="%s" href="#" id="%s-' . $service['name'] . '">';
|
518 |
1180e4f0
|
Sjon Hortensius
|
}
|
519 |
|
|
|
520 |
61e047a5
|
Phil Davis
|
if (get_service_status($service)) {
|
521 |
e48cdc01
|
jim-p
|
switch ($service['name']) {
|
522 |
|
|
case "openvpn":
|
523 |
74b0f23e
|
Stephen Beaver
|
$output .= '<a href="#" id="openvpn-restartservice-' . $service['mode'] . '-' . $service['vpnid'] . '" >';
|
524 |
e48cdc01
|
jim-p
|
break;
|
525 |
|
|
case "captiveportal":
|
526 |
ab7e04c7
|
Colin Fleming
|
$output .= '<a href="#" id="captiveportal-restartservice-' . $service['zone'] . '">';
|
527 |
e48cdc01
|
jim-p
|
break;
|
528 |
|
|
default:
|
529 |
74b0f23e
|
Stephen Beaver
|
$output .= '<a href="#" id="restartservice-' . $service['name'] . '" >';
|
530 |
e48cdc01
|
jim-p
|
}
|
531 |
74b0f23e
|
Stephen Beaver
|
|
532 |
ab7e04c7
|
Colin Fleming
|
$output .= "<i class=\"fa fa-repeat\" title=\"" . sprintf(gettext("Restart %sService"), $stitle) . "\"></i></a>\n";
|
533 |
74b0f23e
|
Stephen Beaver
|
|
534 |
e48cdc01
|
jim-p
|
switch ($service['name']) {
|
535 |
|
|
case "openvpn":
|
536 |
74b0f23e
|
Stephen Beaver
|
$output .= '<a href="#" id="openvpn-stopservice-' . $service['mode'] . '-' . $service['vpnid'] . '" >';
|
537 |
e48cdc01
|
jim-p
|
break;
|
538 |
|
|
case "captiveportal":
|
539 |
ab7e04c7
|
Colin Fleming
|
$output .= '<a href="#" id="captiveportal-stopservice-' . $service['zone'] . '">';
|
540 |
e48cdc01
|
jim-p
|
break;
|
541 |
|
|
default:
|
542 |
74b0f23e
|
Stephen Beaver
|
$output .= '<a href="#" id="stopservice-' . $service['name'] . '">';
|
543 |
e48cdc01
|
jim-p
|
}
|
544 |
74b0f23e
|
Stephen Beaver
|
|
545 |
335ac1e8
|
Stephen Beaver
|
$output .= "<i class=\"fa fa-stop-circle-o\" title=\"" . sprintf(gettext("Stop %sService"), $stitle) . "\"></i></a>";
|
546 |
74b0f23e
|
Stephen Beaver
|
|
547 |
e48cdc01
|
jim-p
|
} else {
|
548 |
ccfc0269
|
phildd
|
$service_enabled = is_service_enabled($service['name']);
|
549 |
1180e4f0
|
Sjon Hortensius
|
|
550 |
46bb8a0b
|
Sjon Hortensius
|
if ($service['name'] == 'openvpn' || $service['name'] == 'captiveportal' || $service_enabled) {
|
551 |
1180e4f0
|
Sjon Hortensius
|
$output .= sprintf($link, sprintf(gettext("Start %sService"), $stitle), 'startservice');
|
552 |
7ea65674
|
Jared Dillard
|
$output .= '<i class="fa fa-play-circle"></i></a> ';
|
553 |
e48cdc01
|
jim-p
|
}
|
554 |
|
|
}
|
555 |
1180e4f0
|
Sjon Hortensius
|
|
556 |
e48cdc01
|
jim-p
|
return $output;
|
557 |
|
|
}
|
558 |
ee6e6011
|
jim-p
|
|
559 |
|
|
function service_control_start($name, $extras) {
|
560 |
|
|
global $g;
|
561 |
61e047a5
|
Phil Davis
|
switch ($name) {
|
562 |
ee6e6011
|
jim-p
|
case 'radvd':
|
563 |
|
|
services_radvd_configure();
|
564 |
|
|
break;
|
565 |
|
|
case 'captiveportal':
|
566 |
2f9951fe
|
Renato Botelho
|
$zone = htmlspecialchars($extras['zone']);
|
567 |
ee6e6011
|
jim-p
|
captiveportal_init_webgui_zonename($zone);
|
568 |
|
|
break;
|
569 |
|
|
case 'ntpd':
|
570 |
|
|
case 'openntpd':
|
571 |
|
|
system_ntp_configure();
|
572 |
|
|
break;
|
573 |
69eefb50
|
Renato Botelho
|
case 'dpinger':
|
574 |
b05a8f35
|
jim-p
|
setup_gateways_monitor();
|
575 |
|
|
break;
|
576 |
ee6e6011
|
jim-p
|
case 'bsnmpd':
|
577 |
|
|
services_snmpd_configure();
|
578 |
|
|
break;
|
579 |
9590e0de
|
Phil Davis
|
case 'dhcrelay':
|
580 |
|
|
services_dhcrelay_configure();
|
581 |
|
|
break;
|
582 |
|
|
case 'dhcrelay6':
|
583 |
|
|
services_dhcrelay6_configure();
|
584 |
|
|
break;
|
585 |
ee6e6011
|
jim-p
|
case 'dnsmasq':
|
586 |
|
|
services_dnsmasq_configure();
|
587 |
|
|
break;
|
588 |
a8604dc6
|
Phil Davis
|
case 'unbound':
|
589 |
|
|
services_unbound_configure();
|
590 |
|
|
break;
|
591 |
ee6e6011
|
jim-p
|
case 'dhcpd':
|
592 |
|
|
services_dhcpd_configure();
|
593 |
|
|
break;
|
594 |
|
|
case 'igmpproxy':
|
595 |
|
|
services_igmpproxy_configure();
|
596 |
|
|
break;
|
597 |
|
|
case 'miniupnpd':
|
598 |
|
|
upnp_action('start');
|
599 |
|
|
break;
|
600 |
8b4abd59
|
Ermal
|
case 'ipsec':
|
601 |
ee6e6011
|
jim-p
|
vpn_ipsec_force_reload();
|
602 |
|
|
break;
|
603 |
aaa78416
|
jim-p
|
case 'sshd':
|
604 |
|
|
send_event("service restart sshd");
|
605 |
|
|
break;
|
606 |
ee6e6011
|
jim-p
|
case 'openvpn':
|
607 |
2f9951fe
|
Renato Botelho
|
$vpnmode = isset($extras['vpnmode']) ? htmlspecialchars($extras['vpnmode']) : htmlspecialchars($extras['mode']);
|
608 |
ee6e6011
|
jim-p
|
if (($vpnmode == "server") || ($vpnmode == "client")) {
|
609 |
2f9951fe
|
Renato Botelho
|
$id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']);
|
610 |
ee6e6011
|
jim-p
|
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
|
611 |
61e047a5
|
Phil Davis
|
if (file_exists($configfile)) {
|
612 |
ee6e6011
|
jim-p
|
openvpn_restart_by_vpnid($vpnmode, $id);
|
613 |
61e047a5
|
Phil Davis
|
}
|
614 |
ee6e6011
|
jim-p
|
}
|
615 |
|
|
break;
|
616 |
|
|
case 'relayd':
|
617 |
|
|
relayd_configure();
|
618 |
|
|
break;
|
619 |
|
|
default:
|
620 |
|
|
start_service($name);
|
621 |
|
|
break;
|
622 |
|
|
}
|
623 |
086cf944
|
Phil Davis
|
return sprintf(gettext("%s has been started."), htmlspecialchars($name));
|
624 |
ee6e6011
|
jim-p
|
}
|
625 |
|
|
function service_control_stop($name, $extras) {
|
626 |
|
|
global $g;
|
627 |
61e047a5
|
Phil Davis
|
switch ($name) {
|
628 |
ee6e6011
|
jim-p
|
case 'radvd':
|
629 |
|
|
killbypid("{$g['varrun_path']}/radvd.pid");
|
630 |
|
|
break;
|
631 |
|
|
case 'captiveportal':
|
632 |
2f9951fe
|
Renato Botelho
|
$zone = htmlspecialchars($extras['zone']);
|
633 |
cd41643d
|
Renato Botelho
|
killbypid("{$g['varrun_path']}/nginx-{$zone}-CaptivePortal.pid");
|
634 |
|
|
killbypid("{$g['varrun_path']}/nginx-{$zone}-CaptivePortal-SSL.pid");
|
635 |
ee6e6011
|
jim-p
|
break;
|
636 |
|
|
case 'ntpd':
|
637 |
|
|
killbyname("ntpd");
|
638 |
|
|
break;
|
639 |
|
|
case 'openntpd':
|
640 |
|
|
killbyname("openntpd");
|
641 |
|
|
break;
|
642 |
69eefb50
|
Renato Botelho
|
case 'dpinger':
|
643 |
|
|
stop_dpinger();
|
644 |
b05a8f35
|
jim-p
|
break;
|
645 |
ee6e6011
|
jim-p
|
case 'bsnmpd':
|
646 |
|
|
killbypid("{$g['varrun_path']}/snmpd.pid");
|
647 |
|
|
break;
|
648 |
|
|
case 'choparp':
|
649 |
|
|
killbyname("choparp");
|
650 |
|
|
break;
|
651 |
|
|
case 'dhcpd':
|
652 |
|
|
killbyname("dhcpd");
|
653 |
|
|
break;
|
654 |
|
|
case 'dhcrelay':
|
655 |
|
|
killbypid("{$g['varrun_path']}/dhcrelay.pid");
|
656 |
|
|
break;
|
657 |
9590e0de
|
Phil Davis
|
case 'dhcrelay6':
|
658 |
|
|
killbypid("{$g['varrun_path']}/dhcrelay6.pid");
|
659 |
|
|
break;
|
660 |
ee6e6011
|
jim-p
|
case 'dnsmasq':
|
661 |
|
|
killbypid("{$g['varrun_path']}/dnsmasq.pid");
|
662 |
|
|
break;
|
663 |
33232486
|
Warren Baker
|
case 'unbound':
|
664 |
|
|
killbypid("{$g['varrun_path']}/unbound.pid");
|
665 |
|
|
break;
|
666 |
ee6e6011
|
jim-p
|
case 'igmpproxy':
|
667 |
|
|
killbyname("igmpproxy");
|
668 |
|
|
break;
|
669 |
|
|
case 'miniupnpd':
|
670 |
|
|
upnp_action('stop');
|
671 |
|
|
break;
|
672 |
|
|
case 'sshd':
|
673 |
|
|
killbyname("sshd");
|
674 |
|
|
break;
|
675 |
8b4abd59
|
Ermal
|
case 'ipsec':
|
676 |
|
|
exec("/usr/local/sbin/ipsec stop");
|
677 |
ee6e6011
|
jim-p
|
break;
|
678 |
|
|
case 'openvpn':
|
679 |
2f9951fe
|
Renato Botelho
|
$vpnmode = htmlspecialchars($extras['vpnmode']);
|
680 |
ee6e6011
|
jim-p
|
if (($vpnmode == "server") or ($vpnmode == "client")) {
|
681 |
2f9951fe
|
Renato Botelho
|
$id = htmlspecialchars($extras['id']);
|
682 |
ee6e6011
|
jim-p
|
$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid";
|
683 |
|
|
killbypid($pidfile);
|
684 |
|
|
}
|
685 |
|
|
break;
|
686 |
|
|
case 'relayd':
|
687 |
|
|
mwexec('pkill relayd');
|
688 |
|
|
break;
|
689 |
|
|
default:
|
690 |
|
|
stop_service($name);
|
691 |
|
|
break;
|
692 |
|
|
}
|
693 |
|
|
return sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
|
694 |
|
|
}
|
695 |
33232486
|
Warren Baker
|
|
696 |
ee6e6011
|
jim-p
|
function service_control_restart($name, $extras) {
|
697 |
|
|
global $g;
|
698 |
61e047a5
|
Phil Davis
|
switch ($name) {
|
699 |
ee6e6011
|
jim-p
|
case 'radvd':
|
700 |
|
|
services_radvd_configure();
|
701 |
|
|
break;
|
702 |
|
|
case 'captiveportal':
|
703 |
2f9951fe
|
Renato Botelho
|
$zone = htmlspecialchars($extras['zone']);
|
704 |
cd41643d
|
Renato Botelho
|
killbypid("{$g['varrun_path']}/nginx-{$zone}-CaptivePortal.pid");
|
705 |
|
|
killbypid("{$g['varrun_path']}/nginx-{$zone}-CaptivePortal-SSL.pid");
|
706 |
ee6e6011
|
jim-p
|
captiveportal_init_webgui_zonename($zone);
|
707 |
|
|
break;
|
708 |
|
|
case 'ntpd':
|
709 |
|
|
case 'openntpd':
|
710 |
|
|
system_ntp_configure();
|
711 |
|
|
break;
|
712 |
69eefb50
|
Renato Botelho
|
case 'dpinger':
|
713 |
b05a8f35
|
jim-p
|
setup_gateways_monitor();
|
714 |
|
|
break;
|
715 |
ee6e6011
|
jim-p
|
case 'bsnmpd':
|
716 |
|
|
services_snmpd_configure();
|
717 |
|
|
break;
|
718 |
9590e0de
|
Phil Davis
|
case 'dhcrelay':
|
719 |
|
|
services_dhcrelay_configure();
|
720 |
|
|
break;
|
721 |
|
|
case 'dhcrelay6':
|
722 |
|
|
services_dhcrelay6_configure();
|
723 |
|
|
break;
|
724 |
ee6e6011
|
jim-p
|
case 'dnsmasq':
|
725 |
|
|
services_dnsmasq_configure();
|
726 |
|
|
break;
|
727 |
33232486
|
Warren Baker
|
case 'unbound':
|
728 |
|
|
services_unbound_configure();
|
729 |
|
|
break;
|
730 |
ee6e6011
|
jim-p
|
case 'dhcpd':
|
731 |
|
|
services_dhcpd_configure();
|
732 |
|
|
break;
|
733 |
|
|
case 'igmpproxy':
|
734 |
|
|
services_igmpproxy_configure();
|
735 |
|
|
break;
|
736 |
|
|
case 'miniupnpd':
|
737 |
|
|
upnp_action('restart');
|
738 |
|
|
break;
|
739 |
8b4abd59
|
Ermal
|
case 'ipsec':
|
740 |
ee6e6011
|
jim-p
|
vpn_ipsec_force_reload();
|
741 |
|
|
break;
|
742 |
aaa78416
|
jim-p
|
case 'sshd':
|
743 |
|
|
send_event("service restart sshd");
|
744 |
|
|
break;
|
745 |
ee6e6011
|
jim-p
|
case 'openvpn':
|
746 |
2f9951fe
|
Renato Botelho
|
$vpnmode = htmlspecialchars($extras['vpnmode']);
|
747 |
ee6e6011
|
jim-p
|
if ($vpnmode == "server" || $vpnmode == "client") {
|
748 |
2f9951fe
|
Renato Botelho
|
$id = htmlspecialchars($extras['id']);
|
749 |
ee6e6011
|
jim-p
|
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
|
750 |
61e047a5
|
Phil Davis
|
if (file_exists($configfile)) {
|
751 |
ee6e6011
|
jim-p
|
openvpn_restart_by_vpnid($vpnmode, $id);
|
752 |
61e047a5
|
Phil Davis
|
}
|
753 |
ee6e6011
|
jim-p
|
}
|
754 |
|
|
break;
|
755 |
|
|
case 'relayd':
|
756 |
|
|
relayd_configure(true);
|
757 |
|
|
break;
|
758 |
|
|
default:
|
759 |
|
|
restart_service($name);
|
760 |
|
|
break;
|
761 |
|
|
}
|
762 |
086cf944
|
Phil Davis
|
return sprintf(gettext("%s has been restarted."), htmlspecialchars($name));
|
763 |
ee6e6011
|
jim-p
|
}
|
764 |
|
|
|
765 |
17098641
|
Ermal
|
?>
|