Revision 232

Date:
2010/10/24 11:55:02
Author:
dpavlin
Revision Log:
extract lxc_hostname and lxc_ip into functions
Files:

Legend:

 
Added
 
Removed
 
Modified
  • recepies/lxc/lxc-watchdog.sh

     
    40 40 grep '^ *lxc\.rootfs *=' "/var/lib/lxc/$1/config" | cut -d= -f2 | sed 's/^ *//'
    41 41 }
    42 42
    43 lxc_hostname() {
    44 inside=`cat $(lxc_rootfs $1)/etc/hostname`
    45 config=`grep lxc.utsname /var/lib/lxc/$name/config | cut -d= -f2`
    46 echo "$config [$inside]";
    47 }
    43 48
    49 lxc_ip() {
    50 grep lxc.network.ipv4 /var/lib/lxc/$name/config | cut -d= -f2 ||
    51 grep address $(lxc_rootfs $name)/etc/network/interfaces | sed 's/.*address //'
    52 }
    53
    44 54 lxc_status() {
    45 55 ( find /var/lib/lxc/ -name "config" | cut -d/ -f5 | sort -u | xargs -i lxc-info -n {} | sed "s/'//g" | while read name is status ; do
    46 56 boot="-"
    47 hostname=`cat $(lxc_rootfs $name)/etc/hostname`
    48 ip=`grep address $(lxc_rootfs $name)/etc/network/interfaces | sed 's/.*address //'`
    49 test -z "$ip" && ip=`grep lxc.network.ipv4 /var/lib/lxc/$name/config | cut -d= -f2`
    50 57 test -s /var/lib/lxc/$name/on_boot && boot="boot"
    51 echo "$name $status $boot $(lxc_rootfs $name) $ip $hostname"
    58 echo "$name $status $boot $(lxc_rootfs $name) $(lxc_ip $name) $(lxc_hostname $name)"
    52 59 done ) | column -t
    53 60 }
    54 61