[arch-projects] [netctl][PATCH] Support dynamically appearing interfaces
Jouke Witteveen
j.witteveen at gmail.com
Thu Feb 14 15:45:52 EST 2013
On Tue, Feb 12, 2013 at 1:40 PM, Ivan Shapovalov <intelfx100 at gmail.com> wrote:
> If a profile is WantedBy=multi-user.target, it breaks init sequence
> if its interface is not immediately available at runtime
> (e. g. a cell-phone or USB modem).
Does this work? Is there a reason not to make the device the default trigger?
>
> Add a parameter "DynamicProfileStart=" which, if enabled,
> makes the profile unit wanted by its interface unit
> (and not multi-user.target).
> ---
> docs/netctl.profile.5.txt | 4 ++++
> src/netctl | 14 ++++++++++++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> 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).
>
> IP OPTIONS
> ----------
> 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
> +
> + 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
> }
>
> --
> 1.8.1.3
More information about the arch-projects
mailing list