/usr/bin/lxc-ls is in lxc 0.7.5-3ubuntu52.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #!/bin/bash
lxcpath=/var/lib/lxc
if [ ! -r $lxcpath ]; then
exit 0
fi
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`;
}
ls "$@" $lxcpath
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
fi
fi
|