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
1942d1f0
Commit
1942d1f0
authored
Feb 20, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: migrate service start commands to array
(cherry picked from commit
60f0f461
)
parent
ebf076e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
63 deletions
+40
-63
services.inc
src/etc/inc/services.inc
+30
-2
status_services.php
src/www/status_services.php
+10
-61
No files found.
src/etc/inc/services.inc
View file @
1942d1f0
...
@@ -2555,6 +2555,7 @@ function services_get()
...
@@ -2555,6 +2555,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"radvd"
;
$pconfig
[
'name'
]
=
"radvd"
;
$pconfig
[
'description'
]
=
gettext
(
"Router Advertisement Daemon"
);
$pconfig
[
'description'
]
=
gettext
(
"Router Advertisement Daemon"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_radvd_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2562,6 +2563,7 @@ function services_get()
...
@@ -2562,6 +2563,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dnsmasq"
;
$pconfig
[
'name'
]
=
"dnsmasq"
;
$pconfig
[
'description'
]
=
gettext
(
"DNS Forwarder"
);
$pconfig
[
'description'
]
=
gettext
(
"DNS Forwarder"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dnsmasq_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2569,12 +2571,14 @@ function services_get()
...
@@ -2569,12 +2571,14 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"unbound"
;
$pconfig
[
'name'
]
=
"unbound"
;
$pconfig
[
'description'
]
=
gettext
(
"Unbound DNS Resolver"
);
$pconfig
[
'description'
]
=
gettext
(
"Unbound DNS Resolver"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_unbound_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"ntpd"
;
$pconfig
[
'name'
]
=
"ntpd"
;
$pconfig
[
'description'
]
=
gettext
(
"NTP clock sync"
);
$pconfig
[
'description'
]
=
gettext
(
"NTP clock sync"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'system_ntp_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/ntpd.pid'
;
$pconfig
[
'pidfile'
]
=
'/var/run/ntpd.pid'
;
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
...
@@ -2591,6 +2595,7 @@ function services_get()
...
@@ -2591,6 +2595,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dhcrelay"
;
$pconfig
[
'name'
]
=
"dhcrelay"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCP Relay"
);
$pconfig
[
'description'
]
=
gettext
(
"DHCP Relay"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcrelay_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2599,6 +2604,7 @@ function services_get()
...
@@ -2599,6 +2604,7 @@ function services_get()
$pconfig
[
'name'
]
=
"dhcrelay6"
;
$pconfig
[
'name'
]
=
"dhcrelay6"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCPv6 Relay"
);
$pconfig
[
'description'
]
=
gettext
(
"DHCPv6 Relay"
);
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay6.pid'
;
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay6.pid'
;
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcrelay6_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2606,6 +2612,7 @@ function services_get()
...
@@ -2606,6 +2612,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dhcpd"
;
$pconfig
[
'name'
]
=
"dhcpd"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCP Service"
);
$pconfig
[
'description'
]
=
gettext
(
"DHCP Service"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcpd_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2621,6 +2628,7 @@ function services_get()
...
@@ -2621,6 +2628,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"bsnmpd"
;
$pconfig
[
'name'
]
=
"bsnmpd"
;
$pconfig
[
'description'
]
=
gettext
(
"SNMP Service"
);
$pconfig
[
'description'
]
=
gettext
(
"SNMP Service"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_snmpd_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2628,6 +2636,7 @@ function services_get()
...
@@ -2628,6 +2636,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"igmpproxy"
;
$pconfig
[
'name'
]
=
"igmpproxy"
;
$pconfig
[
'description'
]
=
gettext
(
"IGMP proxy"
);
$pconfig
[
'description'
]
=
gettext
(
"IGMP proxy"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_igmpproxy_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2643,6 +2652,7 @@ function services_get()
...
@@ -2643,6 +2652,7 @@ function services_get()
$pconfig
[
'name'
]
=
"ipsec"
;
$pconfig
[
'name'
]
=
"ipsec"
;
$pconfig
[
'description'
]
=
gettext
(
"IPsec VPN"
);
$pconfig
[
'description'
]
=
gettext
(
"IPsec VPN"
);
$pconfig
[
'pidfile'
]
=
'/var/run/charon.pid'
;
$pconfig
[
'pidfile'
]
=
'/var/run/charon.pid'
;
$pconfig
[
'php'
][
'start'
]
=
array
(
'vpn_ipsec_force_reload'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
...
@@ -2675,15 +2685,30 @@ function services_get()
...
@@ -2675,15 +2685,30 @@ function services_get()
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"relayd"
;
$pconfig
[
'name'
]
=
"relayd"
;
$pconfig
[
'description'
]
=
gettext
(
"Server load balancing daemon"
);
$pconfig
[
'description'
]
=
gettext
(
"Server load balancing daemon"
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'relayd_configure'
,
'filter_configure'
);
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
if
(
isset
(
$config
[
'OPNsense'
][
'proxy'
][
'general'
][
'enabled'
])
&&
$config
[
'OPNsense'
][
'proxy'
][
'general'
][
'enabled'
]
==
1
)
{
if
(
isset
(
$config
[
'OPNsense'
][
'proxy'
][
'general'
][
'enabled'
])
&&
$config
[
'OPNsense'
][
'proxy'
][
'general'
][
'enabled'
]
==
1
)
{
$services
[]
=
array
(
'name'
=>
'squid'
,
'description'
=>
gettext
(
"Proxy server"
));
$services
[]
=
array
(
'description'
=>
gettext
(
'Proxy server'
),
'configd'
=>
array
(
'start'
=>
array
(
'proxy start'
),
),
'name'
=>
'squid'
,
);
}
}
if
(
isset
(
$config
[
'OPNsense'
][
'IDS'
][
'general'
][
'enabled'
])
&&
$config
[
'OPNsense'
][
'IDS'
][
'general'
][
'enabled'
]
==
1
)
{
if
(
isset
(
$config
[
'OPNsense'
][
'IDS'
][
'general'
][
'enabled'
])
&&
$config
[
'OPNsense'
][
'IDS'
][
'general'
][
'enabled'
]
==
1
)
{
$services
[]
=
array
(
'name'
=>
'suricata'
,
'description'
=>
gettext
(
"Intrusion Detection"
));
$services
[]
=
array
(
'description'
=>
gettext
(
'Intrusion Detection'
),
'configd'
=>
array
(
'start'
=>
array
(
'ids start'
),
),
'name'
=>
'suricata'
,
);
}
}
if
(
isset
(
$config
[
'OPNsense'
][
'captiveportal'
][
'zones'
][
'zone'
]))
{
if
(
isset
(
$config
[
'OPNsense'
][
'captiveportal'
][
'zones'
][
'zone'
]))
{
$enabled
=
false
;
$enabled
=
false
;
if
(
!
empty
(
$config
[
'OPNsense'
][
'captiveportal'
][
'zones'
][
'zone'
][
'enabled'
]))
{
if
(
!
empty
(
$config
[
'OPNsense'
][
'captiveportal'
][
'zones'
][
'zone'
][
'enabled'
]))
{
...
@@ -2701,6 +2726,9 @@ function services_get()
...
@@ -2701,6 +2726,9 @@ 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'
),
'confidg'
=>
array
(
'start'
=>
array
(
'captiveportal start'
),
),
'name'
=>
'captiveportal'
,
'name'
=>
'captiveportal'
,
);
);
}
}
...
...
src/www/status_services.php
View file @
1942d1f0
...
@@ -71,6 +71,8 @@ if (!empty($_GET['service'])) {
...
@@ -71,6 +71,8 @@ if (!empty($_GET['service'])) {
function
service_control_start
(
$name
,
$extras
)
function
service_control_start
(
$name
,
$extras
)
{
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
/* XXX openvpn is handled special at the moment */
/* XXX openvpn is handled special at the moment */
if
(
$name
==
'openvpn'
)
{
if
(
$name
==
'openvpn'
)
{
$vpnmode
=
isset
(
$extras
[
'vpnmode'
])
?
htmlspecialchars
(
$extras
[
'vpnmode'
])
:
htmlspecialchars
(
$extras
[
'mode'
]);
$vpnmode
=
isset
(
$extras
[
'vpnmode'
])
?
htmlspecialchars
(
$extras
[
'vpnmode'
])
:
htmlspecialchars
(
$extras
[
'mode'
]);
...
@@ -81,8 +83,11 @@ function service_control_start($name, $extras)
...
@@ -81,8 +83,11 @@ function service_control_start($name, $extras)
openvpn_restart_by_vpnid
(
$vpnmode
,
$id
);
openvpn_restart_by_vpnid
(
$vpnmode
,
$id
);
}
}
}
}
return
$msg
;
return
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
/* XXX extra argument is extra tricky */
}
elseif
(
$name
==
'miniupnpd'
)
{
upnp_action
(
'start'
);
return
$msg
;
}
}
$service
=
find_service_by_name
(
$name
);
$service
=
find_service_by_name
(
$name
);
...
@@ -94,75 +99,19 @@ function service_control_start($name, $extras)
...
@@ -94,75 +99,19 @@ function service_control_start($name, $extras)
foreach
(
$service
[
'configd'
][
'start'
]
as
$cmd
)
{
foreach
(
$service
[
'configd'
][
'start'
]
as
$cmd
)
{
configd_run
(
$cmd
);
configd_run
(
$cmd
);
}
}
/* XXX fall through later */
return
sprintf
(
gettext
(
'%s has been started via configd.'
),
htmlspecialchars
(
$name
));
}
elseif
(
isset
(
$service
[
'php'
][
'start'
]))
{
}
elseif
(
isset
(
$service
[
'php'
][
'start'
]))
{
foreach
(
$service
[
'php'
][
'start'
]
as
$cmd
)
{
foreach
(
$service
[
'php'
][
'start'
]
as
$cmd
)
{
$cmd
();
$cmd
();
}
}
/* XXX fall through later */
return
sprintf
(
gettext
(
'%s has been started via php.'
),
htmlspecialchars
(
$name
));
}
elseif
(
isset
(
$service
[
'mwexec'
][
'start'
]))
{
}
elseif
(
isset
(
$service
[
'mwexec'
][
'start'
]))
{
foreach
(
$service
[
'mwexec'
][
'start'
]
as
$cmd
)
{
foreach
(
$service
[
'mwexec'
][
'start'
]
as
$cmd
)
{
mwexec
(
$cmd
);
mwexec
(
$cmd
);
}
}
/* XXX fall through later */
}
else
{
return
sprintf
(
gettext
(
'%s has been started via mwexec.'
),
htmlspecialchars
(
$name
));
$msg
=
printf
(
gettext
(
"Could not launch service `%s'"
),
htmlspecialchars
(
$name
));
}
/* XXX migrate all of those */
switch
(
$service
[
'name'
])
{
case
'radvd'
:
services_radvd_configure
();
break
;
case
'ntpd'
:
system_ntp_configure
();
break
;
case
'bsnmpd'
:
services_snmpd_configure
();
break
;
case
'dhcrelay'
:
services_dhcrelay_configure
();
break
;
case
'dhcrelay6'
:
services_dhcrelay6_configure
();
break
;
case
'dnsmasq'
:
services_dnsmasq_configure
();
break
;
case
'unbound'
:
services_unbound_configure
();
break
;
case
'dhcpd'
:
services_dhcpd_configure
();
break
;
case
'igmpproxy'
:
services_igmpproxy_configure
();
break
;
case
'miniupnpd'
:
upnp_action
(
'start'
);
break
;
case
'ipsec'
:
vpn_ipsec_force_reload
();
break
;
case
'relayd'
:
relayd_configure
();
filter_configure
();
break
;
case
'squid'
:
configd_run
(
"proxy start"
);
break
;
case
'suricata'
:
configd_run
(
"ids start"
);
break
;
case
'captiveportal'
:
configd_run
(
"captiveportal start"
);
break
;
default
:
return
sprintf
(
gettext
(
"Could not launch service `%s'"
),
htmlspecialchars
(
$name
));
}
}
return
sprintf
(
gettext
(
'%s has been started.'
),
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