blob: 9f3cc544d082372ae9c63c7bb1fc6e37f4a653d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/python2
import os
import sys
cmd="cp -f /etc/fstab /etc/fstab.backup.pre_acl"
os.system(cmd)
f = open('/etc/fstab', 'r')
fstab=f.readlines()
f.close()
mp='/data/mnt/d1'
def check_fstab_mount():
#first check if media/d1 is in list, if not add it.
newfstab=[]
mnt_in_fstab=False
for line in fstab:
split_line=line.split()
try:
if split_line[1] == mp :
print "found mountpoint if fstab"
mnt_in_fstab = True
break
except: pass
return mnt_in_fstab
def add_mnt_to_fstab():
newfstab=[]
for line in fstab:
newfstab.append(line)
split_line=line.split()
try:
if split_line[1] == "/myth":
split_line[1] = mp
new_line='\t'.join(split_line)+"\n"
newfstab.append(new_line)
except:
pass
return newfstab
if check_fstab_mount() == False:
print "I need to add it"
newfstab=add_mnt_to_fstab()
f = open('/tmp/fstab', 'w')
for i in newfstab:
f.write(i)
#f.write("\n")
f.close()
|