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()
...
@@ -77,10 +77,10 @@ function vpn_services()
'php'
=>
array
(
'php'
=>
array
(
'restart'
=>
array
(
'vpn_pppoe_configure_by_id'
),
'restart'
=>
array
(
'vpn_pppoe_configure_by_id'
),
'start'
=>
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"
,
'pidfile'
=>
"/var/run/pppoe
{
$pppoecfg
[
'pppoeid'
]
}
-vpn.pid"
,
'
pppoe
id'
=>
$pppoecfg
[
'pppoeid'
],
'id'
=>
$pppoecfg
[
'pppoeid'
],
'name'
=>
'pppoed'
,
'name'
=>
'pppoed'
,
);
);
}
}
...
...
src/etc/inc/services.inc
View file @
f01b1953
...
@@ -2627,18 +2627,17 @@ function services_get()
...
@@ -2627,18 +2627,17 @@ function services_get()
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
foreach
(
array
(
'server'
,
'client'
)
as
$mode
)
{
if
(
isset
(
$config
[
'openvpn'
][
"openvpn-
{
$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'
]))
{
if
(
!
isset
(
$setting
[
'disable'
]))
{
$pconfig
=
array
();
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"openvpn"
;
$pconfig
[
'mode'
]
=
$mode
;
$pconfig
[
'id'
]
=
$id
;
$pconfig
[
'vpnid'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'openvpn_restart_by_id'
);
$pconfig
[
'php'
][
'start'
]
=
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
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$pconfig
[
'id'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'name'
]
=
'openvpn'
;
$pconfig
[
'mode'
]
=
$mode
;
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
}
}
...
@@ -2792,38 +2791,35 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
...
@@ -2792,38 +2791,35 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
function
get_service_control_links
(
$service
,
$addname
=
false
)
function
get_service_control_links
(
$service
,
$addname
=
false
)
{
{
$output
=
""
;
$stitle
=
$addname
?
$service
[
'name'
]
.
' '
:
''
;
$stitle
=
(
$addname
)
?
$service
[
'name'
]
.
" "
:
""
;
$output
=
''
;
if
(
get_service_status
(
$service
))
{
if
(
get_service_status
(
$service
))
{
switch
(
$service
[
'name'
])
{
/* restart service button */
case
"openvpn"
:
$output
.=
"<a href='status_services.php?action=restart&service=
{
$service
[
'name'
]
}
"
;
$output
.=
"<a href='status_services.php?mode=restartservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
if
(
isset
(
$service
[
'id'
]))
{
break
;
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
default
:
$output
.=
"<a href='status_services.php?mode=restartservice&service=
{
$service
[
'name'
]
}
' 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
"
;
$output
.=
"' class=
\"
btn btn-default
\"
>"
;
switch
(
$service
[
'name'
])
{
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Restart %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-refresh
\"
></span></a>
\n
"
;
case
"openvpn"
:
$output
.=
"<a href='status_services.php?mode=stopservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
/* stop service button */
break
;
$output
.=
"<a href='status_services.php?action=stop&service=
{
$service
[
'name'
]
}
"
;
default
:
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"<a href='status_services.php?mode=stopservice&service=
{
$service
[
'name'
]
}
' class=
\"
btn btn-default
\"
>"
;
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
break
;
}
}
$output
.=
"
<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Stop %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-stop
\"
></span
>"
;
$output
.=
"
' class=
\"
btn btn-default
\"
>"
;
$output
.=
"</a>"
;
$output
.=
"<
span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Stop %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-stop
\"
></span><
/a>"
;
}
else
{
}
else
{
switch
(
$service
[
'name'
])
{
/* start service button */
case
"openvpn"
:
$output
.=
"<a href='status_services.php?action=start&service=
{
$service
[
'name'
]
}
"
;
$output
.=
"<a href='status_services.php?mode=startservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
if
(
isset
(
$service
[
'id'
]))
{
break
;
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
default
:
$output
.=
"<a href='status_services.php?mode=startservice&service=
{
$service
[
'name'
]
}
' class=
\"
btn btn-default
\"
>"
;
break
;
}
}
$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
;
return
$output
;
}
}
...
...
src/www/status_services.php
View file @
f01b1953
...
@@ -43,14 +43,14 @@ require_once("rrd.inc");
...
@@ -43,14 +43,14 @@ require_once("rrd.inc");
if
(
!
empty
(
$_GET
[
'service'
]))
{
if
(
!
empty
(
$_GET
[
'service'
]))
{
$service_name
=
$_GET
[
'service'
];
$service_name
=
$_GET
[
'service'
];
switch
(
$_GET
[
'
mode
'
])
{
switch
(
$_GET
[
'
action
'
])
{
case
"restartservice"
:
case
'restart'
:
$savemsg
=
service_control_restart
(
$service_name
,
$_GET
);
$savemsg
=
service_control_restart
(
$service_name
,
$_GET
);
break
;
break
;
case
"startservice"
:
case
'start'
:
$savemsg
=
service_control_start
(
$service_name
,
$_GET
);
$savemsg
=
service_control_start
(
$service_name
,
$_GET
);
break
;
break
;
case
"stopservice"
:
case
'stop'
:
$savemsg
=
service_control_stop
(
$service_name
,
$_GET
);
$savemsg
=
service_control_stop
(
$service_name
,
$_GET
);
break
;
break
;
}
}
...
@@ -68,8 +68,8 @@ function service_control_start($name, $extras)
...
@@ -68,8 +68,8 @@ function service_control_start($name, $extras)
{
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
if
(
$name
==
'openvpn'
)
{
if
(
isset
(
$extras
[
'id'
])
)
{
$filter
[
'
vpn
id'
]
=
$extras
[
'id'
];
$filter
[
'id'
]
=
$extras
[
'id'
];
}
}
$service
=
find_service_by_name
(
$name
,
$filter
);
$service
=
find_service_by_name
(
$name
,
$filter
);
...
@@ -107,8 +107,8 @@ function service_control_stop($name, $extras)
...
@@ -107,8 +107,8 @@ function service_control_stop($name, $extras)
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$filter
=
array
();
$filter
=
array
();
if
(
$name
==
'openvpn'
)
{
if
(
isset
(
$extras
[
'id'
])
)
{
$filter
[
'
vpn
id'
]
=
$extras
[
'id'
];
$filter
[
'id'
]
=
$extras
[
'id'
];
}
}
$service
=
find_service_by_name
(
$name
,
$filter
);
$service
=
find_service_by_name
(
$name
,
$filter
);
...
@@ -142,11 +142,11 @@ function service_control_restart($name, $extras)
...
@@ -142,11 +142,11 @@ function service_control_restart($name, $extras)
{
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
if
(
$name
==
'openvpn'
)
{
if
(
isset
(
$extras
[
'id'
])
)
{
$filter
[
'
vpn
id'
]
=
$extras
[
'id'
];
$filter
[
'id'
]
=
$extras
[
'id'
];
}
}
$service
=
find_service_by_name
(
$name
);
$service
=
find_service_by_name
(
$name
,
$filter
);
if
(
!
isset
(
$service
[
'name'
]))
{
if
(
!
isset
(
$service
[
'name'
]))
{
return
sprintf
(
gettext
(
"Could not restart unknown service `%s'"
),
htmlspecialchars
(
$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