diff options
Diffstat (limited to 'abs/core/LinHES-config/mv_advanced.py')
-rwxr-xr-x | abs/core/LinHES-config/mv_advanced.py | 181 |
1 files changed, 26 insertions, 155 deletions
diff --git a/abs/core/LinHES-config/mv_advanced.py b/abs/core/LinHES-config/mv_advanced.py index fdcd1e2..de10d78 100755 --- a/abs/core/LinHES-config/mv_advanced.py +++ b/abs/core/LinHES-config/mv_advanced.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import logging, os, re import mv_common +import glob def setup_pacman(create_link): if create_link: @@ -84,20 +85,27 @@ def setup_ncid_daemon(Runncidd): def setup_splash(Usebootsplash): if Usebootsplash == "1": logging.info(" Enabling splash") - cmd = ''' sed -i "s/^default.*0/default 1/g" /boot/grub/menu.lst''' + cmd = ''' sed -i "s/^set default.*$/set default="0"/g" /boot/grub/grub.cfg''' + mv_common.runcmd(cmd) + #this is needed in case grub-mkconfig is run + cmd = ''' sed -i "s/^GRUB_DEFAULT.*$/GRUB_DEFAULT="0"/g" /etc/default/grub''' mv_common.runcmd(cmd) else: logging.info(" Disabling splash") - cmd = ''' sed -i "s/^default.*1/default 0/g" /boot/grub/menu.lst''' + cmd = ''' sed -i "s/^set default.*$/set default="1"/g" /boot/grub/grub.cfg''' + mv_common.runcmd(cmd) + #this is needed in case grub-mkconfig is run + cmd = ''' sed -i "s/^GRUB_DEFAULT.*$/GRUB_DEFAULT="1"/g" /etc/default/grub''' mv_common.runcmd(cmd) return -def setup_rrd(UseRRD): - if UseRRD == "1": - logging.info(" Enabling rrd_stats") - mv_common.pacinstall("rrd_stats") - else: - logging.info(" Disabling rrd_stats") - mv_common.pacremove("rrd_stats") + +#def setup_rrd(UseRRD): + #if UseRRD == "1": + #logging.info(" Enabling rrd_stats") + #mv_common.pacinstall("rrd_stats") + #else: + #logging.info(" Disabling rrd_stats") + #mv_common.pacremove("rrd_stats") def setup_hobbit(UseHobbit,SystemType,dbhost): @@ -227,141 +235,7 @@ def setup_mythweb(UseMythWEB): logging.info(" Removing mythweb") # mv_common.pacremove("lighttpd") mv_common.pacremove("mythweb") - # mv_common.remove_service("lighttpd") - return - -def setup_samba(systemconfig,data_config): - mythhome = data_config.MYTHHOME - 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 - medialines=''' -[%s] -path = %s -public = yes -only guest = yes -writeable = %s -printable = no -force user = mythtv -force group = mythtv -create mask = 0755''' %(data_config.SMEDIA,data_config.DATAMOUNT,smreadonly) - f.write(medialines) - f.close - logging.debug(" %s",medialines) - 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 setup_NFSshares(UseNFS,templatefile): - if UseNFS == "1": - logging.info(" Activating NFS server") - mv_common.pacinstall("nfs-utils") - mv_common.pacinstall("rpcbind") - cmd = '''sed -e "s/REPLACEME/*/g" %s >/etc/exports''' %templatefile - mv_common.runcmd(cmd) - 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") +# mv_common.remove_service("lighttpd") return def setup_dyndns(DDnsEnable): @@ -398,22 +272,19 @@ def setup_advanced(systemconfig,data_config): setup_hobbit(systemconfig.get("UseHobbit"), systemconfig.get("SystemType"), systemconfig.get("dbhost")) - if data_config.SYSTEMTYPE == "LinHES": - setup_rrd(systemconfig.get("UseRRD")) + #if data_config.SYSTEMTYPE == "LinHES": + #setup_rrd(systemconfig.get("UseRRD")) - setup_evrouter(systemconfig.get("UseEvrouter"), - systemconfig.get("EvrouterConfig"), - systemconfig.get("TEMPLATES")) + #setup_evrouter(systemconfig.get("UseEvrouter"), + #systemconfig.get("EvrouterConfig"), + #systemconfig.get("TEMPLATES")) setup_DNSmasq(systemconfig.get("RunDHCP"), - systemconfig.get("mythip"), - systemconfig.get("mythgw"), - systemconfig.get("mythdns")) + systemconfig.get("mythip"), + systemconfig.get("mythgw"), + systemconfig.get("mythdns")) setup_mythweb(systemconfig.get("UseMythWEB")) - setup_samba(systemconfig,data_config) - setup_NFSshares(systemconfig.get("UseNFS"), - systemconfig.get("TEMPLATES")+"/exports.template") setup_dyndns(systemconfig.get("DDnsEnable")) logging.info("__End of advanced configuration\n") |