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
f01b1953
Commit
f01b1953
authored
Mar 15, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: simplify vpn service control and extend for pppoe servers
(cherry picked from commit
2223d5d2
)
parent
333e92f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
45 deletions
+41
-45
vpn.inc
src/etc/inc/plugins.inc.d/vpn.inc
+2
-2
services.inc
src/etc/inc/services.inc
+28
-32
status_services.php
src/www/status_services.php
+11
-11
No files found.
src/etc/inc/plugins.inc.d/vpn.inc
View file @
f01b1953
...
...
@@ -77,10 +77,10 @@ function vpn_services()
'php'
=>
array
(
'restart'
=>
array
(
'vpn_pppoe_configure_by_id'
),
'start'
=>
array
(
'vpn_pppoe_configure_by_id'
),
'args'
=>
array
(
'
pppoe
id'
),
'args'
=>
array
(
'id'
),
),
'pidfile'
=>
"/var/run/pppoe
{
$pppoecfg
[
'pppoeid'
]
}
-vpn.pid"
,
'
pppoe
id'
=>
$pppoecfg
[
'pppoeid'
],
'id'
=>
$pppoecfg
[
'pppoeid'
],
'name'
=>
'pppoed'
,
);
}
...
...
src/etc/inc/services.inc
View file @
f01b1953
...
...
@@ -2627,18 +2627,17 @@ function services_get()
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]))
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]
as
$
id
=>
$
setting
)
{
foreach
(
$config
[
'openvpn'
][
"openvpn-
{
$mode
}
"
]
as
$setting
)
{
if
(
!
isset
(
$setting
[
'disable'
]))
{
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"openvpn"
;
$pconfig
[
'mode'
]
=
$mode
;
$pconfig
[
'id'
]
=
$id
;
$pconfig
[
'vpnid'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'args'
]
=
array
(
'mode'
,
'
vpn
id'
);
$pconfig
[
'php'
][
'args'
]
=
array
(
'mode'
,
'id'
);
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$pconfig
[
'id'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'name'
]
=
'openvpn'
;
$pconfig
[
'mode'
]
=
$mode
;
$services
[]
=
$pconfig
;
}
}
...
...
@@ -2792,38 +2791,35 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
function
get_service_control_links
(
$service
,
$addname
=
false
)
{
$output
=
""
;
$stitle
=
(
$addname
)
?
$service
[
'name'
]
.
" "
:
""
;
$stitle
=
$addname
?
$service
[
'name'
]
.
' '
:
''
;
$output
=
''
;
if
(
get_service_status
(
$service
))
{
switch
(
$service
[
'name'
])
{
case
"openvpn"
:
$output
.=
"<a href='status_services.php?mode=restartservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
break
;
default
:
$output
.=
"<a href='status_services.php?mode=restartservice&service=
{
$service
[
'name'
]
}
' class=
\"
btn btn-default
\"
>"
;
/* restart service button */
$output
.=
"<a href='status_services.php?action=restart&service=
{
$service
[
'name'
]
}
"
;
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
}
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Restart %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-refresh
\"
> </span> </a>
\n
"
;
switch
(
$service
[
'name'
])
{
case
"openvpn"
:
$output
.=
"<a href='status_services.php?mode=stopservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
break
;
default
:
$output
.=
"<a href='status_services.php?mode=stopservice&service=
{
$service
[
'name'
]
}
' class=
\"
btn btn-default
\"
>"
;
break
;
$output
.=
"' class=
\"
btn btn-default
\"
>"
;
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Restart %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-refresh
\"
></span></a>
\n
"
;
/* stop service button */
$output
.=
"<a href='status_services.php?action=stop&service=
{
$service
[
'name'
]
}
"
;
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
}
$output
.=
"
<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Stop %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-stop
\"
></span
>"
;
$output
.=
"</a>"
;
$output
.=
"
' class=
\"
btn btn-default
\"
>"
;
$output
.=
"<
span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Stop %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-stop
\"
></span><
/a>"
;
}
else
{
switch
(
$service
[
'name'
])
{
case
"openvpn"
:
$output
.=
"<a href='status_services.php?mode=startservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
break
;
default
:
$output
.=
"<a href='status_services.php?mode=startservice&service=
{
$service
[
'name'
]
}
' class=
\"
btn btn-default
\"
>"
;
break
;
/* start service button */
$output
.=
"<a href='status_services.php?action=start&service=
{
$service
[
'name'
]
}
"
;
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
}
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Start %sService"
),
$stitle
)
.
"' alt='start' class=
\"
glyphicon glyphicon-play
\"
/></a>
\n
"
;
$output
.=
"' class=
\"
btn btn-default
\"
>"
;
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Start %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-play
\"
/></a>
\n
"
;
}
return
$output
;
}
...
...
src/www/status_services.php
View file @
f01b1953
...
...
@@ -43,14 +43,14 @@ require_once("rrd.inc");
if
(
!
empty
(
$_GET
[
'service'
]))
{
$service_name
=
$_GET
[
'service'
];
switch
(
$_GET
[
'
mode
'
])
{
case
"restartservice"
:
switch
(
$_GET
[
'
action
'
])
{
case
'restart'
:
$savemsg
=
service_control_restart
(
$service_name
,
$_GET
);
break
;
case
"startservice"
:
case
'start'
:
$savemsg
=
service_control_start
(
$service_name
,
$_GET
);
break
;
case
"stopservice"
:
case
'stop'
:
$savemsg
=
service_control_stop
(
$service_name
,
$_GET
);
break
;
}
...
...
@@ -68,8 +68,8 @@ function service_control_start($name, $extras)
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
if
(
$name
==
'openvpn'
)
{
$filter
[
'
vpn
id'
]
=
$extras
[
'id'
];
if
(
isset
(
$extras
[
'id'
])
)
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
...
...
@@ -107,8 +107,8 @@ function service_control_stop($name, $extras)
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$filter
=
array
();
if
(
$name
==
'openvpn'
)
{
$filter
[
'
vpn
id'
]
=
$extras
[
'id'
];
if
(
isset
(
$extras
[
'id'
])
)
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
,
$filter
);
...
...
@@ -142,11 +142,11 @@ function service_control_restart($name, $extras)
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
if
(
$name
==
'openvpn'
)
{
$filter
[
'
vpn
id'
]
=
$extras
[
'id'
];
if
(
isset
(
$extras
[
'id'
])
)
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
$service
=
find_service_by_name
(
$name
);
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not restart unknown service `%s'"
),
htmlspecialchars
(
$name
));
}
...
...
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