Hi all,
did not you get annoyed by lxc-ls mixing available and running containers ?
here is my lxc-ls that put an echo before each category of container making 
life easier when using lxc-ls
simply replace the provided lxc-ls by this one (change are line 24 and 26 with 
2 simples echo.
#!/bin/bash
lxcpath=/var/lib/lxc
if [ ! -r $lxcpath ]; then    exit 0fi
function get_cgroup(){        local mount_string        mount_string=$(mount -t 
cgroup |grep -E -e '^lxc ')        if test -n "$mount_string"; then             
   mount_point=$(echo $mount_string |cut -d' ' -f3)                return       
 fi        mount_string=`grep -m1 -E '^[^ \t]+[ \t]+[^ \t]+[ \t]+cgroup' 
/proc/self/mounts`;        if test -z "$mount_string"; then                echo 
"failed to find mounted cgroup"                exit 1        fi        
mount_point=`echo "$mount_string" |cut -d' ' -f2`;}echo "----- available 
containers -----"ls "$@" $lxcpathecho "-----  running containers  
-----"active=$(netstat -xa 2>/dev/null | grep $lxcpath | \        sed -e 
's#.*'"$lxcpath/"'\(.*\)/command#\1#');
if test -n "$active"; then        get_cgroup        if test -n "$mount_point"; 
then                # get cgroup for init                init_cgroup=`cat 
/proc/1/cgroup | awk -F: '{ print $3 }' | head -1`                cd 
$mount_point/$init_cgroup/lxc                ls "$@" -d $active        fifi
                                          
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users

Reply via email to