Changeset 3534


Ignore:
Timestamp:
Feb 6, 2017, 4:24:07 PM (2 years ago)
Author:
mabarracus
Message:

Fix live detection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lliurex-detect/trunk/fuentes/lliurex-detect.install/usr/bin/lliurex-detect

    r3533 r3534  
    1212import pwd,grp
    1313import argparse
     14import re
    1415# import glob  # Commented: python 3.5 is not available on lliurex 15
    1516import fnmatch # allows search recursively without glob
     
    2021
    2122def detect_live():
    22     if (os.isdir('/rofs') and os.isdir('/cow')):
    23         try:
    24             check_output(['grep','loop','/proc/mounts'])
    25             return None
    26         except:
    27             raise Exception('Not live')
    28     raise Exception('Not live')
     23    test1=False
     24    test2=False
     25    test3=False
     26
     27    if os.path.isdir('/rofs'):
     28        r1=re.compile('^tmpfs\s/cow\stmpfs')
     29        r2=re.compile('^/cow\s/\soverlayfs')
     30        r3=re.compile('^/dev/loop0\s/rofs\ssquashfs')
     31        with open('/proc/mounts') as mounts_file:
     32            for line in mounts_file.readlines():
     33                if r1.match(line):
     34                    test1=True
     35                if r2.match(line):
     36                    test2=True
     37                if r3.match(line):
     38                    test3=True
     39    if test1 and test2 and test3:
     40        pass
     41    else:
     42        raise Exception('Not live')
     43
    2944#def detect_live():
    3045
Note: See TracChangeset for help on using the changeset viewer.