Revision cd72ded3
Added by Timo Boettcher about 18 years ago
usr/local/www/status_services.php | ||
---|---|---|
57 | 57 |
if(file_exists('/usr/local/etc/rc.d/miniupnpd.sh')) |
58 | 58 |
mwexec('/usr/local/etc/rc.d/miniupnpd.sh restart'); |
59 | 59 |
break; |
60 |
case 'racoon': |
|
61 |
exec("killall -9 racoon"); |
|
62 |
sleep(1); |
|
63 |
vpn_ipsec_force_reload(); |
|
64 |
break; |
|
60 |
case 'racoon': |
|
61 |
exec("killall -9 racoon"); |
|
62 |
sleep(1); |
|
63 |
vpn_ipsec_force_reload(); |
|
64 |
break; |
|
65 |
case 'openvpn': |
|
66 |
$vpnmode = $_GET['vpnmode']; |
|
67 |
if (($vpnmode == "server") or ($vpnmode == "client")) { |
|
68 |
$id = $_GET['id']; |
|
69 |
if (is_numeric($id)) { |
|
70 |
$pidfile = $g['varrun_path'] . "/openvpn_{$vpnmode}{$id}.pid"; |
|
71 |
killbypid($pidfile); |
|
72 |
sleep(1); |
|
73 |
$configfile = $g['varetc_path'] . "/openvpn_{$vpnmode}{$id}.conf"; |
|
74 |
mwexec_bg("openvpn --config $configfile"); |
|
75 |
} |
|
76 |
} |
|
77 |
break; |
|
65 | 78 |
default: |
66 | 79 |
restart_service($_GET['service']); |
67 | 80 |
break; |
... | ... | |
85 | 98 |
if(file_exists('/usr/local/etc/rc.d/miniupnpd.sh')) |
86 | 99 |
mwexec('/usr/local/etc/rc.d/miniupnpd.sh start'); |
87 | 100 |
break; |
88 |
case 'racoon': |
|
89 |
exec("killall -9 racoon"); |
|
90 |
sleep(1); |
|
91 |
vpn_ipsec_force_reload(); |
|
92 |
break; |
|
101 |
case 'racoon': |
|
102 |
exec("killall -9 racoon"); |
|
103 |
sleep(1); |
|
104 |
vpn_ipsec_force_reload(); |
|
105 |
break; |
|
106 |
case 'openvpn': |
|
107 |
$vpnmode = $_GET['vpnmode']; |
|
108 |
if (($vpnmode == "server") or ($vpnmode == "client")) { |
|
109 |
$id = $_GET['id']; |
|
110 |
if (is_numeric($id)) { |
|
111 |
$configfile = $g['varetc_path'] . "/openvpn_{$vpnmode}{$id}.conf"; |
|
112 |
mwexec_bg("openvpn --config $configfile"); |
|
113 |
} |
|
114 |
} |
|
115 |
break; |
|
93 | 116 |
default: |
94 | 117 |
start_service($_GET['service']); |
95 | 118 |
break; |
96 | 119 |
} |
97 |
$savemsg = "{$_GET['service']} has been started.";
|
|
120 |
$savemsg = "{$_GET['service']} has been started.";
|
|
98 | 121 |
sleep(5); |
99 | 122 |
} |
100 | 123 |
|
... | ... | |
107 | 130 |
case 'choparp': |
108 | 131 |
killbyname("choparp"); |
109 | 132 |
break; |
110 |
case 'dhcpd':
|
|
133 |
case 'dhcpd':
|
|
111 | 134 |
killbyname("dhcpd"); |
112 |
break;
|
|
113 |
case 'dhcrelay':
|
|
114 |
killbypid("{$g['varrun_path']}/dhcrelay.pid");
|
|
115 |
break;
|
|
116 |
case 'dnsmasq':
|
|
135 |
break;
|
|
136 |
case 'dhcrelay':
|
|
137 |
killbypid("{$g['varrun_path']}/dhcrelay.pid");
|
|
138 |
break;
|
|
139 |
case 'dnsmasq':
|
|
117 | 140 |
killbypid("{$g['varrun_path']}/dnsmasq.pid"); |
118 | 141 |
break; |
119 | 142 |
case 'miniupnpd': |
... | ... | |
123 | 146 |
break; |
124 | 147 |
case 'ntpd': |
125 | 148 |
killbyname("ntpd"); |
126 |
break;
|
|
127 |
case 'sshd':
|
|
149 |
break;
|
|
150 |
case 'sshd':
|
|
128 | 151 |
killbyname("sshd"); |
129 |
break; |
|
130 |
case 'racoon': |
|
131 |
exec("killall -9 racoon"); |
|
152 |
break; |
|
153 |
case 'racoon': |
|
154 |
exec("killall -9 racoon"); |
|
155 |
break; |
|
156 |
case 'openvpn': |
|
157 |
$vpnmode = $_GET['vpnmode']; |
|
158 |
if (($vpnmode == "server") or ($vpnmode == "client")) { |
|
159 |
$id = $_GET['id']; |
|
160 |
if (is_numeric($id)) { |
|
161 |
$pidfile = $g['varrun_path'] . "/openvpn_{$vpnmode}{$id}.pid"; |
|
162 |
killbypid($pidfile); |
|
163 |
} |
|
164 |
} |
|
165 |
break; |
|
132 | 166 |
default: |
133 |
stop_service($_GET['service']);
|
|
167 |
stop_service($_GET['service']);
|
|
134 | 168 |
break; |
135 | 169 |
} |
136 |
$savemsg = "{$_GET['service']} " . gettext("has been stopped.");
|
|
137 |
sleep(5);
|
|
170 |
$savemsg = "{$_GET['service']} " . gettext("has been stopped.");
|
|
171 |
sleep(5);
|
|
138 | 172 |
} |
139 | 173 |
|
140 | 174 |
/* batch mode, allow other scripts to call this script */ |
... | ... | |
235 | 269 |
} |
236 | 270 |
|
237 | 271 |
if($config['installedpackages']['miniupnpd']['config'][0]['enable']) { |
238 |
$pconfig['name'] = "miniupnpd";
|
|
239 |
$pconfig['description'] = gettext("UPnP Service");
|
|
240 |
$services[] = $pconfig;
|
|
241 |
unset($pconfig);
|
|
272 |
$pconfig['name'] = "miniupnpd";
|
|
273 |
$pconfig['description'] = gettext("UPnP Service");
|
|
274 |
$services[] = $pconfig;
|
|
275 |
unset($pconfig);
|
|
242 | 276 |
} |
243 | 277 |
|
244 | 278 |
if (isset($config['ipsec']['enable'])) { |
245 |
$pconfig['name'] = "racoon";
|
|
246 |
$pconfig['description'] = gettext("IPSEC VPN");
|
|
247 |
$services[] = $pconfig;
|
|
248 |
unset($pconfig);
|
|
279 |
$pconfig['name'] = "racoon";
|
|
280 |
$pconfig['description'] = gettext("IPSEC VPN");
|
|
281 |
$services[] = $pconfig;
|
|
282 |
unset($pconfig);
|
|
249 | 283 |
} |
250 | 284 |
|
285 |
foreach (array('server', 'client') as $mode) { |
|
286 |
if (is_array($config['installedpackages']["openvpn$mode"]['config'])) { |
|
287 |
foreach ($config['installedpackages']["openvpn$mode"]['config'] as $id => $settings) { |
|
288 |
$setting = $config['installedpackages']["openvpn$mode"]['config'][$id]; |
|
289 |
if (!$setting['disable']) { |
|
290 |
$pconfig['name'] = "openvpn"; |
|
291 |
$pconfig['mode'] = $mode; |
|
292 |
$pconfig['id'] = $id; |
|
293 |
$pconfig['description'] = "OpenVPN ".$mode.": ".htmlspecialchars($setting['description']); |
|
294 |
$services[] = $pconfig; |
|
295 |
unset($pconfig); |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
|
|
251 | 302 |
if($services) { |
252 | 303 |
foreach($services as $service) { |
253 | 304 |
if(!$service['name']) continue; |
254 | 305 |
if(!$service['description']) $service['description'] = get_pkg_descr($service['name']); |
255 | 306 |
echo '<tr><td class="listlr">' . $service['name'] . '</td>'; |
256 | 307 |
echo '<td class="listr">' . $service['description'] . '</td>'; |
257 |
if(is_service_running($service['name'], $ps) or is_process_running($service['name']) ) { |
|
308 |
if ($service['name'] == "openvpn") { |
|
309 |
$running = (is_pid_running($g['varrun_path'] . "/openvpn_{$service['mode']}{$service['id']}.pid") ); |
|
310 |
} else { |
|
311 |
$running = (is_service_running($service['name'], $ps) or is_process_running($service['name']) ); |
|
312 |
} |
|
313 |
if($running) { |
|
258 | 314 |
echo '<td class="listr"><center>'; |
259 | 315 |
echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\"> Running</td>"; |
260 |
$running = true; |
|
261 | 316 |
} else { |
262 | 317 |
echo '<td class="listbg"><center>'; |
263 | 318 |
echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> <font color=\"white\">Stopped</td>"; |
264 |
$running = false; |
|
265 | 319 |
} |
266 | 320 |
echo '<td valign="middle" class="list" nowrap>'; |
267 | 321 |
if($running) { |
268 |
echo "<a href='status_services.php?mode=restartservice&service={$service['name']}'>"; |
|
322 |
if ($service['name'] == "openvpn") { |
|
323 |
echo "<a href='status_services.php?mode=restartservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['id']}'>"; |
|
324 |
} else { |
|
325 |
echo "<a href='status_services.php?mode=restartservice&service={$service['name']}'>"; |
|
326 |
} |
|
269 | 327 |
echo "<img title='Restart Service' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_restart.gif'></a> "; |
270 |
echo "<a href='status_services.php?mode=stopservice&service={$service['name']}'>"; |
|
328 |
if ($service['name'] == "openvpn") { |
|
329 |
echo "<a href='status_services.php?mode=stopservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['id']}'>"; |
|
330 |
} else { |
|
331 |
echo "<a href='status_services.php?mode=stopservice&service={$service['name']}'> "; |
|
332 |
} |
|
271 | 333 |
echo "<img title='Stop Service' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_stop.gif'> "; |
272 | 334 |
echo "</a>"; |
273 | 335 |
} else { |
274 |
echo "<a href='status_services.php?mode=startservice&service={$service['name']}'> "; |
|
336 |
if ($service['name'] == "openvpn") { |
|
337 |
echo "<a href='status_services.php?mode=startservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['id']}'>"; |
|
338 |
} else { |
|
339 |
echo "<a href='status_services.php?mode=startservice&service={$service['name']}'> "; |
|
340 |
} |
|
341 |
|
|
275 | 342 |
echo "<img title='Start Service' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_start.gif'></a> "; |
276 | 343 |
} |
277 | 344 |
echo '</td>'; |
... | ... | |
280 | 347 |
} else { |
281 | 348 |
echo "<tr><td colspan=\"3\"><center>No services found.</td></tr>"; |
282 | 349 |
} |
350 |
|
|
283 | 351 |
?> |
284 | 352 |
</table> |
285 | 353 |
|
Also available in: Unified diff
Make OpenVPN usable in status_service.php