Project

General

Profile

Download (3.83 KB) Statistics
| Branch: | Tag: | Revision:
1 a0e4cea2 Scott Ullrich
<?php
2
/*
3 c5d81585 Renato Botelho
 * status_services.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
7
 * All rights reserved.
8
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 c5d81585 Renato Botelho
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 c5d81585 Renato Botelho
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 74b0f23e Stephen Beaver
 */
21 a0e4cea2 Scott Ullrich
22 6b07c15a Matthew Grooms
##|+PRIV
23
##|*IDENT=page-status-services
24 5230f468 jim-p
##|*NAME=Status: Services
25 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Status: Services' page.
26
##|*MATCH=status_services.php*
27
##|-PRIV
28
29 e3c88b77 Ermal
require_once("guiconfig.inc");
30 44173def Ermal Lu?i
require_once("service-utils.inc");
31 a517a108 jmkizer
require_once("shortcuts.inc");
32 a0e4cea2 Scott Ullrich
33 29fda3d3 Stephen Beaver
if ($_REQUEST['ajax']) {
34
	if (isset($_REQUEST['service'])) {
35
		$service_name = htmlspecialchars($_REQUEST['service']);
36 8b88ac79 jim-p
	}
37 517d3109 sbeaver
38 29fda3d3 Stephen Beaver
	if (!empty($service_name)) {
39
		switch ($_REQUEST['mode']) {
40
			case "restartservice":
41
				$savemsg = service_control_restart($service_name, $_REQUEST);
42
				break;
43
			case "startservice":
44
				$savemsg = service_control_start($service_name, $_REQUEST);
45
				break;
46
			case "stopservice":
47
				$savemsg = service_control_stop($service_name, $_REQUEST);
48
				break;
49
		}
50
		sleep(5);
51
	}
52 74b0f23e Stephen Beaver
53 246a887a Ermal
	exit;
54 42b0c921 Phil Davis
}
55 b9eadc0c Colin Smith
56 6c07db48 Phil Davis
$pgtitle = array(gettext("Status"), gettext("Services"));
57 4df96eff Scott Ullrich
include("head.inc");
58
59 abe98adb Phil Davis
if ($savemsg) {
60 517d3109 sbeaver
	print_info_box($savemsg, 'success');
61 abe98adb Phil Davis
}
62 a0e4cea2 Scott Ullrich
63 517d3109 sbeaver
$services = get_services();
64
65 74b0f23e Stephen Beaver
// $debugsvcs = array('name' => 'captiveportal', 'description' => 'Captive Portal', 'zone' => '14');
66
// array_push($services, $debugsvcs);
67
68 517d3109 sbeaver
if (count($services) > 0) {
69 a0e4cea2 Scott Ullrich
?>
70
<form action="status_services.php" method="post">
71 74b0f23e Stephen Beaver
	<input id="mode" type="hidden" name="mode" value=""/>
72
	<input id="vpnmode" type="hidden" name="vpnmode" value=""/>
73
	<input id="service" type="hidden" name="service" value=""/>
74
	<input id="id" type="hidden" name="id" value=""/>
75
	<input id="zone" type="hidden" name="zone" value=""/>
76
77 ac950976 Colin Fleming
<div class="panel panel-default">
78
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Services')?></h2></div>
79
	<div class="panel-body">
80
81 517d3109 sbeaver
	<div class="panel-body panel-default">
82
		<div class="table-responsive">
83 10fe1eb5 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
84 517d3109 sbeaver
				<thead>
85
					<tr>
86
						<th><?=gettext("Service")?></th>
87
						<th><?=gettext("Description")?></th>
88
						<th><?=gettext("Status")?></th>
89
						<th><?=gettext("Actions")?></th>
90
					</tr>
91
				</thead>
92
				<tbody>
93 a0e4cea2 Scott Ullrich
<?php
94
95 b2254c7f jim-p
	uasort($services, "service_name_compare");
96 517d3109 sbeaver
97 ab7e04c7 Colin Fleming
	foreach ($services as $service) {
98
		if (empty($service['name'])) {
99 246a887a Ermal
			continue;
100 ab7e04c7 Colin Fleming
		}
101 517d3109 sbeaver
102 74b0f23e Stephen Beaver
		if (empty($service['description'])) {
103 246a887a Ermal
			$service['description'] = get_pkg_descr($service['name']);
104 74b0f23e Stephen Beaver
		}
105 517d3109 sbeaver
?>
106
					<tr>
107
						<td>
108
							<?=$service['name']?>
109
						</td>
110
111
						<td>
112
							<?=$service['description']?>
113
						</td>
114
<?php
115 17b8c60a Colin Fleming
		// if service is running then listr else listbg
116
		$bgclass = null;
117 517d3109 sbeaver
		$running = false;
118
119 74b0f23e Stephen Beaver
		if (get_service_status($service)) {
120 517d3109 sbeaver
			$running = true;
121 74b0f23e Stephen Beaver
		}
122 517d3109 sbeaver
?>
123
						<td>
124 c805b6e4 Renato Botelho
							<?=$running ? '<span class="text-success">' . gettext("Running") . '</span>':'<span class="text-danger">' . gettext("Stopped") . '</span>'?>
125 517d3109 sbeaver
						</td>
126
						<td>
127
							<?=get_service_control_links($service)?>
128
129
<?php
130 391abfcf jim-p
		$scut = get_shortcut_by_service_name($service['name']);
131 517d3109 sbeaver
132 391abfcf jim-p
		if (!empty($scut)) {
133
			echo get_shortcut_main_link($scut, true, $service);
134
			echo get_shortcut_status_link($scut, true, $service);
135
			echo get_shortcut_log_link($scut, true);
136
		}
137 517d3109 sbeaver
?>
138
						</td>
139
					</tr>
140
<?php
141 a0e4cea2 Scott Ullrich
	}
142 517d3109 sbeaver
?>
143
				</tbody>
144
			</table>
145
		</div>
146
	</div>
147 ac950976 Colin Fleming
148
	</div>
149
</div>
150
151 517d3109 sbeaver
</form>
152
<?php
153 b9eadc0c Colin Smith
} else {
154 8545adde k-paulius
	print_info_box(gettext("No services found."), 'danger');
155 b9eadc0c Colin Smith
}
156 74b0f23e Stephen Beaver
157
include("foot.inc");