summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_advanced.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-09-02 01:07:56 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-09-02 01:07:56 (GMT)
commite98d93babfa1fc1d248e2433e566329fe5a92ff0 (patch)
tree1b2c65e2850424f2e545d02902c50689ab4d6f62 /abs/core/LinHES-config/mv_advanced.py
parent9aa30f297ad0cb6dbc9c9b2f1bcc1c89ff0a5db6 (diff)
downloadlinhes_pkgbuild-e98d93babfa1fc1d248e2433e566329fe5a92ff0.zip
linhes_pkgbuild-e98d93babfa1fc1d248e2433e566329fe5a92ff0.tar.gz
linhes_pkgbuild-e98d93babfa1fc1d248e2433e566329fe5a92ff0.tar.bz2
LinHES-config: moved config of file shares to it's own modules.
Diffstat (limited to 'abs/core/LinHES-config/mv_advanced.py')
-rwxr-xr-xabs/core/LinHES-config/mv_advanced.py205
1 files changed, 0 insertions, 205 deletions
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")