Project

General

Profile

Download (7.65 KB) Statistics
| Branch: | Tag: | Revision:
1 a0e4cea2 Scott Ullrich
<?php
2
/*
3 ef09107d Colin Smith
    services_status.php
4
    Copyright (C) 2004, 2005 Scott Ullrich
5 a0e4cea2 Scott Ullrich
    All rights reserved.
6
7
    Redistribution and use in source and binary forms, with or without
8
    modification, are permitted provided that the following conditions are met:
9
10
    1. Redistributions of source code must retain the above copyright notice,
11
       this list of conditions and the following disclaimer.
12
13
    2. Redistributions in binary form must reproduce the above copyright
14
       notice, this list of conditions and the following disclaimer in the
15
       documentation and/or other materials provided with the distribution.
16
17
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 ef09107d Colin Smith
    INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19 a0e4cea2 Scott Ullrich
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
    POSSIBILITY OF SUCH DAMAGE.
27
*/
28 1d333258 Scott Ullrich
/*	
29
	pfSense_BUILDER_BINARIES:	/usr/local/sbin/openvpn	/usr/bin/killall	/bin/ps
30
	pfSense_MODULE:	services
31
*/
32 a0e4cea2 Scott Ullrich
33 6b07c15a Matthew Grooms
##|+PRIV
34
##|*IDENT=page-status-services
35
##|*NAME=Status: Services page
36
##|*DESCR=Allow access to the 'Status: Services' page.
37
##|*MATCH=status_services.php*
38
##|-PRIV
39
40 e3c88b77 Ermal
require_once("guiconfig.inc");
41 01d4b621 Ermal
require_once("captiveportal.inc");
42 44173def Ermal Lu?i
require_once("service-utils.inc");
43 9a76a52a Ermal Lu?i
require_once("ipsec.inc");
44 1ac7a864 Chris Buechler
require_once("vpn.inc");
45 d3534235 jim-p
require_once("vslb.inc");
46 a517a108 jmkizer
require_once("shortcuts.inc");
47 a0e4cea2 Scott Ullrich
48 246a887a Ermal
if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) {
49 6c3e2b19 Scott Ullrich
	switch($_GET['service']) {
50 0ed8d746 bcyrill
		case 'radvd':
51
			services_radvd_configure();
52
			break;
53 01d4b621 Ermal
		case 'captiveportal':
54 e3cf528e bcyrill
			$zone = $_GET['zone'];
55
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
56
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
57
			captiveportal_init_webgui_zonename($zone);
58 01d4b621 Ermal
			break;
59 96155ce4 Scott Ullrich
		case 'ntpd':
60 c8960970 Ermal
		case 'openntpd':
61 96155ce4 Scott Ullrich
			system_ntp_configure();
62
			break;
63 6c3e2b19 Scott Ullrich
		case 'bsnmpd':
64
			services_snmpd_configure();
65
			break;
66
		case 'dnsmasq':
67
			services_dnsmasq_configure();
68
			break;
69
		case 'dhcpd':
70
			services_dhcpd_configure();
71 422e039b Scott Ullrich
			break;
72 41997fbb Ermal Luci
		case 'igmpproxy':
73
			services_igmpproxy_configure();
74
			break;
75 422e039b Scott Ullrich
		case 'miniupnpd':
76 431484c8 Ryan Wagoner
			upnp_action('restart');	
77 6c3e2b19 Scott Ullrich
			break;
78 cd72ded3 Timo Boettcher
		case 'racoon':
79
			vpn_ipsec_force_reload();
80
			break;
81
		case 'openvpn':         
82
			$vpnmode = $_GET['vpnmode'];
83 0349e09d Ermal
			if ($vpnmode == "server" || $vpnmode == "client") {
84 cd72ded3 Timo Boettcher
				$id = $_GET['id'];
85 45611d02 Ermal
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
86
				$pidfile = $g['varrun_path'] . "/openvpn_{$vpnmode}{$id}.pid";
87
				if (file_exists($configfile)) {
88 cd72ded3 Timo Boettcher
					killbypid($pidfile);
89
					sleep(1);
90 45611d02 Ermal
					mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
91 cd72ded3 Timo Boettcher
				}
92
			}
93
			break;
94 d3534235 jim-p
		case 'relayd':
95
			relayd_configure(true);
96
			break;
97 6c3e2b19 Scott Ullrich
		default:
98
			restart_service($_GET['service']);
99
			break;
100
	}
101 daab67a1 Scott Ullrich
	$savemsg = sprintf(gettext("%s has been restarted."),htmlspecialchars($_GET['service']));
102 422e039b Scott Ullrich
	sleep(5);
103 a0e4cea2 Scott Ullrich
}
104
105 246a887a Ermal
if($_GET['mode'] == "startservice" and !empty($_GET['service'])) {
106 3e32a807 Scott Ullrich
	switch($_GET['service']) {
107 0ed8d746 bcyrill
		case 'radvd':
108
			services_radvd_configure();
109
			break;
110 01d4b621 Ermal
		case 'captiveportal':
111 e3cf528e bcyrill
			$zone = $_GET['zone'];
112
			captiveportal_init_webgui_zonename($zone);
113 01d4b621 Ermal
			break;
114 96155ce4 Scott Ullrich
		case 'ntpd':
115 c8960970 Ermal
		case 'openntpd':
116 96155ce4 Scott Ullrich
			system_ntp_configure();
117 e3cf528e bcyrill
			break;
118 3e32a807 Scott Ullrich
		case 'bsnmpd':
119 3af54e48 Scott Ullrich
			services_snmpd_configure();
120 3e32a807 Scott Ullrich
			break;
121
		case 'dnsmasq':
122
			services_dnsmasq_configure();
123
			break;
124
		case 'dhcpd':
125
			services_dhcpd_configure();
126 422e039b Scott Ullrich
			break;
127 41997fbb Ermal Luci
		case 'igmpproxy':
128
			services_igmpproxy_configure();
129
			break;
130 422e039b Scott Ullrich
		case 'miniupnpd':
131 431484c8 Ryan Wagoner
			upnp_action('start');
132 3e32a807 Scott Ullrich
			break;
133 cd72ded3 Timo Boettcher
		case 'racoon':
134
			vpn_ipsec_force_reload();
135
			break;
136
		case 'openvpn':
137
			$vpnmode = $_GET['vpnmode'];
138 aa79a721 Ermal
			if (($vpnmode == "server") || ($vpnmode == "client")) {
139 cd72ded3 Timo Boettcher
				$id = $_GET['id'];
140 45611d02 Ermal
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
141
				if (file_exists($configfile))
142 aa79a721 Ermal
					mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
143 cd72ded3 Timo Boettcher
			}
144
			break;
145 d3534235 jim-p
		case 'relayd':
146
			relayd_configure();
147
			break;
148 3e32a807 Scott Ullrich
		default:
149
			start_service($_GET['service']);
150
			break;
151
	}
152 daab67a1 Scott Ullrich
	$savemsg = sprintf(gettext("%s has been started."),htmlspecialchars($_GET['service']));
153 422e039b Scott Ullrich
	sleep(5);
154 a0e4cea2 Scott Ullrich
}
155
156 25b66ec5 Scott Ullrich
/* stop service */
157 246a887a Ermal
if($_GET['mode'] == "stopservice" && !empty($_GET['service'])) {
158 422e039b Scott Ullrich
	switch($_GET['service']) {
159 0ed8d746 bcyrill
		case 'radvd':
160
			killbypid("{$g['varrun_path']}/radvd.pid");
161
			break;
162 01d4b621 Ermal
		case 'captiveportal':
163 e3cf528e bcyrill
			$zone = $_GET['zone'];
164
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
165
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
166 01d4b621 Ermal
			break;
167 96155ce4 Scott Ullrich
		case 'ntpd':
168
			killbyname("ntpd");
169
			break;		
170 c8960970 Ermal
		case 'openntpd':
171
			killbyname("openntpd");
172
			break;
173 25b66ec5 Scott Ullrich
		case 'bsnmpd':
174
			killbypid("{$g['varrun_path']}/snmpd.pid");
175
			break;
176
		case 'choparp':
177
			killbyname("choparp");
178
			break;
179 cd72ded3 Timo Boettcher
		case 'dhcpd':
180 25b66ec5 Scott Ullrich
			killbyname("dhcpd");
181 cd72ded3 Timo Boettcher
			break;
182
		case 'dhcrelay':
183
			killbypid("{$g['varrun_path']}/dhcrelay.pid");
184
			break;
185
		case 'dnsmasq':
186 25b66ec5 Scott Ullrich
			killbypid("{$g['varrun_path']}/dnsmasq.pid");
187
			break;
188 41997fbb Ermal Luci
		case 'igmpproxy':
189
			killbyname("igmpproxy");
190
			break;
191 422e039b Scott Ullrich
		case 'miniupnpd':
192 431484c8 Ryan Wagoner
			upnp_action('stop');
193 25b66ec5 Scott Ullrich
			break;
194 cd72ded3 Timo Boettcher
		case 'sshd':
195 25b66ec5 Scott Ullrich
			killbyname("sshd");
196 cd72ded3 Timo Boettcher
			break;
197
		case 'racoon':
198
			exec("killall -9 racoon");
199
			break;
200
		case 'openvpn':         
201
			$vpnmode = $_GET['vpnmode'];
202
			if (($vpnmode == "server") or ($vpnmode == "client")) {
203
				$id = $_GET['id'];
204 45611d02 Ermal
				$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid";
205
				killbypid($pidfile);
206 cd72ded3 Timo Boettcher
			}
207
			break;
208 d3534235 jim-p
		case 'relayd':
209
			mwexec('pkill relayd');
210
			break;
211 422e039b Scott Ullrich
		default:
212 cd72ded3 Timo Boettcher
			stop_service($_GET['service']);
213 422e039b Scott Ullrich
			break;
214
	}
215 daab67a1 Scott Ullrich
	$savemsg = sprintf(gettext("%s has been stopped."), htmlspecialchars($_GET['service']));
216 cd72ded3 Timo Boettcher
	sleep(5);
217 a0e4cea2 Scott Ullrich
}
218
219
/* batch mode, allow other scripts to call this script */
220 246a887a Ermal
if($_GET['batch'])
221
	exit;
