File: mic-rm-chroot-dir

package info (click to toggle)
mic2 0.19-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 932 kB
  • ctags: 864
  • sloc: python: 9,292; sh: 1,347; makefile: 62
file content (19 lines) | stat: -rwxr-xr-x 561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python -tt

import mic.chroot as achroot
import shutil
import sys
import os

if len(sys.argv) < 2:
    print "Usage: %s <chroot-dir>"
    sys.exit(1)

chrootdirs = sys.argv[1:]
for chrootdir in chrootdirs:
    if os.path.isdir(chrootdir):
        ret = achroot.cleanup_mounts(chrootdir)
        if ret == 0:
            shutil.rmtree(chrootdir, ignore_errors = True)
        else:
            print "Failed to rm %s because of the above error. please ensure there isn't any other process accessing some directories under %s" % (chrootdir, chrootdir)