summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_fileshare.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-10-08 01:47:55 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-10-08 01:47:55 (GMT)
commit6a71275027db683cc2d6b6df1d7558adc47ff156 (patch)
treefc3772fb214d84b4d745be4c674e72fb47677a64 /abs/core/LinHES-config/mv_fileshare.py
parent5711508ebf21a62cabc3c682ec8d65108452dcfe (diff)
downloadlinhes_pkgbuild-6a71275027db683cc2d6b6df1d7558adc47ff156.zip
linhes_pkgbuild-6a71275027db683cc2d6b6df1d7558adc47ff156.tar.gz
linhes_pkgbuild-6a71275027db683cc2d6b6df1d7558adc47ff156.tar.bz2
LinHES-config: fixed central NFS
new feature, if central NFS is selected the entry is added to nfsmap_auto
Diffstat (limited to 'abs/core/LinHES-config/mv_fileshare.py')
-rwxr-xr-xabs/core/LinHES-config/mv_fileshare.py83
1 files changed, 63 insertions, 20 deletions
diff --git a/abs/core/LinHES-config/mv_fileshare.py b/abs/core/LinHES-config/mv_fileshare.py
index ebb53c7..96e9a28 100755
--- a/abs/core/LinHES-config/mv_fileshare.py
+++ b/abs/core/LinHES-config/mv_fileshare.py
@@ -4,6 +4,7 @@ import mv_common
import glob
from urllib2 import Request, urlopen, URLError, HTTPError
#client side
+#CentralNFSallhosts=
def setup_nfs_client(systemconfig,data_config):
nfslist=[]
@@ -13,6 +14,7 @@ def setup_nfs_client(systemconfig,data_config):
if systemconfig.get("HaveCentralNFS") == "yes":
logging.debug(" Using a Central NFS server")
+ logging.debug(" NFSserver:%s" %systemconfig.get("NFSserver"))
if systemconfig.get("NFSserver") == "file:nfsmap":
#if it's a file check for it, failure results in downloading attempt from MBE
nfsmap_file=data_config.MYTHHOME+"/templates/nfsmap"
@@ -22,8 +24,15 @@ def setup_nfs_client(systemconfig,data_config):
nfsmap_file = download_nfsmap(systemconfig.get("dbhost"),nfsmap_serverfile)
nfslist = process_nfsmap_file(nfsmap_file)
+ #check for other filesname:
+
+ elif re.search("^file:",systemconfig.get("NFSserver")):
+ filename=systemconfig.get("NFSserver").split(":")[1]
+ nfsmap_file=data_config.MYTHHOME+"/templates/"+filename
+ nfslist = process_nfsmap_file(nfsmap_file)
+
# if it's an ip parse ip and download file
- elif re.search(systemconfig.get("NFSserver"),":nfsmap"):
+ elif re.search(":nfsmap$",systemconfig.get("NFSserver")):
ip=systemconfig.get("NFSserver").split(":")[0]
nfsmap_file = download_nfsmap(ip,nfsmap_serverfile)
nfslist = process_nfsmap_file(nfsmap_file)
@@ -41,8 +50,9 @@ def setup_nfs_client(systemconfig,data_config):
nfslist = process_nfsmap_file(nfsmap_file)
- setup_nfs_fstab(nfslist)
+ setup_nfs_fstab(nfslist,data_config)
logging.info("__End of nfs\n")
+ return nfslist
def process_nfsmap_file(mapfile):
@@ -102,20 +112,30 @@ def setup_nfs_mkdir(nfs_dirname):
-def setup_nfs_fstab(nfslist):
+
+
+def setup_nfs_fstab(nfslist,data_config):
logging.info(" Adding nfs paths to fstab")
+ nfs_options = mythhome = data_config.nfs_options
try:
f = open('/etc/fstab', 'a')
line = "#STARTSCRUB --------------anything in this block will be scrubbed\n"
f.write(line)
for s, m in nfslist:
- line = "%s %s nfs \n" %(s,m)
+ line = "%s %s nfs %s \n" %(s,m,nfs_options)
setup_nfs_mkdir(m)
logging.debug(" %s",line)
f.write(line)
line = "#ENDSCRUB\n"
f.write(line)
f.close()
+
+ for s, m in nfslist:
+ logging.info(" nfs mounting %s",m)
+ cmd = ['mount',m]
+ mv_common.runcmd_bg(cmd)
+
+
except:
logging.critical(" *Couldn't open /etc/fstab for writing")
logging.debug(" Done adding nfs paths to fstab")
@@ -257,7 +277,7 @@ create mask = 0755 ''' %(data_config.MYTHHOME,shreadonly)
mv_common.restart_service("smbd")
else:
- logging.info(" Removing windows file sharing")
+ logging.info(" Removing windows file sharing")
mv_common.remove_service("smbd")
mv_common.remove_service("nmbd")
mv_common.pacremove("samba")
@@ -284,7 +304,7 @@ def scan_for_shares():
return share_list
-def setup_etc_exports(shares,data_config,servername):
+def setup_etc_exports(shares,data_config,servername,nfslist):
#read in /etc/ exports
conf_file="/etc/exports"
excludes = data_config.share_exclude_dir
@@ -293,12 +313,18 @@ def setup_etc_exports(shares,data_config,servername):
#print nfsmap_auto_skip
nfs_auto_line ="%s:%s %s"
-
-
nfs_map_auto = []
-
share_list = []
+ #populate nfs_map_auto with nfs_list. nfs_list is populated from the
+ #central nfs options
+ #nfslist looks like [('silverraid:/raid0/data/media', '/data/storage/nfs/silverraid')]
+ for i in nfslist:
+ sharename = i[0]
+ mountpoint = i[1]
+ templine = "%s %s" %(sharename,mountpoint)
+ nfs_map_auto.append(templine)
+
#create the lists for both /etc/exports and nfs_map_auto
for share in shares:
@@ -326,9 +352,6 @@ def setup_etc_exports(shares,data_config,servername):
templine = nfs_auto_line %(servername,tempname,tempname)
nfs_map_auto.append(templine)
-
-
-
new_exports=[]
new_exports.append("#This file was generated by systemconfig.py -m fileshare")
new_exports.append("#Use exportfs -arv to reread. \n\n")
@@ -348,7 +371,19 @@ def setup_etc_exports(shares,data_config,servername):
logging.info(" writing nfsmap_auto")
try:
- os.makedirs("%s/templates/" %data_config.MYTHHOME)
+ dirname ="%s/templates/" %data_config.MYTHHOME
+ os.makedirs(dirname)
+ cmd = "chmod 755 %s" %dirname
+ mv_common.runcmd(cmd)
+ cmd = "chown mythtv:users %s" %dirname
+ mv_common.runcmd(cmd)
+ except:
+ pass
+ try:
+ cmd = "chmod 755 %s" %dirname
+ mv_common.runcmd(cmd)
+ cmd = "chown mythtv:users %s" %dirname
+ mv_common.runcmd(cmd)
except:
pass
conf_file_nfs = "%s/templates/nfsmap_auto" %(data_config.MYTHHOME)
@@ -359,7 +394,7 @@ def setup_etc_exports(shares,data_config,servername):
logging.debug("%s" %line)
f.close()
except:
- logging.info("* error writing /data/srv/htdocs/nfsmap_auto")
+ logging.info("* error writing %s" %conf_file_nfs)
try:
logging.info(" writing /etc/exports")
@@ -374,14 +409,13 @@ def setup_etc_exports(shares,data_config,servername):
-def setup_NFSshares(UseNFS,templatefile,data_config,servername):
+def setup_NFSshares(UseNFS,templatefile,data_config,servername,nfslist):
if UseNFS == "1":
logging.info(" Activating NFS server")
mv_common.pacinstall("nfs-utils")
mv_common.pacinstall("rpcbind")
shares = scan_for_shares()
- setup_etc_exports(shares,data_config,servername)
-
+ setup_etc_exports(shares,data_config,servername,nfslist)
mv_common.add_service("nfsd")
mv_common.add_service("nfs-common")
mv_common.add_service("rpcbind")
@@ -408,11 +442,20 @@ def setup_fileshare(systemconfig,data_config):
logging.info("____Skipping of fileshare, config disabled____")
return
logging.info("____Start of fileshare configuration____")
- #client
- setup_nfs_client(systemconfig,data_config)
+
+ #client, nfslist will be used in case the central NFS needs to also be addressed
+ nfslist = setup_nfs_client(systemconfig,data_config)
+
#server
+ if systemconfig.get("CentralNFSallhosts") == "0":
+ #reset nfslist to 0 so that central nfsshares do not get added to auto_nfs
+ nfslist = []
+
setup_NFSshares(systemconfig.get("UseNFS"),
- systemconfig.get("TEMPLATES")+"/exports.template",data_config,systemconfig.get("hostname"))
+ systemconfig.get("TEMPLATES")+"/exports.template",
+ data_config,systemconfig.get("hostname"),
+ nfslist)
+
setup_samba(systemconfig,data_config)
logging.info("__End of fileshare configuration\n")