Project

General

Profile

Download (7.62 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

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

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

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

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

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

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

    
248
$services = get_services();
249

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

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