From e98d93babfa1fc1d248e2433e566329fe5a92ff0 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 1 Sep 2012 20:07:56 -0500
Subject: LinHES-config: moved config of file shares to it's own modules.

---
 abs/core/LinHES-config/PKGBUILD        |  15 +-
 abs/core/LinHES-config/mv_advanced.py  | 205 --------------------
 abs/core/LinHES-config/mv_config.py    |  12 +-
 abs/core/LinHES-config/mv_fileshare.py | 334 +++++++++++++++++++++++++++++++++
 abs/core/LinHES-config/mv_misc.py      |  96 +---------
 abs/core/LinHES-config/mythvantage.cfg |   1 +
 abs/core/LinHES-config/systemconfig.py |  15 +-
 7 files changed, 366 insertions(+), 312 deletions(-)
 create mode 100755 abs/core/LinHES-config/mv_fileshare.py

diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index f5372aa..62a0dd2 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.3
-pkgrel=108
+pkgrel=111
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config )
 pkgdesc="Install and configure your system"
 depends=('bc' 'libstatgrab'  'mysql-python' 'expect' 'curl' 'dnsutils' 'parted'
@@ -44,6 +44,7 @@ source=(mv_install.py 09_mythvantge_runit_grub
 	mv_hostype.py
 	mv_supplemental.py
 	mv_vnc.py
+	mv_fileshare.py
     systemconfig.py
 	myth_user_call.py
 	mythvantage.cfg
@@ -97,6 +98,7 @@ build() {
     install -m 0755 mv_hostype.py $MVDIR/bin/
     install -m 0755 mv_supplemental.py $MVDIR/bin/
     install -m 0755 mv_vnc.py $MVDIR/bin/
+    install -m 0755 mv_fileshare.py $MVDIR/bin/
     install -m 0755 systemconfig.py $MVDIR/bin/
     install -m 0755 print_xorg_res.py $MVDIR/bin/
     install -m 0755 backend_control.sh $MVDIR/bin/
@@ -125,7 +127,7 @@ build() {
 }
 md5sums=('666cacc9fc81a2c3d7f0175dfd6afd96'
          'f33e1a6f7985091b8d47cbaf7433f90f'
-         'c5bca0a2333608391628a0b67b486e5c'
+         '88d0d57a5d2acaf9c0456c38218e513f'
          '2596460462cf6c889cf8f95485537b20'
          '985891a43f7c4c983eb2a362162f1a0f'
          '5e019ede24323a77f8d3812a93d38075'
@@ -145,11 +147,11 @@ md5sums=('666cacc9fc81a2c3d7f0175dfd6afd96'
          '9151c74fcaf18ec4cf5e757cfdbc7017'
          '3d1e4a119f38cff0498bf8a67e94e4b3'
          '71fd2d0d448fc2fcd15415a1beed7109'
-         '58fe4ac269ca45a08028786fc0a5f5bc'
+         'af6b3c5ec0d974b3e19ff1ed50662ee5'
          '65c2dad8748210c3c0098efab377c330'
          'b845de3e05c1734cce4b9ac5e8f1baaf'
          'e869e2c72212881db1e4fa40b116efe5'
-         'eaf5b9bab2a52beb8ad5ca6f0f56026d'
+         '8b7dce4a3a0a281fa6656aa8781a648e'
          '2934fd80277e4598856f3171ccef9bfd'
          '824e49d9b01fed295c704ab68908b464'
          'fe5e31b833cc6707209e9d656b6eb53c'
@@ -158,9 +160,10 @@ md5sums=('666cacc9fc81a2c3d7f0175dfd6afd96'
          'cc5ee06e2182bb825ca3712a1c1afb64'
          '919909f4d23b9ee3caf71193c042cc40'
          'f15bce124e586b8e279c2f61a8e9b5fc'
-         '0dd5a895022a81aa2f87d761d3f43a87'
+         'd81d7ee9996e61ec859f3338ee10fce8'
+         '419a2eaa52b8639da1076828a85bf355'
          '2596460462cf6c889cf8f95485537b20'
-         '2bfa69776f57b459e690094dd249e863'
+         '4cba2bb55c6b8e27c57a6171f42d0455'
          '4804aa93aaad3dfcfff08cd9ffd68836'
          '0fa6fffd87f350380d45f1f8a5b7babe'
          '6ec39b010c0ed8901ea896c7e153d330'
diff --git a/abs/core/LinHES-config/mv_advanced.py b/abs/core/LinHES-config/mv_advanced.py
index c90a1eb..8ed216e 100755
--- a/abs/core/LinHES-config/mv_advanced.py
+++ b/abs/core/LinHES-config/mv_advanced.py
@@ -238,208 +238,6 @@ def setup_mythweb(UseMythWEB):
 #       mv_common.remove_service("lighttpd")
     return
 
-def setup_samba(systemconfig,data_config):
-    mythhome = data_config.MYTHHOME
-    excludes = data_config.share_exclude_dir
-    if systemconfig.get("UseSamba") == "1":
-        logging.info("    Activating windows file sharing")
-        usersamba=mythhome+"/templates/smb.conf"
-        mv_common.pacinstall("samba")
-        if not os.path.exists("/etc/samba"):
-            logging.debug("    Creating directory /etc/samba")
-            try:
-                os.makedirs("/etc/samba")
-            except:
-                pass
-
-        if os.path.exists(usersamba):
-            logging.debug("    Using user provided config file %s",usersamba)
-            cmd = "install -D -m755  %s /etc/samba/smb.conf" %usersamba
-            mv_common.runcmd(cmd)
-        else:
-            Samba_media = systemconfig.get("Samba_media")
-            Samba_home = systemconfig.get("Samba_home")
-            if systemconfig.get("Samba_mediareadonly") == "0":
-                smreadonly = "yes"
-            else:
-                smreadonly = "no"
-
-            if systemconfig.get("Samba_homereadonly") == "0":
-                shreadonly = "yes"
-            else:
-                shreadonly = "no"
-            domain = systemconfig.get("Samba_domain")
-            servername = systemconfig.get("hostname")
-
-            try:
-                f = open(systemconfig.get("TEMPLATES")+"/samba/smb.conf.template",'r')
-                t_smbconf = f.readlines()
-                f.close()
-            except:
-                logging.info("   Couldn't open samba template file")
-                return
-
-            try:
-                f = open("/etc/samba/smb.conf",'w')
-            except:
-                logging.info("   Couldn't open samba file")
-                return
-
-            for line in t_smbconf:
-                outline = line
-                if re.match("^.*workgroup", line):
-                    logging.debug("    Setting workgroup to %s",domain)
-                    outline="workgroup = %s\n" %domain
-                    logging.debug("     %s",outline)
-                if re.match("^.* server string",line):
-                    logging.debug("    Setting server name to %s",servername)
-                    outline="server string = %s\n" %servername
-                    logging.debug("     %s",outline)
-                f.write(outline)
-
-            outline="include =  %s/templates/user.shares \n" %mythhome
-            f.write(outline)
-            if Samba_media == "1":
-                outline="include =  /etc/samba/smb.conf.media\n"
-                f.write(outline)
-            if Samba_home == "1":
-                outline="include =  /etc/samba/smb.conf.home\n"
-                f.write(outline)
-            f.close()
-
-            logging.info("    Writing smb.conf.media")
-            try:
-                f = open("/etc/samba/smb.conf.media","w")
-            except:
-                logging.info("*   Couldn't open smb.conf.media")
-                return
-
-            shares = scan_for_shares()
-            medialines='''
-[%s]
-    path = %s
-    public = yes
-    only guest = yes
-    writeable  = %s
-    printable = no
-    force user = mythtv
-    force group = mythtv
-    create mask = 0755\n'''
-            new_share=[]
-            excludes
-            for share in shares:
-                share_name = share.split("/")[-1]
-                share_path = share
-                #new_share.append(medialines %(share_name,share_patch,smreadonly)
-                f.write(medialines %(share_name,share_path,smreadonly) )
-                logging.debug("     %s",medialines %(share_name,share_path,smreadonly) )
-                excludeline = '    veto files = '
-                for exclude in excludes:
-                    excludeline+= ''' "/%s/" ''' %exclude
-
-                if excludes != []:
-                    f.write( excludeline)
-                    logging.debug(excludeline)
-                    f.write("\n")
-
-            f.close()
-            logging.info("    Writing smb.conf.home")
-            try:
-                    f = open("/etc/samba/smb.conf.home","w")
-            except:
-                logging.info("    Couldn't open smb.conf.home")
-                return
-            homelines='''
-[home]
-path = %s
-public = yes
-only guest = yes
-writeable  = %s
-printable = no
-force user = mythtv
-force group = mythtv
-create mask = 0755 ''' %(data_config.MYTHHOME,shreadonly)
-            f.write(homelines)
-            f.close()
-            logging.debug("     %s",homelines)
-
-
-        mv_common.add_service("nmbd")
-        mv_common.add_service("smbd")
-        mv_common.restart_service("nmbd")
-        mv_common.restart_service("smbd")
-
-    else:
-        logging.info("  Removing windows file sharing")
-        mv_common.remove_service("smbd")
-        mv_common.remove_service("nmbd")
-        mv_common.pacremove("samba")
-        mv_common.pacinstall("smbclient")
-    return
-
-def scan_for_shares():
-    import ConfigParser
-    config = ConfigParser.RawConfigParser()
-    file_list=glob.glob("/etc/storage.d/*.conf")
-    share_list = []
-    for conf_file in file_list:
-        try:
-            logging.debug("    mv_advanced: reading in %s" %conf_file)
-            config.read(conf_file)
-            shareable = config.get('storage','shareable')
-            if shareable == "True" :
-                mp = config.get('storage','mountpoint')
-                share_list.append(mp)
-                if config.get('storage','mmount') == "True" :
-                    share_list.append("/myth")
-        except:
-            logging.debug("    mv_advanced: Couldn't open %s for reading" %conf_file)
-
-    return share_list
-
-def setup_etc_exports(shares,data_config):
-    #read in /etc/ exports
-    conf_file="/etc/exports"
-    excludes = data_config.share_exclude_dir
-    new_exports=[]
-    new_exports.append("#This file was generated by systemconfig.py -m advanced")
-    new_exports.append("#Use exportfs -arv to reread. \n\n")
-
-    for share in shares:
-        share_line='''%s   *(rw,all_squash,anonuid=1000,anongid=1000,no_subtree_check)''' %share
-        new_exports.append(share_line)
-        for exclude in excludes:
-            share_line='''/%s   *(noaccess)''' %exclude
-            new_exports.append(share_line)
-    try:
-        logging.info("    writing /etc/exports")
-        f=open(conf_file,'w')
-        for line in new_exports:
-            f.write(line)
-            f.write("\n")
-            logging.debug("%s" %line)
-        f.close()
-    except:
-        logging.info("*   error writing /etc/exports")
-
-
-
-def setup_NFSshares(UseNFS,templatefile,data_config):
-    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)
-
-        mv_common.add_service("nfsd")
-        mv_common.add_service("nfs-common")
-        mv_common.add_service("rpcbind")
-    else:
-        logging.info("    Removing NFS server")
-        mv_common.remove_service("nfsd")
-    return
-
 def setup_dyndns(DDnsEnable):
     if DDnsEnable == "1":
         logging.info("    Installing Dynamic DNS client")
@@ -487,9 +285,6 @@ def setup_advanced(systemconfig,data_config):
                 systemconfig.get("mythdns"))
 
     setup_mythweb(systemconfig.get("UseMythWEB"))
-    setup_samba(systemconfig,data_config)
-    setup_NFSshares(systemconfig.get("UseNFS"),
-                systemconfig.get("TEMPLATES")+"/exports.template",data_config)
 
     setup_dyndns(systemconfig.get("DDnsEnable"))
     logging.info("__End of advanced configuration\n")
diff --git a/abs/core/LinHES-config/mv_config.py b/abs/core/LinHES-config/mv_config.py
index af57b8e..32ede47 100755
--- a/abs/core/LinHES-config/mv_config.py
+++ b/abs/core/LinHES-config/mv_config.py
@@ -2,11 +2,15 @@
 SYSTEMTYPE="LinHES"
 MVHOSTNAME="apheleia"
 MOUNTPOINT="/new_boot"
-DATAMOUNT="/myth"
+DATAMOUNT="/data/storage/disk0"
+MYTHHOME="/home/mythtv"
+VNCHOME="/home/vncsvc"
+NOOPDEBUG="FALSE"
+TEMP_TEMPLATES="/tmp/templates"
+share_exclude_dir=['mysql','srv']
+
 
-MYTHHOME="/storage/data/home/mythtv"
 
-VNCHOME="/home/vncsvc"
 SQUASHFILE="/tmp/.squashlist"
 SQUASHLIST=("bin","boot","etc","home","lib","opt","root","sbin","usr","var","data","service")
 NOOPDEBUG="FALSE"
@@ -14,7 +18,7 @@ BACKUPFILE="mythconverg.sql.gz"
 BACKUPPATH="/myth/backup/"
 TEMP_TEMPLATES="/tmp/templates"
 SMEDIA="myth"
-share_exclude_dir=['mysql','srv']
+
 
 
 
diff --git a/abs/core/LinHES-config/mv_fileshare.py b/abs/core/LinHES-config/mv_fileshare.py
new file mode 100755
index 0000000..06f3091
--- /dev/null
+++ b/abs/core/LinHES-config/mv_fileshare.py
@@ -0,0 +1,334 @@
+# -*- coding: utf-8 -*-
+import logging, os, re
+import mv_common
+import glob
+#client side
+
+def setup_nfs_client(systemconfig):
+    nfslist=[]
+    logging.info("____Start of setup_nfs__client____")
+    scrubnfs(systemconfig.get("TEMPLATES"))
+
+    if systemconfig.get("HaveCentralNFS") == "yes":
+        logging.debug("    Using a Central NFS server")
+        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"
+            if not os.path.exists(nfsmap_file):
+                logging.debug("    Couldn't find local %s",nfsmap_file)
+                logging.info("    Trying to download nfsmap from MBE")
+                nfsmap_file = download_nfsmap(systemconfig.get("dbhost"))
+            nfslist = process_nfsmap_file(nfsmap_file)
+        # if it's an ip  parse ip and download file
+        elif re.search(systemconfig.get("NFSserver"),":nfsmap"):
+            ip=systemconfig.get("NFSserver").split(":")[0]
+            nfsmap_file = download_nfsmap(ip)
+            nfslist = process_nfsmap_file(nfsmap_file)
+        #else treat it as a single mount point
+        else:
+            item = (systemconfig.get("NFSserver") , systemconfig["NFSmount"])
+            nfslist.append(item)
+    else:
+        #if standalone or slave try to use MBE
+        if systemconfig.get("SystemType") == "Frontend_only" or systemconfig["SystemType"] == "Slave_Backend":
+            item = (systemconfig.get("dbhost")+":"+ data_config.DATAMOUNT, data_config.DATAMOUNT)
+            nfslist.append(item)
+    setup_nfs_fstab(nfslist)
+    logging.info("__End of nfs\n")
+
+
+def process_nfsmap_file(mapfile):
+    logging.debug("   processing nfsmap file %s",mapfile)
+    nfslist = []
+    try:
+        f = open(mapfile,"r")
+        for line in f.readlines():
+            if line.startswith("#"):
+                continue
+            item = line.split()
+            if len(item) <= 1 :
+                continue
+            logging.debug("    %s",item)
+            nfslist.append(item)
+    except :
+        logging.critical("Couldn't read file %s, or some other error",mapfile)
+    return nfslist
+
+def scrubnfs(templates):
+    logging.info("    Scrubbing nfs")
+    mv_common.cp_and_log("/etc/fstab",templates+"/fstab.conf.template")
+    #used this sed cmd because it's clean and took me forever to figure out =)
+    cmd='''sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' %s/fstab.conf.template > /etc/fstab''' %templates
+    mv_common.runcmd(cmd)
+
+def download_nfsmap(ip):
+    nfsmap_file="/tmp/nfsmap"
+    myurl="http://%s:1337/templates/nfsmap" %ip
+    req = Request(myurl)
+    try:
+        f = urlopen(req)
+        logging.info("    downloading %s", myurl)
+        local_file = open(nfsmap_file, "w")
+        #Write to our local file
+        local_file.write(f.read())
+        local_file.close()
+    #handle errors
+    except HTTPError, e:
+        logging.info("    File download failed")
+        logging.debug("    %s", myurl)
+        logging.debug("   HTTP Error: %s", e.code)
+    except URLError, e:
+        logging.info("    File download failed")
+        logging.debug("   %s",myurl)
+        logging.debug("   URL Error: %s ", e.reason)
+
+    return nfsmap_file
+
+def setup_nfs_fstab(nfslist):
+    logging.info("    Adding nfs paths to fstab")
+    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)
+            logging.debug("    %s",line)
+            f.write(line)
+        line = "#ENDSCRUB\n"
+        f.write(line)
+        f.close()
+    except:
+        logging.critical("    *Couldn't open /etc/fstab for writing")
+    logging.debug("   Done adding nfs paths to fstab")
+
+
+
+
+
+#server side
+def setup_samba(systemconfig,data_config):
+    mythhome = data_config.MYTHHOME
+    excludes = data_config.share_exclude_dir
+    if systemconfig.get("UseSamba") == "1":
+        logging.info("    Activating windows file sharing")
+        usersamba=mythhome+"/templates/smb.conf"
+        mv_common.pacinstall("samba")
+        if not os.path.exists("/etc/samba"):
+            logging.debug("    Creating directory /etc/samba")
+            try:
+                os.makedirs("/etc/samba")
+            except:
+                pass
+
+        if os.path.exists(usersamba):
+            logging.debug("    Using user provided config file %s",usersamba)
+            cmd = "install -D -m755  %s /etc/samba/smb.conf" %usersamba
+            mv_common.runcmd(cmd)
+        else:
+            Samba_media = systemconfig.get("Samba_media")
+            Samba_home = systemconfig.get("Samba_home")
+            if systemconfig.get("Samba_mediareadonly") == "0":
+                smreadonly = "yes"
+            else:
+                smreadonly = "no"
+
+            if systemconfig.get("Samba_homereadonly") == "0":
+                shreadonly = "yes"
+            else:
+                shreadonly = "no"
+            domain = systemconfig.get("Samba_domain")
+            servername = systemconfig.get("hostname")
+
+            try:
+                f = open(systemconfig.get("TEMPLATES")+"/samba/smb.conf.template",'r')
+                t_smbconf = f.readlines()
+                f.close()
+            except:
+                logging.info("   Couldn't open samba template file")
+                return
+
+            try:
+                f = open("/etc/samba/smb.conf",'w')
+            except:
+                logging.info("   Couldn't open samba file")
+                return
+
+            for line in t_smbconf:
+                outline = line
+                if re.match("^.*workgroup", line):
+                    logging.debug("    Setting workgroup to %s",domain)
+                    outline="workgroup = %s\n" %domain
+                    logging.debug("     %s",outline)
+                if re.match("^.* server string",line):
+                    logging.debug("    Setting server name to %s",servername)
+                    outline="server string = %s\n" %servername
+                    logging.debug("     %s",outline)
+                f.write(outline)
+
+            outline="include =  %s/templates/user.shares \n" %mythhome
+            f.write(outline)
+            if Samba_media == "1":
+                outline="include =  /etc/samba/smb.conf.media\n"
+                f.write(outline)
+            if Samba_home == "1":
+                outline="include =  /etc/samba/smb.conf.home\n"
+                f.write(outline)
+            f.close()
+
+            logging.info("    Writing smb.conf.media")
+            try:
+                f = open("/etc/samba/smb.conf.media","w")
+            except:
+                logging.info("*   Couldn't open smb.conf.media")
+                return
+
+            shares = scan_for_shares()
+            medialines='''
+[%s]
+    path = %s
+    public = yes
+    only guest = yes
+    writeable  = %s
+    printable = no
+    force user = mythtv
+    force group = mythtv
+    create mask = 0755\n'''
+            new_share=[]
+            excludes
+            for share in shares:
+                share_name = share.split("/")[-1]
+                share_path = share
+                #new_share.append(medialines %(share_name,share_patch,smreadonly)
+                f.write(medialines %(share_name,share_path,smreadonly) )
+                logging.debug("     %s",medialines %(share_name,share_path,smreadonly) )
+                excludeline = '    veto files = '
+                for exclude in excludes:
+                    excludeline+= ''' "/%s/" ''' %exclude
+
+                if excludes != []:
+                    f.write( excludeline)
+                    logging.debug(excludeline)
+                    f.write("\n")
+
+            f.close()
+            logging.info("    Writing smb.conf.home")
+            try:
+                    f = open("/etc/samba/smb.conf.home","w")
+            except:
+                logging.info("    Couldn't open smb.conf.home")
+                return
+            homelines='''
+[home]
+path = %s
+public = yes
+only guest = yes
+writeable  = %s
+printable = no
+force user = mythtv
+force group = mythtv
+create mask = 0755 ''' %(data_config.MYTHHOME,shreadonly)
+            f.write(homelines)
+            f.close()
+            logging.debug("     %s",homelines)
+
+
+        mv_common.add_service("nmbd")
+        mv_common.add_service("smbd")
+        mv_common.restart_service("nmbd")
+        mv_common.restart_service("smbd")
+
+    else:
+        logging.info("  Removing windows file sharing")
+        mv_common.remove_service("smbd")
+        mv_common.remove_service("nmbd")
+        mv_common.pacremove("samba")
+        mv_common.pacinstall("smbclient")
+    return
+
+def scan_for_shares():
+    import ConfigParser
+    config = ConfigParser.RawConfigParser()
+    file_list=glob.glob("/etc/storage.d/*.conf")
+    share_list = []
+    for conf_file in file_list:
+        try:
+            logging.debug("    mv_advanced: reading in %s" %conf_file)
+            config.read(conf_file)
+            shareable = config.get('storage','shareable')
+            if shareable == "True" :
+                mp = config.get('storage','mountpoint')
+                share_list.append(mp)
+                if config.get('storage','mmount') == "True" :
+                    share_list.append("/myth")
+        except:
+            logging.debug("    mv_advanced: Couldn't open %s for reading" %conf_file)
+
+    return share_list
+
+def setup_etc_exports(shares,data_config):
+    #read in /etc/ exports
+    conf_file="/etc/exports"
+    excludes = data_config.share_exclude_dir
+    new_exports=[]
+    new_exports.append("#This file was generated by systemconfig.py -m advanced")
+    new_exports.append("#Use exportfs -arv to reread. \n\n")
+
+    for share in shares:
+        share_line='''%s   *(rw,all_squash,anonuid=1000,anongid=1000,no_subtree_check)''' %share
+        new_exports.append(share_line)
+        for exclude in excludes:
+            share_line='''/%s   *(noaccess)''' %exclude
+            new_exports.append(share_line)
+    try:
+        logging.info("    writing /etc/exports")
+        f=open(conf_file,'w')
+        for line in new_exports:
+            f.write(line)
+            f.write("\n")
+            logging.debug("%s" %line)
+        f.close()
+    except:
+        logging.info("*   error writing /etc/exports")
+
+
+
+def setup_NFSshares(UseNFS,templatefile,data_config):
+    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)
+
+        mv_common.add_service("nfsd")
+        mv_common.add_service("nfs-common")
+        mv_common.add_service("rpcbind")
+    else:
+        logging.info("    Removing NFS server")
+        mv_common.remove_service("nfsd")
+    return
+
+def setup_dyndns(DDnsEnable):
+    if DDnsEnable == "1":
+        logging.info("    Installing Dynamic DNS client")
+        mv_common.pacinstall("inadyn")
+        mv_common.add_service("inadyn")
+    else:
+        logging.info("    Removing Dynamic DNS client")
+        mv_common.pacremove("inadyn")
+        mv_common.remove_service("inadyn")
+
+
+def setup_fileshare(systemconfig,data_config):
+    if  mv_common.read_config(mv_common.module_config,"fileshare")  == False  :
+        logging.info("____Skipping of fileshare, config disabled____")
+        return
+    logging.info("____Start of fileshare configuration____")
+    #client
+    setup_nfs_client(systemconfig)
+    #server
+    setup_NFSshares(systemconfig.get("UseNFS"),
+                    systemconfig.get("TEMPLATES")+"/exports.template",data_config)
+    setup_samba(systemconfig,data_config)
+
+    logging.info("__End of advanced configuration\n")
diff --git a/abs/core/LinHES-config/mv_misc.py b/abs/core/LinHES-config/mv_misc.py
index 587295f..d03bdca 100755
--- a/abs/core/LinHES-config/mv_misc.py
+++ b/abs/core/LinHES-config/mv_misc.py
@@ -56,37 +56,7 @@ def setup_tz(timezone,TEMPLATES):
     #mv_common.cp_and_log(TEMPLATES+"/rc.conf","/etc/rc.conf")
     logging.info("__End of timezone\n")
 
-def setup_nfs(systemconfig):
-    nfslist=[]
-    logging.info("____Start of setup_nfs____")
-    scrubnfs(systemconfig.get("TEMPLATES"))
-
-    if systemconfig.get("HaveCentralNFS") == "yes":
-        logging.debug("    Using a Central NFS server")
-        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"
-            if not os.path.exists(nfsmap_file):
-                logging.debug("    Couldn't find local %s",nfsmap_file)
-                logging.info("    Trying to download nfsmap from MBE")
-                nfsmap_file = download_nfsmap(systemconfig.get("dbhost"))
-            nfslist = process_nfsmap_file(nfsmap_file)
-        # if it's an ip  parse ip and download file
-        elif re.search(systemconfig.get("NFSserver"),":nfsmap"):
-            ip=systemconfig.get("NFSserver").split(":")[0]
-            nfsmap_file = download_nfsmap(ip)
-            nfslist = process_nfsmap_file(nfsmap_file)
-        #else treat it as a single mount point
-        else:
-            item = (systemconfig.get("NFSserver") , systemconfig["NFSmount"])
-            nfslist.append(item)
-    else:
-        #if standalone or slave try to use MBE
-        if systemconfig.get("SystemType") == "Frontend_only" or systemconfig["SystemType"] == "Slave_Backend":
-            item = (systemconfig.get("dbhost")+":"+ data_config.DATAMOUNT, data_config.DATAMOUNT)
-            nfslist.append(item)
-    setup_nfs_fstab(nfslist)
-    logging.info("__End of nfs\n")
+
 
 def setup_sleep(systemconfig):
     logging.debug("____Setting up sleep____")
@@ -115,67 +85,3 @@ def setup_sleep(systemconfig):
     logging.debug("__End of  sleep\n")
 
 
-def process_nfsmap_file(mapfile):
-    logging.debug("   processing nfsmap file %s",mapfile)
-    nfslist = []
-    try:
-        f = open(mapfile,"r")
-        for line in f.readlines():
-            if line.startswith("#"):
-                continue
-            item = line.split()
-            if len(item) <= 1 :
-                continue
-            logging.debug("    %s",item)
-            nfslist.append(item)
-    except :
-        logging.critical("Couldn't read file %s, or some other error",mapfile)
-    return nfslist
-
-def scrubnfs(templates):
-    logging.info("    Scrubbing nfs")
-    mv_common.cp_and_log("/etc/fstab",templates+"/fstab.conf.template")
-    #used this sed cmd because it's clean and took me forever to figure out =)
-    cmd='''sed '/^#STARTSCRUB.*$/,/^#ENDSCRUB.*$/d' %s/fstab.conf.template > /etc/fstab''' %templates
-    mv_common.runcmd(cmd)
-
-def download_nfsmap(ip):
-    nfsmap_file="/tmp/nfsmap"
-    myurl="http://%s:1337/templates/nfsmap" %ip
-    req = Request(myurl)
-    try:
-        f = urlopen(req)
-        logging.info("    downloading %s", myurl)
-        local_file = open(nfsmap_file, "w")
-        #Write to our local file
-        local_file.write(f.read())
-        local_file.close()
-    #handle errors
-    except HTTPError, e:
-        logging.info("    File download failed")
-        logging.debug("    %s", myurl)
-        logging.debug("   HTTP Error: %s", e.code)
-    except URLError, e:
-        logging.info("    File download failed")
-        logging.debug("   %s",myurl)
-        logging.debug("   URL Error: %s ", e.reason)
-
-    return nfsmap_file
-
-def setup_nfs_fstab(nfslist):
-    logging.info("    Adding nfs paths to fstab")
-    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)
-            logging.debug("    %s",line)
-            f.write(line)
-        line = "#ENDSCRUB\n"
-        f.write(line)
-        f.close()
-    except:
-        logging.critical("    *Couldn't open /etc/fstab for writing")
-    logging.debug("   Done adding nfs paths to fstab")
-
diff --git a/abs/core/LinHES-config/mythvantage.cfg b/abs/core/LinHES-config/mythvantage.cfg
index dda5ed5..8897724 100644
--- a/abs/core/LinHES-config/mythvantage.cfg
+++ b/abs/core/LinHES-config/mythvantage.cfg
@@ -19,4 +19,5 @@ user = True
 software = True
 smolt = True
 vnc = True
+fileshare = True
 
diff --git a/abs/core/LinHES-config/systemconfig.py b/abs/core/LinHES-config/systemconfig.py
index 8686841..d2596e7 100755
--- a/abs/core/LinHES-config/systemconfig.py
+++ b/abs/core/LinHES-config/systemconfig.py
@@ -74,7 +74,7 @@ def main(argv):
                "plugins":False, "smolt":False,
                "all":False, "dhcp_request":False ,
                "func":False, "supplemental":False,
-               "vnc":False }
+               "vnc":False, "fileshare":False }
     try:
         opts,  args = getopt.getopt(argv,  'c:hm:d:',  ["help","modules" ] )
     except getopt.GetoptError, why:
