From 9cc4259f6e0418b2393f0104ac59bd626d39ed14 Mon Sep 17 00:00:00 2001 From: Niklas Yann Wettengel Date: Mon, 3 Aug 2015 15:37:42 +0200 Subject: [PATCH] Added handling of multiple lxc.network.veth.pair-lines --- plugins/lxc/lxc_net | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/lxc/lxc_net b/plugins/lxc/lxc_net index 08759087..319a92cb 100755 --- a/plugins/lxc/lxc_net +++ b/plugins/lxc/lxc_net @@ -66,14 +66,16 @@ for guest in `ls $lxcpath`; do continue; fi if [ -f "$lxcpath/$guest/config" ]; then - device=`grep '^lxc\.network\.veth\.pair[ \t]*=[ \t]*' $lxcpath/$guest/config | \ + devices=`grep '^lxc\.network\.veth\.pair[ \t]*=[ \t]*' $lxcpath/$guest/config | \ awk '{ split($0, a, /=/); gsub(/[ \t]/, "", a[2]); print a[2]; }'` - if [ -n "$device" ]; then - device_re=`echo $device | sed -e 's/\./\\\\./g'` - if [ `grep -c "^ *$device_re:" /proc/net/dev` -eq 1 ]; then - actives="$actives $guest" - eval "dev_$(clean_fieldname $guest)=$device" - fi + if [ -n "$devices" ]; then + for device in $devices; do + device_re=`echo $device | sed -e 's/\./\\\\./g'` + if [ `grep -c "^ *$device_re:" /proc/net/dev` -eq 1 ]; then + actives="$actives $guest" + eval "dev_$(clean_fieldname $guest)=$device" + fi + done fi fi done