[arch-projects] [netctl][PATCH] Support dynamically appearing interfaces

Thomas Bächler thomas at archlinux.org
Fri Feb 15 07:41:52 EST 2013


Am 12.02.2013 13:40, schrieb Ivan Shapovalov:
> diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt
> index efd4fb4..73d99f9 100644
> --- a/docs/netctl.profile.5.txt
> +++ b/docs/netctl.profile.5.txt
> @@ -85,6 +85,10 @@ GENERAL OPTIONS
>      A command that is executed after a connection is brought down.
>      Similar precautions should be taken as with 'ExecUpPost'.
>  
> +'DynamicProfileStart='::
> +    If ``yes`', the profile unit file is wanted by its interface unit file
> +    instead of *multi-user.target*. This is needed if the interface
> +    may appear dynamically (e. g. cell phone modem).

I'd name this differently. For example
 WantedBy=multi-user.target
 WantedBy=DEVICE
 WantedBy=foobar.target
and make it default to multi-user.target. The special keyword DEVICE
would make it start dynamically.

> diff --git a/src/netctl b/src/netctl
> index 498b50d..787a621 100755
> --- a/src/netctl
> +++ b/src/netctl
> @@ -97,8 +97,18 @@ unit_enable() {
>      if [[ -n $After ]]; then
>          printf 'After="netctl@%s.service"\n' "${After[@]//\"/\\\"}" >> 
> "$unit"
>      fi
> -    echo "ln -s '$unit' '${unit/system\//system/multi-user.target.wants/}'"
> -    ln -s "$unit" "${unit/system\//system/multi-user.target.wants/}"
> +
> +    local trigger="multi-user.target"
> +    if is_yes "${DynamicProfileStart:-no}"; then
> +        trigger="sys-subsystem-net-devices-${Interface/-/\\x2d}.device"
> +    fi

'Interface' is incorrect, if I remember right, this should be derived
from BindsToInterfaces - but I am unsure whether that is a good idea,
because BindsToInterfaces could have more than one value. It might still
be worth doing it, for example: Try to bring up a bridge once one of the
interfaces appears. But then, one should rather implement a system where
the bridge is brought up and interfaces are dynamically added and
removed as they appear.

> +
> +    trigger="${unit/system\//system/$trigger.wants/}"
> +
> +    echo "mkdir -p '$(dirname "$trigger")'"
> +    mkdir -p "$(dirname "$trigger")"
> +    echo "ln -s '$unit' '$trigger'"
> +    ln -s "$unit" "$trigger"
>      systemctl daemon-reload
>  }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20130215/36780c69/attachment.asc>


More information about the arch-projects mailing list