@@ -120,6 +120,12 @@ def main(argv):
         #cmdmodule["smolt"] = True
         cmdmodule["user"] = True
         cmdmodule["vnc"] = True
+        cmdmodule["fileshare"] = True
+
+    ##putting this here until I can create the seperate share module
+    #if cmdmodule["fileshare"]:
+        #cmdmodule["advanced"] = True
+        #cmdmodule["misc"] = True
 
     if cmdmodule["network"]:
         restartfe = mv_network.setup_network(systemconfig, cmdmodule["this_is_install"])
@@ -196,7 +202,7 @@ def main(argv):
 	    #zipcode is no longer used
             #mv_misc.setup_zip(MVROOT,systemconfig.get("zipcode"))
             mv_misc.setup_tz(systemconfig.get("timezone"),systemconfig["TEMPLATES"])
-            mv_misc.setup_nfs(systemconfig)
+            #mv_misc.setup_nfs(systemconfig)
 
     if cmdmodule["sleep"]:
         if  mv_common.read_config(mv_common.module_config,"sleep")  == False  :
@@ -221,6 +227,11 @@ def main(argv):
         import mv_advanced
         mv_advanced.setup_advanced(systemconfig, data_config)
 
+    if cmdmodule["fileshare"]:
+        import mv_fileshare
+        mv_fileshare.setup_fileshare(systemconfig, data_config)
+
+
     if cmdmodule["software"] or cmdmodule["plugins"]:
         import mv_software
         mv_software.setup_software(systemconfig, data_config)
-- 
cgit v0.12

