]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/lxc-ls.in
lxc-ls to report also active containers
[mirror_lxc.git] / src / lxc / lxc-ls.in
1 #!/bin/bash
2
3 lxcpath=@LXCPATH@
4
5 if [ ! -r $lxcpath ]; then
6 exit 0
7 fi
8
9 function get_cgroup()
10 {
11 local mount_string
12 mount_string=$(mount -t cgroup |grep -E -e '^lxc ')
13 if test -z "$mount_string"; then
14 mount_string=$(mount |grep -m1 'type cgroup')
15 fi
16 if test -n "$mount_string"; then
17 mount_point=$(echo $mount_string |cut -d' ' -f3)
18 fi
19 }
20
21 ls $* $lxcpath
22
23 active=$(netstat -xa | grep $lxcpath | \
24 sed -e 's#.*'"$lxcpath/"'\(.*\)/command#\1#');
25
26 if test -n "$active"; then
27 get_cgroup
28 if test -n "$mount_point"; then
29 cd $mount_point; ls $* -d $active
30 fi
31 fi