Make running_in_container work in more containers

Instead of grepping for 'lxc' in /proc/1/cgroup, use systemd's
features. This now at least also works in LXD containers.

Change-Id: I35e807c26f0b1fbba83ddbe04cfb4901a7a95cbe
This commit is contained in:
Julian Edwards 2017-03-16 09:01:39 +10:00
parent 27b1b21f01
commit 4ae92b846b

View File

@ -666,7 +666,7 @@ function set_mtu {
# running_in_container - Returns true otherwise false
function running_in_container {
if grep -q lxc /proc/1/cgroup; then
if [[ $(systemd-detect-virt --container) == 'none' ]]; then
return 0
fi