Project

General

Profile

Download (7.62 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 a0e4cea2 Scott Ullrich
47 246a887a Ermal
if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) {
48 6c3e2b19 Scott Ullrich
	switch($_GET['service']) {
49 0ed8d746 bcyrill
		case 'radvd':
50
			services_radvd_configure();
51
			break;
52 01d4b621 Ermal
		case 'captiveportal':
53 e3cf528e bcyrill
			$zone = $_GET['zone'];
54
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
55
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
56
			captiveportal_init_webgui_zonename($zone);
57 01d4b621 Ermal
			break;
58 96155ce4 Scott Ullrich
		case 'ntpd':
59 c8960970 Ermal
		case 'openntpd':
60 96155ce4 Scott Ullrich
			system_ntp_configure();
61
			break;
62 6c3e2b19 Scott Ullrich
		case 'bsnmpd':
63
			services_snmpd_configure();
64
			break;
65
		case 'dnsmasq':
66
			services_dnsmasq_configure();
67
			break;
68
		case 'dhcpd':
69
			services_dhcpd_configure();
70 422e039b Scott Ullrich
			break;
71 41997fbb Ermal Luci
		case 'igmpproxy':
72
			services_igmpproxy_configure();
73
			break;
74 422e039b Scott Ullrich
		case 'miniupnpd':
75 431484c8 Ryan Wagoner
			upnp_action('restart');	
76 6c3e2b19 Scott Ullrich
			break;
77 cd72ded3 Timo Boettcher
		case 'racoon':
78
			vpn_ipsec_force_reload();
79
			break;
80
		case 'openvpn':         
81
			$vpnmode = $_GET['vpnmode'];
82 0349e09d Ermal
			if ($vpnmode == "server" || $vpnmode == "client") {
83 cd72ded3 Timo Boettcher
				$id = $_GET['id'];
84 45611d02 Ermal
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
85
				$pidfile = $g['varrun_path'] . "/openvpn_{$vpnmode}{$id}.pid";
86
				if (file_exists($configfile)) {
87 cd72ded3 Timo Boettcher
					killbypid($pidfile);
88
					sleep(1);
89 45611d02 Ermal
					mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
90 cd72ded3 Timo Boettcher
				}
91
			}
92
			break;
93 d3534235 jim-p
		case 'relayd':
94
			relayd_configure(true);
95
			break;
96 6c3e2b19 Scott Ullrich
		default:
97
			restart_service($_GET['service']);
98
			break;
99
	}
100 daab67a1 Scott Ullrich
	$savemsg = sprintf(gettext("%s has been restarted."),htmlspecialchars($_GET['service']));
101 422e039b Scott Ullrich
	sleep(5);
102 a0e4cea2 Scott Ullrich
}
103
104 246a887a Ermal
if($_GET['mode'] == "startservice" and !empty($_GET['service'])) {
105 3e32a807 Scott Ullrich
	switch($_GET['service']) {
106 0ed8d746 bcyrill
		case 'radvd':
107
			services_radvd_configure();
108
			break;
109 01d4b621 Ermal
		case 'captiveportal':
110 e3cf528e bcyrill
			$zone = $_GET['zone'];
111
			captiveportal_init_webgui_zonename($zone);
112 01d4b621 Ermal
			break;
113 96155ce4 Scott Ullrich
		case 'ntpd':
114 c8960970 Ermal
		case 'openntpd':
115 96155ce4 Scott Ullrich
			system_ntp_configure();
116 e3cf528e bcyrill
			break;
117 3e32a807 Scott Ullrich
		case 'bsnmpd':
118 3af54e48 Scott Ullrich
			services_snmpd_configure();
119 3e32a807 Scott Ullrich
			break;
120
		case 'dnsmasq':
121
			services_dnsmasq_configure();
122
			break;
123
		case 'dhcpd':
124
			services_dhcpd_configure();
125 422e039b Scott Ullrich
			break;
126 41997fbb Ermal Luci
		case 'igmpproxy':
127
			services_igmpproxy_configure();
128
			break;
129 422e039b Scott Ullrich
		case 'miniupnpd':
130 431484c8 Ryan Wagoner
			upnp_action('start');
131 3e32a807 Scott Ullrich
			break;
132 cd72ded3 Timo Boettcher
		case 'racoon':
133
			vpn_ipsec_force_reload();
134
			break;
135
		case 'openvpn':
136
			$vpnmode = $_GET['vpnmode'];
137 aa79a721 Ermal
			if (($vpnmode == "server") || ($vpnmode == "client")) {
138 cd72ded3 Timo Boettcher
				$id = $_GET['id'];
139 45611d02 Ermal
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
140
				if (file_exists($configfile))
141 aa79a721 Ermal
					mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
142 cd72ded3 Timo Boettcher
			}
143
			break;
144 d3534235 jim-p
		case 'relayd':
145
			relayd_configure();
146
			break;
147 3e32a807 Scott Ullrich
		default:
148
			start_service($_GET['service']);
149
			break;
150
	}
151 daab67a1 Scott Ullrich
	$savemsg = sprintf(gettext("%s has been started."),htmlspecialchars($_GET['service']));
152 422e039b Scott Ullrich
	sleep(5);
153 a0e4cea2 Scott Ullrich
}
154
155 25b66ec5 Scott Ullrich
/* stop service */
156 246a887a Ermal
if($_GET['mode'] == "stopservice" && !empty($_GET['service'])) {
157 422e039b Scott Ullrich
	switch($_GET['service']) {
158 0ed8d746 bcyrill
		case 'radvd':
159
			killbypid("{$g['varrun_path']}/radvd.pid");
160
			break;
161 01d4b621 Ermal
		case 'captiveportal':
162 e3cf528e bcyrill
			$zone = $_GET['zone'];
163
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
164
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
165 01d4b621 Ermal
			break;
166 96155ce4 Scott Ullrich
		case 'ntpd':
167
			killbyname("ntpd");
168
			break;		
169 c8960970 Ermal
		case 'openntpd':
170
			killbyname("openntpd");
171
			break;
172 25b66ec5 Scott Ullrich
		case 'bsnmpd':
173
			killbypid("{$g['varrun_path']}/snmpd.pid");
174
			break;
175
		case 'choparp':
176
			killbyname("choparp");
177
			break;
178 cd72ded3 Timo Boettcher
		case 'dhcpd':
179 25b66ec5 Scott Ullrich
			killbyname("dhcpd");
180 cd72ded3 Timo Boettcher
			break;
181
		case 'dhcrelay':
182
			killbypid("{$g['varrun_path']}/dhcrelay.pid");
183
			break;
184
		case 'dnsmasq':
185 25b66ec5 Scott Ullrich
			killbypid("{$g['varrun_path']}/dnsmasq.pid");
186
			break;
187 41997fbb Ermal Luci
		case 'igmpproxy':
188
			killbyname("igmpproxy");
189
			break;
190 422e039b Scott Ullrich
		case 'miniupnpd':
191 431484c8 Ryan Wagoner
			upnp_action('stop');
192 25b66ec5 Scott Ullrich
			break;
193 cd72ded3 Timo Boettcher
		case 'sshd':
194 25b66ec5 Scott Ullrich
			killbyname("sshd");
195 cd72ded3 Timo Boettcher
			break;
196
		case 'racoon':
197
			exec("killall -9 racoon");
198
			break;
199
		case 'openvpn':         
200
			$vpnmode = $_GET['vpnmode'];
201
			if (($vpnmode == "server") or ($vpnmode == "client")) {
202
				$id = $_GET['id'];
203 45611d02 Ermal
				$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid";
204
				killbypid($pidfile);
205 cd72ded3 Timo Boettcher
			}
206
			break;
207 d3534235 jim-p
		case 'relayd':
208
			mwexec('pkill relayd');
209
			break;
210 422e039b Scott Ullrich
		default:
211 cd72ded3 Timo Boettcher
			stop_service($_GET['service']);
212 422e039b Scott Ullrich
			break;
213
	}
214 daab67a1 Scott Ullrich
	$savemsg = sprintf(gettext("%s has been stopped."), htmlspecialchars($_GET['service']));
215 cd72ded3 Timo Boettcher
	sleep(5);
216 a0e4cea2 Scott Ullrich
}
217
218
/* batch mode, allow other scripts to call this script */
219 246a887a Ermal
if($_GET['batch'])
220
	exit;
