Project

General

Profile

Download (7.65 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
    services_status.php
4
    Copyright (C) 2004, 2005 Scott Ullrich
5
    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
    INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
    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
/*	
29
	pfSense_BUILDER_BINARIES:	/usr/local/sbin/openvpn	/usr/bin/killall	/bin/ps
30
	pfSense_MODULE:	services
31
*/
32

    
33
##|+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
require_once("guiconfig.inc");
41
require_once("captiveportal.inc");
42
require_once("service-utils.inc");
43
require_once("ipsec.inc");
44
require_once("vpn.inc");
45
require_once("vslb.inc");
46
require_once("shortcuts.inc");
47

    
48
if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) {
49
	switch($_GET['service']) {
50
		case 'radvd':
51
			services_radvd_configure();
52
			break;
53
		case 'captiveportal':
54
			$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
			break;
59
		case 'ntpd':
60
		case 'openntpd':
61
			system_ntp_configure();
62
			break;
63
		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
			break;
72
		case 'igmpproxy':
73
			services_igmpproxy_configure();
74
			break;
75
		case 'miniupnpd':
76
			upnp_action('restart');	
77
			break;
78
		case 'racoon':
79
			vpn_ipsec_force_reload();
80
			break;
81
		case 'openvpn':         
82
			$vpnmode = $_GET['vpnmode'];
83
			if ($vpnmode == "server" || $vpnmode == "client") {
84
				$id = $_GET['id'];
85
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
86
				$pidfile = $g['varrun_path'] . "/openvpn_{$vpnmode}{$id}.pid";
87
				if (file_exists($configfile)) {
88
					killbypid($pidfile);
89
					sleep(1);
90
					mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
91
				}
92
			}
93
			break;
94
		case 'relayd':
95
			relayd_configure(true);
96
			break;
97
		default:
98
			restart_service($_GET['service']);
99
			break;
100
	}
101
	$savemsg = sprintf(gettext("%s has been restarted."),htmlspecialchars($_GET['service']));
102
	sleep(5);
103
}
104

    
105
if($_GET['mode'] == "startservice" and !empty($_GET['service'])) {
106
	switch($_GET['service']) {
107
		case 'radvd':
108
			services_radvd_configure();
109
			break;
110
		case 'captiveportal':
111
			$zone = $_GET['zone'];
112
			captiveportal_init_webgui_zonename($zone);
113
			break;
114
		case 'ntpd':
115
		case 'openntpd':
116
			system_ntp_configure();
117
			break;
118
		case 'bsnmpd':
119
			services_snmpd_configure();
120
			break;
121
		case 'dnsmasq':
122
			services_dnsmasq_configure();
123
			break;
124
		case 'dhcpd':
125
			services_dhcpd_configure();
126
			break;
127
		case 'igmpproxy':
128
			services_igmpproxy_configure();
129
			break;
130
		case 'miniupnpd':
131
			upnp_action('start');
132
			break;
133
		case 'racoon':
134
			vpn_ipsec_force_reload();
135
			break;
136
		case 'openvpn':
137
			$vpnmode = $_GET['vpnmode'];
138
			if (($vpnmode == "server") || ($vpnmode == "client")) {
139
				$id = $_GET['id'];
140
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
141
				if (file_exists($configfile))
142
					mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
143
			}
144
			break;
145
		case 'relayd':
146
			relayd_configure();
147
			break;
148
		default:
149
			start_service($_GET['service']);
150
			break;
151
	}
152
	$savemsg = sprintf(gettext("%s has been started."),htmlspecialchars($_GET['service']));
153
	sleep(5);
154
}
155

    
156
/* stop service */
157
if($_GET['mode'] == "stopservice" && !empty($_GET['service'])) {
158
	switch($_GET['service']) {
159
		case 'radvd':
160
			killbypid("{$g['varrun_path']}/radvd.pid");
161
			break;
162
		case 'captiveportal':
163
			$zone = $_GET['zone'];
164
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
165
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
166
			break;
167
		case 'ntpd':
168
			killbyname("ntpd");
169
			break;		
170
		case 'openntpd':
171
			killbyname("openntpd");
172
			break;
173
		case 'bsnmpd':
174
			killbypid("{$g['varrun_path']}/snmpd.pid");
175
			break;
176
		case 'choparp':
177
			killbyname("choparp");
178
			break;
179
		case 'dhcpd':
180
			killbyname("dhcpd");
181
			break;
182
		case 'dhcrelay':
183
			killbypid("{$g['varrun_path']}/dhcrelay.pid");
184
			break;
185
		case 'dnsmasq':
186
			killbypid("{$g['varrun_path']}/dnsmasq.pid");
187
			break;
188
		case 'igmpproxy':
189
			killbyname("igmpproxy");
190
			break;
191
		case 'miniupnpd':
192
			upnp_action('stop');
193
			break;
194
		case 'sshd':
195
			killbyname("sshd");
196
			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
				$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid";
205
				killbypid($pidfile);
206
			}
207
			break;
208
		case 'relayd':
209
			mwexec('pkill relayd');
210
			break;
211
		default:
212
			stop_service($_GET['service']);
213
			break;
214
	}
215
	$savemsg = sprintf(gettext("%s has been stopped."), htmlspecialchars($_GET['service']));
216
	sleep(5);
217
}
218

    
219
/* batch mode, allow other scripts to call this script */
220
if($_GET['batch'])
221
	exit;
222

    
223
$pgtitle = array(gettext("Status"),gettext("Services"));
224
include("head.inc");
225

    
226
?>
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
<div id="boxarea">
238
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
239
	<thead>
240
	<tr>
241
		<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
	</tr>
245
	</thead>
246
	<tbody>
247
<?php
248

    
249
$services = get_services();
250

    
251
if (count($services) > 0) {
252
	uasort($services, "service_name_compare");
253
	foreach($services as $service) {
254
		if (empty($service['name']))
255
			continue;
256
		if (empty($service['description']))
257
			$service['description'] = get_pkg_descr($service['name']);
258
		echo '<tr><td class="listlr" width="20%">' . $service['name'] . '</td>' . "\n";
259
		echo '<td class="listr" width="55%">' . $service['description'] . '</td>' . "\n";
260
		echo get_service_status_icon($service, true, true);
261
		echo '<td valign="middle" class="list" nowrap>';
262
		echo get_service_control_links($service);
263
		$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
		echo "</td></tr>\n";
270
	}
271
} else {
272
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . ".</td></tr>\n";
273
}
274

    
275
?>
276
</tbody>
277
</table>
278
</div>
279
</p>
280
</form>
281
<?php include("fend.inc"); ?>
282
</body>
283
</html>
(195-195/249)