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
7d568ea2
Commit
7d568ea2
authored
May 17, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
May 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move legacy service start/stop/restart to services.inc
(cherry picked from commit
f759d902
)
parent
01131493
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
110 deletions
+111
-110
services.inc
src/etc/inc/services.inc
+111
-0
status_services.php
src/www/status_services.php
+0
-110
No files found.
src/etc/inc/services.inc
View file @
7d568ea2
...
@@ -2924,3 +2924,114 @@ function is_radvd_enabled() {
...
@@ -2924,3 +2924,114 @@ function is_radvd_enabled() {
return
false
;
return
false
;
}
}
function
service_control_start
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not start unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
if
(
isset
(
$service
[
'configd'
][
'start'
]))
{
foreach
(
$service
[
'configd'
][
'start'
]
as
$cmd
)
{
configd_run
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'php'
][
'start'
]))
{
foreach
(
$service
[
'php'
][
'start'
]
as
$cmd
)
{
$params
=
array
();
if
(
isset
(
$service
[
'php'
][
'args'
]))
{
foreach
(
$service
[
'php'
][
'args'
]
as
$param
)
{
$params
[]
=
$service
[
$param
];
}
}
call_user_func_array
(
$cmd
,
$params
);
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'start'
]))
{
foreach
(
$service
[
'mwexec'
][
'start'
]
as
$cmd
)
{
mwexec
(
$cmd
);
}
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not start service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
}
function
service_control_stop
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$filter
=
array
();
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not stop unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
if
(
isset
(
$service
[
'configd'
][
'stop'
]))
{
foreach
(
$service
[
'configd'
][
'stop'
]
as
$cmd
)
{
configd_run
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'php'
][
'stop'
]))
{
foreach
(
$service
[
'php'
][
'stop'
]
as
$cmd
)
{
$cmd
();
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'stop'
]))
{
foreach
(
$service
[
'mwexec'
][
'stop'
]
as
$cmd
)
{
mwexec
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'pidfile'
]))
{
killbypid
(
$service
[
'pidfile'
],
'TERM'
,
true
);
}
else
{
/* last resort, but not very elegant */
killbyname
(
$service
[
'name'
]);
}
return
$msg
;
}
function
service_control_restart
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not restart unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
if
(
isset
(
$service
[
'configd'
][
'restart'
]))
{
foreach
(
$service
[
'configd'
][
'restart'
]
as
$cmd
)
{
configd_run
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'php'
][
'restart'
]))
{
foreach
(
$service
[
'php'
][
'restart'
]
as
$cmd
)
{
$params
=
array
();
if
(
isset
(
$service
[
'php'
][
'args'
]))
{
foreach
(
$service
[
'php'
][
'args'
]
as
$param
)
{
$params
[]
=
$service
[
$param
];
}
}
call_user_func_array
(
$cmd
,
$params
);
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'restart'
]))
{
foreach
(
$service
[
'mwexec'
][
'restart'
]
as
$cmd
)
{
mwexec
(
$cmd
);
}
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not restart service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
}
src/www/status_services.php
View file @
7d568ea2
...
@@ -57,116 +57,6 @@ if (!empty($_POST['service'])) {
...
@@ -57,116 +57,6 @@ if (!empty($_POST['service'])) {
exit
;
exit
;
}
}
function
service_control_start
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not start unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
if
(
isset
(
$service
[
'configd'
][
'start'
]))
{
foreach
(
$service
[
'configd'
][
'start'
]
as
$cmd
)
{
configd_run
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'php'
][
'start'
]))
{
foreach
(
$service
[
'php'
][
'start'
]
as
$cmd
)
{
$params
=
array
();
if
(
isset
(
$service
[
'php'
][
'args'
]))
{
foreach
(
$service
[
'php'
][
'args'
]
as
$param
)
{
$params
[]
=
$service
[
$param
];
}
}
call_user_func_array
(
$cmd
,
$params
);
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'start'
]))
{
foreach
(
$service
[
'mwexec'
][
'start'
]
as
$cmd
)
{
mwexec
(
$cmd
);
}
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not start service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
}
function
service_control_stop
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$filter
=
array
();
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not stop unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
if
(
isset
(
$service
[
'configd'
][
'stop'
]))
{
foreach
(
$service
[
'configd'
][
'stop'
]
as
$cmd
)
{
configd_run
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'php'
][
'stop'
]))
{
foreach
(
$service
[
'php'
][
'stop'
]
as
$cmd
)
{
$cmd
();
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'stop'
]))
{
foreach
(
$service
[
'mwexec'
][
'stop'
]
as
$cmd
)
{
mwexec
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'pidfile'
]))
{
killbypid
(
$service
[
'pidfile'
],
'TERM'
,
true
);
}
else
{
/* last resort, but not very elegant */
killbyname
(
$service
[
'name'
]);
}
return
$msg
;
}
function
service_control_restart
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not restart unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
if
(
isset
(
$service
[
'configd'
][
'restart'
]))
{
foreach
(
$service
[
'configd'
][
'restart'
]
as
$cmd
)
{
configd_run
(
$cmd
);
}
}
elseif
(
isset
(
$service
[
'php'
][
'restart'
]))
{
foreach
(
$service
[
'php'
][
'restart'
]
as
$cmd
)
{
$params
=
array
();
if
(
isset
(
$service
[
'php'
][
'args'
]))
{
foreach
(
$service
[
'php'
][
'args'
]
as
$param
)
{
$params
[]
=
$service
[
$param
];
}
}
call_user_func_array
(
$cmd
,
$params
);
}
}
elseif
(
isset
(
$service
[
'mwexec'
][
'restart'
]))
{
foreach
(
$service
[
'mwexec'
][
'restart'
]
as
$cmd
)
{
mwexec
(
$cmd
);
}
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not restart service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
}
$services
=
services_get
();
$services
=
services_get
();
...
...
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