Project

General

Profile

Download (7.54 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("openvpn.inc");
44
require_once("ipsec.inc");
45
require_once("vpn.inc");
46
require_once("vslb.inc");
47
require_once("shortcuts.inc");
48

    
49
if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) {
50
	switch($_GET['service']) {
51
		case 'radvd':
52
			services_radvd_configure();
53
			break;
54
		case 'captiveportal':
55
			$zone = $_GET['zone'];
56
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid");
57
			killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid");
58
			captiveportal_init_webgui_zonename($zone);
59
			break;
60
		case 'ntpd':
61
		case 'openntpd':
62
			system_ntp_configure();
63
			break;
64
		case 'bsnmpd':
65
			services_snmpd_configure();
66
			break;
67
		case 'dnsmasq':
68
			services_dnsmasq_configure();
69
			break;
70
		case 'dhcpd':
71
			services_dhcpd_configure();
72
			break;
73
		case 'igmpproxy':
74
			services_igmpproxy_configure();
75
			break;
76
		case 'miniupnpd':
77
			upnp_action('restart');	
78
			break;
79
		case 'racoon':
80
			vpn_ipsec_force_reload();
81
			break;
82
		case 'openvpn':         
83
			$vpnmode = $_GET['vpnmode'];
84
			if ($vpnmode == "server" || $vpnmode == "client") {
85
				$id = $_GET['id'];
86
				$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
87
				if (file_exists($configfile))
88
					openvpn_restart_by_vpnid($vpnmode, $id);
89
			}
90
			break;
91
		case 'relayd':
92
			relayd_configure(true);
93
			break;
94
		default:
95
			restart_service($_GET['service']);
96
			break;
97
	}
98
	$savemsg = sprintf(gettext("%s has been restarted."),htmlspecialchars($_GET['service']));
99
	sleep(5);
100
}
101

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

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

    
216
/* batch mode, allow other scripts to call this script */
217
if($_GET['batch'])
218
	exit;
219

    
220
$pgtitle = array(gettext("Status"),gettext("Services"));
221
include("head.inc");
222

    
223
?>
224

    
225
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
226
<?php
227
include("fbegin.inc");
228
?>
229
<form action="status_services.php" method="post">
230
<?php if ($savemsg) print_info_box($savemsg); ?>
231

    
232
<div id="boxarea">
233
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="status services">
234
	<thead>
235
	<tr>
236
		<td class="listhdrr" align="center"><?=gettext("Service");?></td>
237
		<td class="listhdrr" align="center"><?=gettext("Description");?></td>
238
		<td class="listhdrr" align="center"><?=gettext("Status");?></td>
239
	</tr>
240
	</thead>
241
	<tbody>
242
<?php
243

    
244
$services = get_services();
245

    
246
if (count($services) > 0) {
247
	uasort($services, "service_name_compare");
248
	foreach($services as $service) {
249
		if (empty($service['name']))
250
			continue;
251
		if (empty($service['description']))
252
			$service['description'] = get_pkg_descr($service['name']);
253
		echo '<tr><td class="listlr" width="20%">' . $service['name'] . '</td>' . "\n";
254
		echo '<td class="listr" width="55%">' . $service['description'] . '</td>' . "\n";
255
		echo get_service_status_icon($service, true, true);
256
		echo '<td valign="middle" class="list nowrap">';
257
		echo get_service_control_links($service);
258
		$scut = get_shortcut_by_service_name($service['name']);
259
		if (!empty($scut)) {
260
			echo get_shortcut_main_link($scut, true, $service);
261
			echo get_shortcut_status_link($scut, true, $service);
262
			echo get_shortcut_log_link($scut, true);
263
		}
264
		echo "</td></tr>\n";
265
	}
266
} else {
267
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . ".</td></tr>\n";
268
}
269

    
270
?>
271
</tbody>
272
</table>
273
</div>
274
</form>
275
<?php include("fend.inc"); ?>
276
</body>
277
</html>
(192-192/246)