221 b9eadc0c Colin Smith
222 7f6ea91f Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Services"));
223 4df96eff Scott Ullrich
include("head.inc");
224
225 a0e4cea2 Scott Ullrich
?>
226
227
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
228
<?php
229
include("fbegin.inc");
230
?>
231
<form action="status_services.php" method="post">
232
<?php if ($savemsg) print_info_box($savemsg); ?>
233
234
<p>
235
236 0f10aee4 Bill Marquette
<div id="boxarea">
237 3473bb6a Scott Ullrich
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
238 a0995b8d jim-p
	<thead>
239 a9bc3b82 Scott Ullrich
	<tr>
240 a0995b8d jim-p
		<td class="listhdrr" align="center"><?=gettext("Service");?></td>
241
		<td class="listhdrr" align="center"><?=gettext("Description");?></td>
242
		<td class="listhdrr" align="center"><?=gettext("Status");?></td>
243 a9bc3b82 Scott Ullrich
	</tr>
244 a0995b8d jim-p
	</thead>
245
	<tbody>
246 a0e4cea2 Scott Ullrich
<?php
247
248 e48cdc01 jim-p
$services = get_services();
249 41997fbb Ermal Luci
250 246a887a Ermal
if (count($services) > 0) {
251 b2254c7f jim-p
	uasort($services, "service_name_compare");
252 25d3fbd5 Scott Ullrich
	foreach($services as $service) {
253 246a887a Ermal
		if (empty($service['name']))
254
			continue;
255
		if (empty($service['description']))
256
			$service['description'] = get_pkg_descr($service['name']);
257 391abfcf jim-p
		echo '<tr><td class="listlr" width="20%">' . $service['name'] . '</td>' . "\n";
258
		echo '<td class="listr" width="55%">' . $service['description'] . '</td>' . "\n";
259 36d1c798 jim-p
		echo get_service_status_icon($service, true, true);
260 ef09107d Colin Smith
		echo '<td valign="middle" class="list" nowrap>';
261 b1460af3 jim-p
		echo get_service_control_links($service);
262 391abfcf jim-p
		$scut = get_shortcut_by_service_name($service['name']);
263
		if (!empty($scut)) {
264
			echo get_shortcut_main_link($scut, true, $service);
265
			echo get_shortcut_status_link($scut, true, $service);
266
			echo get_shortcut_log_link($scut, true);
267
		}
268 a0995b8d jim-p
		echo "</td></tr>\n";
269 a0e4cea2 Scott Ullrich
	}
270 b9eadc0c Colin Smith
} else {
271 39121390 bcyrill
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . ".</td></tr>\n";
272 b9eadc0c Colin Smith
}
273 cd72ded3 Timo Boettcher
274 a0e4cea2 Scott Ullrich
?>
275 a0995b8d jim-p
</tbody>
276 a0e4cea2 Scott Ullrich
</table>
277 12af52d9 Scott Ullrich
</div>
278 01d4b621 Ermal
</p>
279
</form>
280 a0e4cea2 Scott Ullrich
<?php include("fend.inc"); ?>
281
</body>
282
</html>