use only first ip address
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 25 Jan 2011 14:40:42 +0000 (14:40 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 25 Jan 2011 14:40:42 +0000 (14:40 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@235 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/lxc/lxc-watchdog.sh

index 11fe0ac..da013d8 100755 (executable)
@@ -47,8 +47,9 @@ lxc_hostname() {
 }
 
 lxc_ip() {
-       ( grep lxc.network.ipv4 /var/lib/lxc/$name/config | cut -d= -f2 || \
-       grep address $(lxc_rootfs $name)/etc/network/interfaces | sed 's/.*address //' ) | \
+       ( grep lxc.network.ipv4 /var/lib/lxc/$name/config | grep -v '^#' | cut -d= -f2 || \
+       grep address $(lxc_rootfs $name)/etc/network/interfaces | grep -v '^#' | sed 's/.*address //' ) | \
+       head -1 | \
        sed -e 's/ *//g' -e 's/\/.*$//'
 }