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
b8f194cd
Commit
b8f194cd
authored
Sep 28, 2016
by
Jouke Witteveen
Browse files
Don't duplicate functionality provided by systemd
parent
b150d864
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/globals
View file @
b8f194cd
...
...
@@ -132,6 +132,15 @@ load_profile() {
source
"
$SUBR_DIR
/connections/
$Connection
"
}
## Wrapper around systemctl converting profile names to unit names
# $1: systemctl command
# $2...: profile names
sd_call
()
{
local command
=
$1
shift
systemctl
$command
$(
systemd-escape
--template
=
netctl@.service
"
$@
"
)
}
# Set a restrictive umask
do_readable :
...
...
src/netctl.in
View file @
b8f194cd
...
...
@@ -27,28 +27,6 @@ Commands:
END
}
sd_booted
()
{
[[
-d
/run/systemd/system
]]
}
sd_escape
()
{
local
IFS
=
''
# Prevent a recursion loop on backspaces
set
--
"
${
@//\\/\\x5c
}
"
while
[[
"
$*
"
=
~
[
^[:alnum:].:_/
\\
]
]]
;
do
set
--
"
${
@//
$BASH_REMATCH
/
$(
printf
'\\x%x'
"'
$BASH_REMATCH
"
)
}
"
done
printf
'%s\n'
"
${
@//\//-
}
"
}
# Wrapper around systemctl to convert profile names to unit names
sd_call
()
{
local command
=
$1
shift
set
--
$(
sd_escape
"
$@
"
)
systemctl
$command
$(
printf
'netctl@%s.service\n'
"
$@
"
)
}
list
()
{
local
indicators
=(
'*'
' '
)
list_profiles |
while
read
-r
Profile
;
do
...
...
@@ -105,7 +83,7 @@ switch_to() {
}
unit_enable
()
{
local
unit
=
"@systemdsystemconfdir@/netctl@
$(
s
d_
escape
"
$1
"
)
.service"
local
unit
=
"@systemdsystemconfdir@/netctl@
$(
s
ystemd-
escape
"
$1
"
)
.service"
if
[[
-e
$unit
]]
;
then
report_error
"A unit file for profile '
$1
' already exists"
return
1
...
...
@@ -118,14 +96,14 @@ unit_enable() {
declare
-p
BindsToInterfaces &> /dev/null
||
BindsToInterfaces
=
$Interface
if
((
${#
BindsToInterfaces
[@]
}
))
;
then
:
${
InterfaceRoot
=sys/subsystem/net/devices/
}
printf
"BindsTo=
$(
s
d_
escape
"
$InterfaceRoot
"
)
%s.device
\n
"
\
$(
s
d_
escape
"
${
BindsToInterfaces
[@]
}
"
)
>>
"
$unit
"
printf
"After=
$(
s
d_
escape
"
$InterfaceRoot
"
)
%s.device
\n
"
\
$(
s
d_
escape
"
${
BindsToInterfaces
[@]
}
"
)
>>
"
$unit
"
printf
"BindsTo=
$(
s
ystemd-
escape
"
$InterfaceRoot
"
)
%s.device
\n
"
\
$(
s
ystemd-
escape
"
${
BindsToInterfaces
[@]
}
"
)
>>
"
$unit
"
printf
"After=
$(
s
ystemd-
escape
"
$InterfaceRoot
"
)
%s.device
\n
"
\
$(
s
ystemd-
escape
"
${
BindsToInterfaces
[@]
}
"
)
>>
"
$unit
"
fi
if
((
${#
After
[@]
}
))
;
then
printf
'After="netctl@%s.service"\n'
\
$(
s
d_
escape
"
${
After
[@]
}
"
)
>>
"
$unit
"
$(
s
ystemd-
escape
"
${
After
[@]
}
"
)
>>
"
$unit
"
fi
mkdir
-p
"@systemdsystemconfdir@/multi-user.target.wants"
echo
"ln -s '
$unit
' '
${
unit
/system\//system/multi-user.target.wants/
}
'"
...
...
@@ -133,7 +111,7 @@ unit_enable() {
}
unit_disable
()
{
local
unit
=
"@systemdsystemconfdir@/netctl@
$(
s
d_
escape
"
$1
"
)
.service"
local
unit
=
"@systemdsystemconfdir@/netctl@
$(
s
ystemd-
escape
"
$1
"
)
.service"
if
sd_call
"is-enabled --quiet"
"
$1
"
&> /dev/null
;
then
sd_call disable
"
$1
"
fi
...
...
@@ -172,14 +150,14 @@ case $# in
enable
|
disable
)
ensure_root
"
$(
basename
"
$0
"
)
"
"unit_
$1
"
"
$2
"
if
s
d_
booted
;
then
if
s
ystemd-notify
--
booted
;
then
systemctl daemon-reload
fi
;;
reenable
)
ensure_root
"
$(
basename
"
$0
"
)
"
unit_disable
"
$2
"
unit_enable
"
$2
"
if
s
d_
booted
;
then
if
s
ystemd-notify
--
booted
;
then
systemctl daemon-reload
fi
;;
edit
)
...
...
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