diff options
author | James Meyer <james.meyer@operamail.com> | 2012-01-02 22:01:04 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-01-02 22:01:04 (GMT) |
commit | 2365e0b921a7b7211384070f6cd9cc8611df3542 (patch) | |
tree | 6e4ec885707e4d834c9d417e59b8c3c8064d58d2 /abs/core/linhes-scripts | |
parent | 3acbadb008100071929b5c5ee5984ff475625654 (diff) | |
download | linhes_pkgbuild-2365e0b921a7b7211384070f6cd9cc8611df3542.zip linhes_pkgbuild-2365e0b921a7b7211384070f6cd9cc8611df3542.tar.gz linhes_pkgbuild-2365e0b921a7b7211384070f6cd9cc8611df3542.tar.bz2 |
linhes-scripts: add acl_fix_fstab.py, missed from earlier commit
Diffstat (limited to 'abs/core/linhes-scripts')
-rw-r--r-- | abs/core/linhes-scripts/acl_fix_fstab.py | 64 |
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() + |