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
9784c8b0
Commit
9784c8b0
authored
Feb 21, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: restructure restart, work in progress
parent
f90e96f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
56 deletions
+48
-56
services.inc
src/etc/inc/services.inc
+16
-0
status_services.php
src/www/status_services.php
+32
-56
No files found.
src/etc/inc/services.inc
View file @
9784c8b0
...
...
@@ -2511,6 +2511,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"radvd"
;
$pconfig
[
'description'
]
=
gettext
(
"Router Advertisement Daemon"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_radvd_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_radvd_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/radvd.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2520,6 +2521,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dnsmasq"
;
$pconfig
[
'description'
]
=
gettext
(
"DNS Forwarder"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_dnsmasq_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dnsmasq_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/dnsmasq.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2529,6 +2531,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"unbound"
;
$pconfig
[
'description'
]
=
gettext
(
"Unbound DNS Resolver"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_unbound_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_unbound_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/unbound.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2537,6 +2540,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"ntpd"
;
$pconfig
[
'description'
]
=
gettext
(
"NTP clock sync"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'system_ntp_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'system_ntp_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/ntpd.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2554,6 +2558,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dhcrelay"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCP Relay"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_dhcrelay_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcrelay_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2563,6 +2568,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dhcrelay6"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCPv6 Relay"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_dhcrelay6_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcrelay6_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/dhcrelay6.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2572,6 +2578,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"dhcpd"
;
$pconfig
[
'description'
]
=
gettext
(
"DHCP Service"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_dhcpd_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_dhcpd_configure'
);
$pconfig
[
'pidfile'
]
=
"
{
$g
[
'dhcpd_chroot_path'
]
}
/var/run/dhcpd.pid"
;
$services
[]
=
$pconfig
;
...
...
@@ -2590,6 +2597,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"bsnmpd"
;
$pconfig
[
'description'
]
=
gettext
(
"SNMP Service"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_snmpd_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_snmpd_configure'
);
$pconfig
[
'pidfile'
]
=
'/var/run/snmpd.pid'
;
$services
[]
=
$pconfig
;
...
...
@@ -2599,6 +2607,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"igmpproxy"
;
$pconfig
[
'description'
]
=
gettext
(
"IGMP proxy"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'services_igmpproxy_configure'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'services_igmpproxy_configure'
);
$services
[]
=
$pconfig
;
}
...
...
@@ -2620,6 +2629,7 @@ function services_get()
$pconfig
[
'name'
]
=
"ipsec"
;
$pconfig
[
'description'
]
=
gettext
(
"IPsec VPN"
);
$pconfig
[
'pidfile'
]
=
'/var/run/charon.pid'
;
$pconfig
[
'php'
][
'restart'
]
=
array
(
'vpn_ipsec_force_reload'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'vpn_ipsec_force_reload'
);
$pconfig
[
'mwexec'
][
'stop'
]
=
array
(
'/usr/local/sbin/ipsec stop'
);
$services
[]
=
$pconfig
;
...
...
@@ -2629,6 +2639,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
'sshd'
;
$pconfig
[
'description'
]
=
gettext
(
'Secure Shell Daemon'
);
$pconfig
[
'configd'
][
'restart'
]
=
array
(
'sshd restart'
);
$pconfig
[
'configd'
][
'start'
]
=
array
(
'sshd restart'
);
$services
[]
=
$pconfig
;
}
...
...
@@ -2662,6 +2673,7 @@ function services_get()
$services
[]
=
array
(
'description'
=>
gettext
(
'Proxy server'
),
'configd'
=>
array
(
'restart'
=>
array
(
'proxy restart'
),
'start'
=>
array
(
'proxy start'
),
'stop'
=>
array
(
'proxy stop'
),
),
...
...
@@ -2673,6 +2685,7 @@ function services_get()
$services
[]
=
array
(
'description'
=>
gettext
(
'Intrusion Detection'
),
'configd'
=>
array
(
'restart'
=>
array
(
'ids restart'
),
'start'
=>
array
(
'ids start'
),
'stop'
=>
array
(
'ids stop'
),
),
...
...
@@ -2698,6 +2711,7 @@ function services_get()
'pidfile'
=>
'/var/run/lighttpd-api-dispatcher.pid'
,
'description'
=>
gettext
(
'Captive Portal'
),
'confidg'
=>
array
(
'restart'
=>
array
(
'captiveportal restart'
),
'start'
=>
array
(
'captiveportal start'
),
'stop'
=>
array
(
'captiveportal stop'
),
),
...
...
@@ -2710,7 +2724,9 @@ function services_get()
'description'
=>
gettext
(
'System Configuration Daemon'
),
'pidfile'
=>
'/var/run/configd.pid'
,
'mwexec'
=>
array
(
'restart'
=>
array
(
'/usr/local/etc/rc.d/configd restart'
),
'start'
=>
array
(
'/usr/local/etc/rc.d/configd start'
),
'stop'
=>
array
(
'/usr/local/etc/rc.d/configd stop'
),
),
'name'
=>
'configd'
,
);
...
...
src/www/status_services.php
View file @
9784c8b0
...
...
@@ -104,7 +104,7 @@ function service_control_start($name, $extras)
mwexec
(
$cmd
);
}
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not
launch
service `%s'"
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
"Could not
start
service `%s'"
),
htmlspecialchars
(
$name
));
}
return
$msg
;
...
...
@@ -148,49 +148,16 @@ function service_control_stop($name, $extras)
}
function
service_control_restart
(
$name
,
$extras
)
{
function
service_control_restart
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
/* XXX clean this up */
switch
(
$name
)
{
case
'radvd'
:
services_radvd_configure
();
break
;
case
'ntpd'
:
system_ntp_configure
();
break
;
case
'apinger'
:
killbypid
(
"/var/run/apinger.pid"
);
setup_gateways_monitor
();
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_stop
();
upnp_start
();
break
;
case
'ipsec'
:
vpn_ipsec_force_reload
();
break
;
case
'sshd'
:
configd_run
(
"sshd restart"
);
break
;
return
$msg
;
case
'openvpn'
:
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
if
(
$vpnmode
==
"server"
||
$vpnmode
==
"client"
)
{
...
...
@@ -200,28 +167,37 @@ function service_control_restart($name, $extras) {
openvpn_restart_by_vpnid
(
$vpnmode
,
$id
);
}
}
break
;
return
$msg
;
case
'relayd'
:
relayd_configure
(
true
);
filter_configure
();
break
;
case
'squid'
:
configd_run
(
"proxy restart"
);
break
;
case
'suricata'
:
configd_run
(
"ids restart"
);
break
;
case
'configd'
:
mwexec
(
'/usr/local/etc/rc.d/configd restart'
);
break
;
case
'captiveportal'
:
configd_run
(
"captiveportal restart"
);
break
;
return
$msg
;
default
:
log_error
(
sprintf
(
gettext
(
"Could not restart unknown service `%s'"
),
$name
));
break
;
}
return
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
$service
=
find_service_by_name
(
$name
);
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
)
{
$cmd
();
}
}
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
();
...
...
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