Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
cef101f5
Commit
cef101f5
authored
Apr 16, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) rework status_services, optional tag for script, fix typo
parent
f9d6ddc4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
23 deletions
+40
-23
services.inc
src/etc/inc/services.inc
+20
-18
status_services.php
src/www/status_services.php
+20
-5
No files found.
src/etc/inc/services.inc
View file @
cef101f5
...
@@ -2687,7 +2687,7 @@ function services_get()
...
@@ -2687,7 +2687,7 @@ function services_get()
$services
[]
=
array
(
$services
[]
=
array
(
'pidfile'
=>
'/var/run/lighttpd-api-dispatcher.pid'
,
'pidfile'
=>
'/var/run/lighttpd-api-dispatcher.pid'
,
'description'
=>
gettext
(
'Captive Portal'
),
'description'
=>
gettext
(
'Captive Portal'
),
'confi
dg
'
=>
array
(
'confi
gd
'
=>
array
(
'restart'
=>
array
(
'captiveportal restart'
),
'restart'
=>
array
(
'captiveportal restart'
),
'start'
=>
array
(
'captiveportal start'
),
'start'
=>
array
(
'captiveportal start'
),
'stop'
=>
array
(
'captiveportal stop'
),
'stop'
=>
array
(
'captiveportal stop'
),
...
@@ -2782,26 +2782,28 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
...
@@ -2782,26 +2782,28 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
return
$output
;
return
$output
;
}
}
function
get_service_control_links
(
$service
,
$addname
=
false
)
function
get_service_control_links
(
$service
,
$addname
=
false
,
$add_script
=
true
)
{
{
$stitle
=
$addname
?
$service
[
'name'
]
.
' '
:
''
;
$stitle
=
$addname
?
$service
[
'name'
]
.
' '
:
''
;
$output
=
"
if
(
$add_script
)
{
<script type='text/javascript'>
$output
=
"
$( document ).ready(function() {
<script type='text/javascript'>
$('.srv_status_act').click(function(event){
$( document ).ready(function() {
event.preventDefault();
$('.srv_status_act').click(function(event){
params = {};
event.preventDefault();
params['action'] = $(this).data('service_action');
params = {};
params['service'] = $(this).data('service');
params['action'] = $(this).data('service_action');
params['id'] = $(this).data('service_id');
params['service'] = $(this).data('service');
$.post('/status_services.php',params, function(data) {
params['id'] = $(this).data('service_id');
// refresh page after service action
$.post('/status_services.php',params, function(data) {
location.reload();
// refresh page after service action
});
//location.reload();
});
});
});
});
});
</script>
</script>
"
;
"
;
}
if
(
get_service_status
(
$service
))
{
if
(
get_service_status
(
$service
))
{
if
(
isset
(
$service
[
'id'
]))
{
if
(
isset
(
$service
[
'id'
]))
{
...
...
src/www/status_services.php
View file @
cef101f5
...
@@ -45,13 +45,13 @@ if (!empty($_POST['service'])) {
...
@@ -45,13 +45,13 @@ if (!empty($_POST['service'])) {
$service_name
=
$_POST
[
'service'
];
$service_name
=
$_POST
[
'service'
];
switch
(
$_POST
[
'action'
])
{
switch
(
$_POST
[
'action'
])
{
case
'restart'
:
case
'restart'
:
service_control_restart
(
$service_name
,
$_POST
);
echo
service_control_restart
(
$service_name
,
$_POST
);
break
;
break
;
case
'start'
:
case
'start'
:
service_control_start
(
$service_name
,
$_POST
);
echo
service_control_start
(
$service_name
,
$_POST
);
break
;
break
;
case
'stop'
:
case
'stop'
:
service_control_stop
(
$service_name
,
$_POST
);
echo
service_control_stop
(
$service_name
,
$_POST
);
break
;
break
;
}
}
exit
;
exit
;
...
@@ -69,7 +69,6 @@ function service_control_start($name, $extras)
...
@@ -69,7 +69,6 @@ function service_control_start($name, $extras)
if
(
!
isset
(
$service
[
'name'
]))
{
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not start unknown service `%s'"
),
htmlspecialchars
(
$name
));
return
sprintf
(
gettext
(
"Could not start unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
}
if
(
isset
(
$service
[
'configd'
][
'start'
]))
{
if
(
isset
(
$service
[
'configd'
][
'start'
]))
{
foreach
(
$service
[
'configd'
][
'start'
]
as
$cmd
)
{
foreach
(
$service
[
'configd'
][
'start'
]
as
$cmd
)
{
configd_run
(
$cmd
);
configd_run
(
$cmd
);
...
@@ -180,6 +179,22 @@ include("head.inc");
...
@@ -180,6 +179,22 @@ include("head.inc");
?>
?>
<body>
<body>
<script
type=
'text/javascript'
>
$
(
document
).
ready
(
function
()
{
$
(
'
.srv_status_act
'
).
click
(
function
(
event
){
event
.
preventDefault
();
params
=
{};
params
[
'
action
'
]
=
$
(
this
).
data
(
'
service_action
'
);
params
[
'
service
'
]
=
$
(
this
).
data
(
'
service
'
);
params
[
'
id
'
]
=
$
(
this
).
data
(
'
service_id
'
);
$
.
post
(
'
/status_services.php
'
,
params
,
function
(
data
)
{
// refresh page after service action
location
.
reload
();
});
});
});
</script>
<?php
include
(
"fbegin.inc"
);
?>
<?php
include
(
"fbegin.inc"
);
?>
<section
class=
"page-content-main"
>
<section
class=
"page-content-main"
>
<div
class=
"container-fluid"
>
<div
class=
"container-fluid"
>
...
@@ -205,7 +220,7 @@ include("head.inc");
...
@@ -205,7 +220,7 @@ include("head.inc");
<td>
<?=
$service
[
'description'
];
?>
</td>
<td>
<?=
$service
[
'description'
];
?>
</td>
<td>
<td>
<?=
get_service_status_icon
(
$service
,
true
,
true
);
?>
<?=
get_service_status_icon
(
$service
,
true
,
true
);
?>
<?=
get_service_control_links
(
$service
);
?>
<?=
get_service_control_links
(
$service
,
false
,
false
);
?>
</td>
</td>
</tr>
</tr>
<?php
<?php
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment