Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
netctl
Commits
1a35b9ff
Commit
1a35b9ff
authored
Jul 28, 2018
by
Jouke Witteveen
Browse files
Centralize profile exposing through the Profile variable
This also allows hooks to alter the profile to be loaded.
parent
04d39b25
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/auto.action
View file @
1a35b9ff
...
...
@@ -6,11 +6,9 @@
export
INTERFACE
=
"
$1
"
export
SSID
=
"
$2
"
# Expose the profile name similar to ordinary netctl usage
Profile
=
"
$3
"
export
ACTION
=
"
$4
"
load_profile
"
$
Profile
"
load_profile
"
$
3
"
load_interface_config
"
$INTERFACE
"
case
$ACTION
in
...
...
src/lib/globals
View file @
1a35b9ff
...
...
@@ -113,19 +113,21 @@ list_profiles() {
# $1: profile name
load_profile
()
{
local
hook
if
[[
-z
$1
||
!
-r
"
$PROFILE_DIR
/
$1
"
]]
;
then
exit_error
"Profile '
$1
' does not exist or is not readable"
# Expose the profile name
Profile
=
$1
if
[[
-z
$Profile
||
!
-r
"
$PROFILE_DIR
/
$Profile
"
]]
;
then
exit_error
"Profile '
$Profile
' does not exist or is not readable"
fi
while
IFS
=
read
-r
hook
;
do
source
"
$hook
"
done
< <
(
find
-L
"
$PROFILE_DIR
/hooks"
-maxdepth
1
-type
f
-executable
-not
-name
'.*'
-not
-name
'*~'
-not
-name
$'*
\n
*'
|
sort
-u
)
unset
hook
source
"
$PROFILE_DIR
/
$
1
"
source
"
$PROFILE_DIR
/
$
Profile
"
if
[[
-z
$Interface
]]
;
then
exit_error
"Profile '
$
1
' does not specify an interface"
exit_error
"Profile '
$
Profile
' does not specify an interface"
fi
if
[[
!
-r
"
${
Connection
:+
$SUBR_DIR
/connections/
$Connection
}
"
]]
;
then
exit_error
"Profile '
$
1
' does not specify a valid connection"
exit_error
"Profile '
$
Profile
' does not specify a valid connection"
fi
source
"
$SUBR_DIR
/connections/
$Connection
"
}
...
...
src/lib/network
View file @
1a35b9ff
...
...
@@ -85,10 +85,9 @@ cd /
if
[[
$#
-eq
1
&&
$1
==
wait-online
]]
;
then
network_wait_online
elif
[[
$#
-eq
2
&&
$1
==
@
(
start|stop
)
]]
;
then
# Expose the
profile name and
command
# Expose the command
Command
=
$1
Profile
=
$2
load_profile
"
$Profile
"
load_profile
"
$2
"
load_interface_config
"
$Interface
"
"network_
$1
"
else
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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