summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abs/core/linhes-scripts/acl_fix_fstab.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/abs/core/linhes-scripts/acl_fix_fstab.py b/abs/core/linhes-scripts/acl_fix_fstab.py
new file mode 100644
index 0000000..187cab1
--- /dev/null
+++ b/abs/core/linhes-scripts/acl_fix_fstab.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python2
+import os
+import sys
+import subprocess as sub
+
+def should_add_acl(mount_point,fs_map):
+ acl_fs_list=["ext3","ext4"]
+ rc = False
+ for i in fs_map:
+ if i[0] == mount_point:
+ if i[1] in acl_fs_list:
+ rc = True
+
+ return rc
+
+
+cmd="cp -f /etc/fstab /etc/fstab.backup.pre_acl"
+os.system(cmd)
+f = open('/etc/fstab', 'r')
+fstab=f.readlines()
+f.close()
+
+p = sub.Popen(['/sbin/fsck','-N' ],stdout=sub.PIPE,stderr=sub.PIPE)
+output, errors = p.communicate()
+output = output.split("\n")
+fs_map=[]
+for i in output:
+ if i.startswith("["):
+ split_line=i.split()
+ #find mount_p and remove the last char
+ mount_p = split_line[3][:-1]
+ fstype = split_line[4].split(".")[1]
+ append_tuple=(mount_p,fstype)
+ fs_map.append(append_tuple)
+
+
+
+mp=['/' , '/myth', '/data']
+newfstab=[]
+for line in fstab:
+ new_line=line
+ split_line=line.split()
+ try:
+ if split_line[1] in mp and should_add_acl(split_line[1],fs_map):
+ #print split_line[3]
+ if "acl" in split_line[3]:
+ pass
+ else:
+ print "Adding ACL"
+ new_acl=split_line[3]+",acl"
+ split_line[3]=new_acl
+ new_line='\t'.join(split_line)
+ except:
+ pass
+ newfstab.append(new_line)
+
+
+f = open('/etc/fstab', 'w')
+for i in newfstab:
+ f.write(i)
+ f.write("\n")
+
+f.close()
+