<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi all,<div><br></div><div>did not you get annoyed by lxc-ls mixing available and running containers ?</div><div><br></div><div>here is my lxc-ls that put an echo before each category of container making life easier when using lxc-ls</div><div><br></div><div>simply replace the provided lxc-ls by this one (change are line 24 and 26 with 2 simples echo.</div><div><br></div><div><div>#!/bin/bash</div><div><br></div><div>lxcpath=/var/lib/lxc</div><div><br></div><div>if [ ! -r $lxcpath ]; then</div><div> exit 0</div><div>fi</div><div><br></div><div>function get_cgroup()</div><div>{</div><div> local mount_string</div><div> mount_string=$(mount -t cgroup |grep -E -e '^lxc ')</div><div> if test -n "$mount_string"; then</div><div> mount_point=$(echo $mount_string |cut -d' ' -f3)</div><div> return</div><div> fi</div><div> mount_string=`grep -m1 -E '^[^ \t]+[ \t]+[^ \t]+[ \t]+cgroup' /proc/self/mounts`;</div><div> if test -z "$mount_string"; then</div><div> echo "failed to find mounted cgroup"</div><div> exit 1</div><div> fi</div><div> mount_point=`echo "$mount_string" |cut -d' ' -f2`;</div><div>}</div><div>echo "----- available containers -----"</div><div>ls "$@" $lxcpath</div><div>echo "----- running containers -----"</div><div>active=$(netstat -xa 2>/dev/null | grep $lxcpath | \</div><div> sed -e 's#.*'"$lxcpath/"'\(.*\)/command#\1#');</div><div><br></div><div>if test -n "$active"; then</div><div> get_cgroup</div><div> if test -n "$mount_point"; then</div><div> # get cgroup for init</div><div> init_cgroup=`cat /proc/1/cgroup | awk -F: '{ print $3 }' | head -1`</div><div> cd $mount_point/$init_cgroup/lxc</div><div> ls "$@" -d $active</div><div> fi</div><div>fi</div></div><div><br></div> </div></body>
</html>