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
de888244
Commit
de888244
authored
Feb 20, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: adapt stop commands to new approach
parent
60f0f461
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
58 deletions
+49
-58
services.inc
src/etc/inc/services.inc
+13
-2
status_services.php
src/www/status_services.php
+36
-56
No files found.
src/etc/inc/services.inc
View file @
de888244
...
...
@@ -2540,7 +2540,7 @@ function is_apinger_enabled()
function
services_get
()
{
global
$config
;
global
$config
,
$g
;
$services
=
array
();
...
...
@@ -2549,6 +2549,7 @@ function services_get()
$pconfig
[
'name'
]
=
"radvd"
;
$pconfig
[
'description'
]
=
gettext
(
"Router Advertisement Daemon"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_radvd_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/radvd.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2557,6 +2558,7 @@ function services_get()
$pconfig
[
'name'
]
=
"dnsmasq"
;
$pconfig
[
'description'
]
=
gettext
(
"DNS Forwarder"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dnsmasq_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/dnsmasq.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2565,6 +2567,7 @@ function services_get()
$pconfig
[
'name'
]
=
"unbound"
;
$pconfig
[
'description'
]
=
gettext
(
"Unbound DNS Resolver"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_unbound_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/unbound.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2589,6 +2592,7 @@ function services_get()
$pconfig
[
'name'
]
=
"dhcrelay"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCP Relay"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcrelay_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2596,8 +2600,8 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dhcrelay6"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCPv6 Relay"
);
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay6.pid'
;
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcrelay6_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay6.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2606,6 +2610,7 @@ function services_get()
$pconfig
[
'name'
]
=
"dhcpd"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCP Service"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcpd_configure'
);
$pconfig
[
'pidfile'
]
=
"
{
$g
[
'dhcpd_chroot_path'
]
}
/var/run/dhcpd.pid"
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2614,6 +2619,7 @@ function services_get()
$pconfig
[
'name'
]
=
"apinger"
;
$pconfig
[
'description'
]
=
gettext
(
"Gateway Monitoring Daemon"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'setup_gateways_monitor'
);
$pconfig
[
'pidfile'
]
=
'/var/run/apinger.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2622,6 +2628,7 @@ function services_get()
$pconfig
[
'name'
]
=
"bsnmpd"
;
$pconfig
[
'description'
]
=
gettext
(
"SNMP Service"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_snmpd_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/snmpd.pid'
;
$services
[]
=
$pconfig
;
}
...
...
@@ -2646,6 +2653,7 @@ function services_get()
$pconfig
[
'description'
]
=
gettext
(
"IPsec VPN"
);
$pconfig
[
'pidfile'
]
=
'/var/run/charon.pid'
;
$pconfig
[
'php'
][
'start'
]
=
array
(
'vpn_ipsec_force_reload'
);
$pconfig
[
'mwexec'
][
'stop'
]
=
array
(
'/usr/local/sbin/ipsec stop'
);
$services
[]
=
$pconfig
;
}
...
...
@@ -2687,6 +2695,7 @@ function services_get()
'description'
=>
gettext
(
'Proxy server'
),
'configd'
=>
array
(
'start'
=>
array
(
'proxy start'
),
'stop'
=>
array
(
'proxy stop'
),
),
'name'
=>
'squid'
,
);
...
...
@@ -2697,6 +2706,7 @@ function services_get()
'description'
=>
gettext
(
'Intrusion Detection'
),
'configd'
=>
array
(
'start'
=>
array
(
'ids start'
),
'stop'
=>
array
(
'ids stop'
),
),
'name'
=>
'suricata'
,
);
...
...
@@ -2721,6 +2731,7 @@ function services_get()
'description'
=>
gettext
(
'Captive Portal'
),
'confidg'
=>
array
(
'start'
=>
array
(
'captiveportal start'
),
'stop'
=>
array
(
'captiveportal stop'
),
),
'name'
=>
'captiveportal'
,
);
...
...
src/www/status_services.php
View file @
de888244
...
...
@@ -108,57 +108,26 @@ function service_control_start($name, $extras)
mwexec
(
$cmd
);
}
}
else
{
$msg
=
printf
(
gettext
(
"Could not launch service `%s'"
),
htmlspecialchars
(
$name
));
$msg
=
s
printf
(
gettext
(
"Could not launch service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
}
function
service_control_stop
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
function
service_control_stop
(
$name
,
$extras
)
{
switch
(
$name
)
{
case
'radvd'
:
killbypid
(
"/var/run/radvd.pid"
);
break
;
case
'ntpd'
:
killbyname
(
"ntpd"
);
break
;
case
'apinger'
:
killbypid
(
"/var/run/apinger.pid"
);
break
;
case
'bsnmpd'
:
killbypid
(
"/var/run/snmpd.pid"
);
break
;
case
'choparp'
:
killbyname
(
"choparp"
);
break
;
case
'dhcpd'
:
killbyname
(
"dhcpd"
);
break
;
case
'dhcrelay'
:
killbypid
(
"/var/run/dhcrelay.pid"
);
break
;
case
'dhcrelay6'
:
killbypid
(
"/var/run/dhcrelay6.pid"
);
break
;
case
'dnsmasq'
:
killbypid
(
"/var/run/dnsmasq.pid"
);
break
;
case
'unbound'
:
killbypid
(
"/var/run/unbound.pid"
);
break
;
switch
(
$name
)
{
case
'igmpproxy'
:
killbyname
(
"igmpproxy"
);
break
;
return
$msg
;
case
'miniupnpd'
:
upnp_action
(
'stop'
);
break
;
return
$msg
;
case
'sshd'
:
killbyname
(
"sshd"
);
break
;
case
'ipsec'
:
exec
(
"/usr/local/sbin/ipsec stop"
);
break
;
return
$msg
;
case
'openvpn'
:
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
if
((
$vpnmode
==
"server"
)
or
(
$vpnmode
==
"client"
))
{
...
...
@@ -166,27 +135,38 @@ function service_control_stop($name, $extras) {
$pidfile
=
"/var/run/openvpn_
{
$vpnmode
}{
$id
}
.pid"
;
killbypid
(
$pidfile
);
}
break
;
return
$msg
;
case
'relayd'
:
mwexec
(
'pkill relayd'
);
break
;
case
'squid'
:
configd_run
(
"proxy stop"
);
break
;
case
'suricata'
:
configd_run
(
"ids stop"
);
break
;
case
'configd'
:
killbypid
(
"/var/run/configd.pid"
);
break
;
case
'captiveportal'
:
configd_run
(
"captiveportal stop"
);
break
;
killbyname
(
'relayd'
);
return
$msg
;
default
:
log_error
(
sprintf
(
gettext
(
"Could not stop unknown service `%s'"
),
$name
));
break
;
}
return
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$service
=
find_service_by_name
(
$name
);
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'
]);
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not stop service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
}
...
...
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