diff --git a/app-emulation/lxc/files/lxc.initd.2 b/app-emulation/lxc/files/lxc.initd.2 index 72680d8..9e5debd 100644 --- a/app-emulation/lxc/files/lxc.initd.2 +++ b/app-emulation/lxc/files/lxc.initd.2 @@ -24,6 +24,16 @@ lxc_get_var() { awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE} } +lxc_get_net_link_type() { + awk 'BEGIN { FS="[ \t]*=[ \t]*"; _link=""; _type="" } + $1 == "lxc.network.type" {_type=$2;} + $1 == "lxc.network.link" {_link=$2;} + {if(_link != "" && _type != ""){ + printf("%s:%s\n", _link, _type ); + _link=""; _type=""; + }; }' <${CONFIGFILE} +} + checkconfig() { if [ ${CONTAINER} = ${SVCNAME} ]; then eerror "You have to create an init script for each container:" @@ -50,24 +60,19 @@ depend() { config ${CONFIGFILE} need localmount - # find out which network interface the container is linked to, - # and then require that to be enabled, so that the - # dependencies are correct. - netif=$(lxc_get_var lxc.network.link) - - # when the network type is set to phys, we can make use of a - # network service (for instance to set it up before we disable - # the net_admin capability), but we might also not set it up - # at all on the host and leave the net_admin capable service - # to take care of it. - nettype=$(lxc_get_var lxc.network.type) - - if [ -n "${netif}" ]; then - case "${nettype}" in - phys) use net.${netif} ;; - *) need net.${netif} ;; - esac - fi + local _x _if + for _x in $(lxc_get_net_link_type); do + _if=${_x%:*} + case "${_x##*:}" in + # when the network type is set to phys, we can make use of a + # network service (for instance to set it up before we disable + # the net_admin capability), but we might also not set it up + # at all on the host and leave the net_admin capable service + # to take care of it. + phys) use net.${_if} ;; + *) need net.${_if} ;; + esac + done } start() {