summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/add_storage.py
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2016-06-07 19:28:19 (GMT)
committerBritney Fransen <brfransen@gmail.com>2016-06-07 19:28:19 (GMT)
commit8c9dc836b4e96cacc66897228de39ae3a7c27ac9 (patch)
treebb7c6f7441ee5257223c2c470b6959dac1a7178a /abs/core/LinHES-system/add_storage.py
parent1cf333b06fe3832a007ac2b89f74748c72066d73 (diff)
downloadlinhes_pkgbuild-8c9dc836b4e96cacc66897228de39ae3a7c27ac9.zip
linhes_pkgbuild-8c9dc836b4e96cacc66897228de39ae3a7c27ac9.tar.gz
linhes_pkgbuild-8c9dc836b4e96cacc66897228de39ae3a7c27ac9.tar.bz2
LinHES-system: add_storage.py: check fstab for old mount point and comment out if found
Diffstat (limited to 'abs/core/LinHES-system/add_storage.py')
-rwxr-xr-xabs/core/LinHES-system/add_storage.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py
index 853c39e..9f5a60d 100755
--- a/abs/core/LinHES-system/add_storage.py
+++ b/abs/core/LinHES-system/add_storage.py
@@ -248,7 +248,7 @@ class disk_device:
def add_fstab(self,bind=False):
new_fstab_list=['UUID=', 'mount_point', 'auto', 'defaults', '0', '1']
fstab=self.read_fstab()
-
+ new_fstab=[]
#determine mount_path
self.new_mount_point="%s/%s_%s" %(self.top_mount_dir,self.model.replace(' ',''),self.serial_number.replace(' ',''))
@@ -257,8 +257,16 @@ class disk_device:
new_fstab_list=["/data/storage/disk0" , self.new_mount_point , "none" , "rw,bind", '0', '0']
uuid=self.find_uuid(self.block_partition)
else:
- #determine options
-
+ #check for old mount point and comment out
+ for line in fstab:
+ if not line.startswith("#"):
+ if line.find(self.new_mount_point) > -1:
+ print " Found old mount %s in fstab, commenting out" %self.new_mount_point
+ line = "#"+line
+ new_fstab.append(line)
+ fstab=new_fstab
+
+ #determine options
new_options = self.find_options_type(fstab)[0]
#find blkid
@@ -481,7 +489,6 @@ def prompt_to_add(current_drive,destruction = True):
def prompt_to_continue(process_list):
loop = True
- #while loop:
print "\n\n\n Ready to add additional storage!\n"
if destruction:
print "** WARNING: These disk(s) WILL be partitioned and formatted. **\n ** All content on these disk(s) will be erased. **"
@@ -491,10 +498,6 @@ def prompt_to_continue(process_list):
print " %s" %(i.get_name())
str1 = raw_input("\n Press Y to add disk(s), any other key to cancel:")
- #if str1 in ['Y','N','y','n']:
- # loop = False
- # break
- #print "\n"
if str1 == 'Y' or str1 == 'y':
rc = True
else:
@@ -673,6 +676,7 @@ def main(scan_only, destruction, no_mount, install_call, dir_sg):
i.mkdirs(FS_LIST)
i.set_disk_num(disk_num)
+ i.set_dir_sg(dir_sg)
i.write_config()
system_drive_list.append(i)
write_known_drive_list(system_drive_list)
@@ -901,7 +905,6 @@ class reconstruct_path:
return fstab
def check_in_fstab(self,fstab,check_path):
-
for line in fstab:
if line.find(check_path) > -1:
return True
@@ -914,7 +917,7 @@ class reconstruct_path:
f = open('/etc/fstab', 'a')
#f = open('/tmp/fstab', 'a')
f.write(new_fstab_line)
- f.write("\n")
+ #f.write("\n")
f.close()
def symlink(self):
@@ -940,7 +943,7 @@ class reconstruct_path:
self.symlink()
if self.check_in_fstab(fstab,self.uuid) == True:
- print " Found disk in fstab, will not add it"
+ print " Found UUID of disk in fstab, will not add it"
else:
print " Adding storage to fstab"
if self.bind == "True" :
@@ -952,6 +955,16 @@ class reconstruct_path:
print " Found bind storage in fstab, will not add it"
else:
+ #check for old mount point and comment out
+ f = open('/etc/fstab', 'w')
+ for line in fstab:
+ if not line.startswith("#"):
+ if line.find(self.mount_point) > -1:
+ print " Found old mount %s in fstab, commenting out" %self.mount_point
+ line = "#"+line
+ f.write(line)
+ f.close()
+
#construct new line
new_options = self.find_options_type(fstab)[0]
new_fstab_list[0]="UUID=%s" %self.uuid