Permalink
Browse files

Only setup cgroups if the cgroup path does not exist

  • Loading branch information...
1 parent b1cb5f3 commit 6e1842c27c951c373fc0cde3cce93c93593b823f David Sabeti and Pieter Noordhuis committed Apr 5, 2013
Showing with 17 additions and 20 deletions.
  1. +17 −20 warden/root/linux/setup.sh
View
@@ -9,30 +9,27 @@ cd $(dirname "${0}")
cgroup_path=/tmp/warden/cgroup
-mkdir -p $cgroup_path
-
-if grep "${cgroup_path} " /proc/mounts | cut -d' ' -f3 | grep -q cgroup
+if [ ! -d $cgroup_path ]
then
- find $cgroup_path -mindepth 1 -type d | sort | tac | xargs rmdir
- umount $cgroup_path
-fi
-
-# Mount tmpfs
-if ! grep "${cgroup_path} " /proc/mounts | cut -d' ' -f3 | grep -q tmpfs
-then
- mount -t tmpfs none $cgroup_path
-fi
+ mkdir -p $cgroup_path
-# Mount cgroup subsystems individually
-for subsystem in cpu cpuacct devices memory
-do
- mkdir -p $cgroup_path/$subsystem
-
- if ! grep -q "${cgroup_path}/$subsystem " /proc/mounts
+ # Mount tmpfs
+ if ! grep "${cgroup_path} " /proc/mounts | cut -d' ' -f3 | grep -q tmpfs
then
- mount -t cgroup -o $subsystem none $cgroup_path/$subsystem
+ mount -t tmpfs none $cgroup_path
fi
-done
+
+ # Mount cgroup subsystems individually
+ for subsystem in cpu cpuacct devices memory
+ do
+ mkdir -p $cgroup_path/$subsystem
+
+ if ! grep -q "${cgroup_path}/$subsystem " /proc/mounts
+ then
+ mount -t cgroup -o $subsystem none $cgroup_path/$subsystem
+ fi
+ done
+fi
./net.sh setup

0 comments on commit 6e1842c

Please sign in to comment.