[arch-projects] [netctl][PATCH] Add EnvironmentFile into the netctl@.service
This patch adds the ability to pass environment variables to the network script. This allows to enable debugging by adding the "NETCTL_DEBUG=yes" into the /etc/conf.d/netctl file. Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com> --- services/netctl@.service | 1 + 1 file changed, 1 insertion(+) diff --git a/services/netctl@.service b/services/netctl@.service index b8a19c2..576617f 100644 --- a/services/netctl@.service +++ b/services/netctl@.service @@ -8,5 +8,6 @@ Wants=network.target [Service] Type=oneshot RemainAfterExit=yes +EnvironmentFile=-/etc/conf.d/netctl ExecStart=/usr/lib/network/network start %I ExecStop=/usr/lib/network/network stop %I -- 2.2.2
This patch fixes the behavior when IPv4 and IPv6 is configured in the same profile file but only IPv6 address can be acquired. Without this patch, the process finishes right after the attempt to acquire IPv4 address and never gets to the point where IPv6 address can be acquired. Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com> --- src/lib/ip | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/ip b/src/lib/ip index 2dc67fc..5b0eab2 100644 --- a/src/lib/ip +++ b/src/lib/ip @@ -62,9 +62,17 @@ ip_set() { ;; esac + OnlyIPv6=no case $IP in dhcp) - dhcp_call "${DHCPClient:-dhcpcd}" start 4 || return + dhcp_call "${DHCPClient:-dhcpcd}" start 4 + # Do not fail yet, maybe only IPV6 address will be acquired + if [[ $? > 0 ]] && [[ $IP6 != @(dhcp|dhcp-noaddr) ]]; then + return + elif [[ $? > 0 ]]; then + report_debug "Could not get IPv4 address. Will try IPv6." + fi + OnlyIPv6=yes ;; static) for addr in "${Address[@]}"; do @@ -82,7 +90,7 @@ ip_set() { ;; esac - if [[ $IP != @(|no) ]]; then + if [[ $OnlyIPv6 == 'no' ]] && [[ $IP != @(|no) ]]; then # Add static IP routes for route in "${Routes[@]}"; do if ! do_debug ip route add $route dev "$Interface"; then -- 2.2.2
On Sun, Feb 1, 2015 at 12:48 PM, Jiri Tyr <jiri.tyr@gmail.com> wrote:
This patch adds the ability to pass environment variables to the network script. This allows to enable debugging by adding the "NETCTL_DEBUG=yes" into the /etc/conf.d/netctl file.
What is the benefit of this over setting an environment in, say, /etc/netctl/hooks/environment?
On Mon, Feb 2, 2015 at 12:18 PM, Jouke Witteveen <j.witteveen@gmail.com> wrote:
What is the benefit of this over setting an environment in, say, /etc/netctl/hooks/environment?
Well, the motivation for this was that I could not find a way how to enable the debugging. Apart of that, using hooks enables debugging only for certain profiles. The conf.d solution enables it globally regardless the profile name. Just thinking about it, I should have documented how to enable debugging by using the file in the conf.d directory. If this patch has chance being accepted, I will add the documentation.
On Mon, Feb 2, 2015 at 2:00 PM, Jiri Tyr <jiri.tyr@gmail.com> wrote:
On Mon, Feb 2, 2015 at 12:18 PM, Jouke Witteveen <j.witteveen@gmail.com> wrote:
What is the benefit of this over setting an environment in, say, /etc/netctl/hooks/environment?
Well, the motivation for this was that I could not find a way how to enable the debugging. Apart of that, using hooks enables debugging only for certain profiles. The conf.d solution enables it globally regardless the profile name.
Just thinking about it, I should have documented how to enable debugging by using the file in the conf.d directory. If this patch has chance being accepted, I will add the documentation.
You can just add "NETCTL_DEBUG=yes" to /etc/netctl/hooks/environment and you get debugging for all profiles.
Nice, I did not know that. We should definitely document this. On Mon, Feb 2, 2015 at 2:13 PM, Jouke Witteveen <j.witteveen@gmail.com> wrote:
On Mon, Feb 2, 2015 at 2:00 PM, Jiri Tyr <jiri.tyr@gmail.com> wrote:
On Mon, Feb 2, 2015 at 12:18 PM, Jouke Witteveen <j.witteveen@gmail.com> wrote:
What is the benefit of this over setting an environment in, say, /etc/netctl/hooks/environment?
Well, the motivation for this was that I could not find a way how to enable the debugging. Apart of that, using hooks enables debugging only for certain profiles. The conf.d solution enables it globally regardless the profile name.
Just thinking about it, I should have documented how to enable debugging by using the file in the conf.d directory. If this patch has chance being accepted, I will add the documentation.
You can just add "NETCTL_DEBUG=yes" to /etc/netctl/hooks/environment and you get debugging for all profiles.
On 2015-02-01 at 11:48 +0000, Jiri Tyr wrote:
This patch adds the ability to pass environment variables to the network script. This allows to enable debugging by adding the "NETCTL_DEBUG=yes" into the /etc/conf.d/netctl file.
[...]
I think that this can be achieved (apart from using /etc/netctl/hooks) more elegantly by using systemd drop-ins: # cat > /etc/systemd/system/netctl@.service.d/env.conf <<EOF [Service] Environment=... EOF # cat > /etc/systemd/system/netctl@$PROFILE.service.d/env.conf <<EOF [Service] Environment=... EOF Or, one can use systemctl(1) to invoke an editor on the right file: # systemctl edit netctl@.service <type in the above lines> # systemctl edit netctl@$PROFILE.service <type in the above lines> Or, in the latter case, one can also use systemctl(1) to set the environment non-interactively: # systemctl set-property netctl@$PROFILE.service Environment=... -- Ivan Shapovalov / intelfx /
participants (3)
-
Ivan Shapovalov
-
Jiri Tyr
-
Jouke Witteveen