Browse code

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

Julian Edwards authored on 2017/03/16 08:01:39
Showing 1 changed files
... ...
@@ -666,7 +666,7 @@ function set_mtu {
666 666
 
667 667
 # running_in_container - Returns true otherwise false
668 668
 function running_in_container {
669
-    if grep -q lxc /proc/1/cgroup; then
669
+    if [[ $(systemd-detect-virt --container) == 'none' ]]; then
670 670
         return 0
671 671
     fi
672 672