222 b9eadc0c Colin Smith
223 7f6ea91f Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Services"));
224 4df96eff Scott Ullrich
include("head.inc");
225
226 a0e4cea2 Scott Ullrich
?>
227
228
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
229
<?php
230
include("fbegin.inc");
231
?>
232
<form action="status_services.php" method="post">
233
<?php if ($savemsg) print_info_box($savemsg); ?>
234
235
<p>
236
237 0f10aee4 Bill Marquette
<div id="boxarea">
238 3473bb6a Scott Ullrich
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
239 a0995b8d jim-p
	<thead>
240 a9bc3b82 Scott Ullrich
	<tr>
241 a0995b8d jim-p
		<td class="listhdrr" align="center"><?=gettext("Service");?></td>
242
		<td class="listhdrr" align="center"><?=gettext("Description");?></td>
243
		<td class="listhdrr" align="center"><?=gettext("Status");?></td>
244 a9bc3b82 Scott Ullrich
	</tr>
245 a0995b8d jim-p
	</thead>
246
	<tbody>
247 a0e4cea2 Scott Ullrich
<?php
248
249 e48cdc01 jim-p
$services = get_services();
250 41997fbb Ermal Luci
251 246a887a Ermal
if (count($services) > 0) {
252 b2254c7f jim-p
	uasort($services, "service_name_compare");
253 25d3fbd5 Scott Ullrich
	foreach($services as $service) {
254 246a887a Ermal
		if (empty($service['name']))
255
			continue;
256
		if (empty($service['description']))
257
			$service['description'] = get_pkg_descr($service['name']);
258 391abfcf jim-p
		echo '<tr><td class="listlr" width="20%">' . $service['name'] . '</td>' . "\n";
259
		echo '<td class="listr" width="55%">' . $service['description'] . '</td>' . "\n";
260 36d1c798 jim-p
		echo get_service_status_icon($service, true, true);
261 ef09107d Colin Smith
		echo '<td valign="middle" class="list" nowrap>';
262 b1460af3 jim-p
		echo get_service_control_links($service);
263 391abfcf jim-p
		$scut = get_shortcut_by_service_name($service['name']);
264
		if (!empty($scut)) {
265
			echo get_shortcut_main_link($scut, true, $service);
266
			echo get_shortcut_status_link($scut, true, $service);
267
			echo get_shortcut_log_link($scut, true);
268
		}
269 a0995b8d jim-p
		echo "</td></tr>\n";
270 a0e4cea2 Scott Ullrich
	}
271 b9eadc0c Colin Smith
} else {
272 39121390 bcyrill
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . ".</td></tr>\n";
273 b9eadc0c Colin Smith
}
274 cd72ded3 Timo Boettcher
275 a0e4cea2 Scott Ullrich
?>
276 a0995b8d jim-p
</tbody>
277 a0e4cea2 Scott Ullrich
</table>
278 12af52d9 Scott Ullrich
</div>
279 01d4b621 Ermal
</p>
280
</form>
281 a0e4cea2 Scott Ullrich
<?php include("fend.inc"); ?>
282
</body>
283
</html>