summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2009-05-09 19:46:39 (GMT)
committerJames Meyer <james.meyer@operamail.com>2009-05-09 19:46:39 (GMT)
commit6aec480f40e73de0b179d0a91aa484266190f52b (patch)
tree812008241c95a21acedb1f006a9b8b3bb4e1d2c9
parentd2558b37e5c93dff5ee88519d416686b9df1a40b (diff)
downloadlinhes_pkgbuild-6aec480f40e73de0b179d0a91aa484266190f52b.zip
linhes_pkgbuild-6aec480f40e73de0b179d0a91aa484266190f52b.tar.gz
linhes_pkgbuild-6aec480f40e73de0b179d0a91aa484266190f52b.tar.bz2
mv_install: white space cleanup
-rwxr-xr-xabs/core-testing/LinHES-config/PKGBUILD2
-rwxr-xr-xabs/core-testing/LinHES-config/mv_install.py623
2 files changed, 289 insertions, 336 deletions
diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index a85f158..0fc6ae9 100755
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
pkgname=LinHES-config
pkgver=1.0
-pkgrel=418
+pkgrel=419
conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
pkgdesc="Install and configure your system"
depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted )
diff --git a/abs/core-testing/LinHES-config/mv_install.py b/abs/core-testing/LinHES-config/mv_install.py
index 678cf3e..83563aa 100755
--- a/abs/core-testing/LinHES-config/mv_install.py
+++ b/abs/core-testing/LinHES-config/mv_install.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-import sys , os, commands , glob, time
-import getopt, re, MySQLdb
+import sys, os, commands, glob, time
+import getopt, re, MySQLdb
import logging
try:
import parted
@@ -15,27 +15,27 @@ def usage():
def clean_upgrade():
return False
-def update_db(value,data):
- db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
+def update_db(value, data):
+ db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
try:
cursor = db.cursor()
- cursor.execute("DELETE FROM settings where value=%s and hostname=%s;",(value,data_config.MVHOSTNAME))
- cursor.execute("REPLACE INTO settings set value=%s,data=%s,hostname=%s;" ,(value,data,data_config.MVHOSTNAME))
- logging.debug("Updated database with %s,%s",data,value)
- except MySQLdb.Error, e:
- logging.debug("Unable to update database with %s,%s",data,value)
+ cursor.execute("DELETE FROM settings where value=%s and hostname=%s;", (value, data_config.MVHOSTNAME))
+ cursor.execute("REPLACE INTO settings set value=%s, data=%s, hostname=%s;", (value, data, data_config.MVHOSTNAME))
+ logging.debug("Updated database with %s, %s", data, value)
+ except MySQLdb.Error, e:
+ logging.debug("Unable to update database with %s, %s", data, value)
def progress(pgnum):
progressline = str(pgnum) + "% complete"
- logging.debug("Progress: %s" , pgnum)
- f = open('/tmp/.install_percent', 'w')
+ logging.debug("Progress: %s", pgnum)
+ f = open('/tmp/.install_percent', 'w')
f.write(progressline)
f.close()
def update_status(status):
- logging.debug("Status: %s" , status)
- f = open('/tmp/.install_state', 'w')
+ logging.debug("Status: %s", status)
+ f = open('/tmp/.install_state', 'w')
f.write(str(status))
f.close()
@@ -46,9 +46,9 @@ def kill_dhcp_chroot():
try:
os.chdir(piddir)
for FILE in glob.glob("dhcpcd-*.pid"):
- f = open(FILE,'r')
+ f = open(FILE, 'r')
pid = f.readline()
- f.close
+ f.close()
cmd = "kill -9 %s" %pid
runcmd(cmd)
os.remove(FILE)
@@ -64,7 +64,7 @@ def statgrab(disk):
except:
prewritebytes = "1024"
outline = "STARTSIZE=%s" %prewritebytes
- f = open('/tmp/.startsize.io', 'w')
+ f = open('/tmp/.startsize.io', 'w')
f.write(str(outline))
f.close()
@@ -76,10 +76,10 @@ def backup_sql_check():
logging.debug("Backup file var is empty")
return False
if os.path.exists(data_config.MOUNTPOINT+hostoptions["backupfile"]):
- logging.debug("Backup file %s is present",data_config.MOUNTPOINT+hostoptions["backupfile"])
+ logging.debug("Backup file %s is present", data_config.MOUNTPOINT+hostoptions["backupfile"])
return True
else:
- logging.debug("Backup file %s is NOT present",data_config.MOUNTPOINT+hostoptions["backupfile"])
+ logging.debug("Backup file %s is NOT present", data_config.MOUNTPOINT+hostoptions["backupfile"])
return False
def mdadm_find(PREFIX):
@@ -88,7 +88,7 @@ def mdadm_find(PREFIX):
mdadmconf = "/etc/mdadm/mdadm.conf"
else:
mdadmconf = "/etc/mdadm.conf"
- logging.debug("Using %s for mdadm.conf",mdadmconf)
+ logging.debug("Using %s for mdadm.conf", mdadmconf)
return mdadmconf
def mdadm_assemble_all():
@@ -100,17 +100,17 @@ def mdadm_assemble_all():
runcmd(cmd)
mdadm_contents = ''
try:
- f = open(mdadmconf_file, 'r')
+ f = open(mdadmconf_file, 'r')
mdadm_contents = f.readlines()
f.close()
except:
logging.debug(" Couldn't open mdadmconf file")
for line in mdadm_contents:
if line.startswith("ARRAY"):
- logging.debug(" Found MD array: %s",line)
+ logging.debug(" Found MD array: %s", line)
array = line.split()[1]
- logging.info(" assembling array: %s",array)
- cmd = "mdadm --assemble -c /tmp%s %s" %(mdadmconf_file,array)
+ logging.info(" assembling array: %s", array)
+ cmd = "mdadm --assemble -c /tmp%s %s" %(mdadmconf_file, array)
runcmd(cmd)
time.sleep(2)
cmd = "fsck -p %s" %array
@@ -120,118 +120,71 @@ def copy_updates():
try:
MVROOT = os.environ["MV_ROOT"]
except:
- logging.debug("MVROOT was not defined, using the default value")
+ logging.debug("MVROOT was not defined, using the default value")
MVROOT = "/usr/MythVantage"
- cp_and_log2(MVROOT+"/bin/",data_config.MOUNTPOINT+MVROOT+"/bin","*.sh")
- cp_and_log2(MVROOT+"/bin/",data_config.MOUNTPOINT+MVROOT+"/bin","*.py")
+ cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin", "*.sh")
+ cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin", "*.py")
def timezone_to_db(timefile):
logging.info("importing timezone needs")
try:
f = open(timefile)
timezonecontents = f.readline().strip()
- f.close
+ f.close()
except:
logging.debug("Couldn't open /tmp/etc/timezone, will not set the timezone")
return
tzsplit = timezonecontents.partition('/')
print tzsplit
if tzsplit[2] == '' :
- update_db("HostTimeZoneRegion", tzsplit[0])
+ update_db("HostTimeZoneRegion", tzsplit[0])
else:
- update_db("HostTimeZoneRegion", tzsplit[0])
+ update_db("HostTimeZoneRegion", tzsplit[0])
tztemp="HostTimeZoneRegion_%s" % tzsplit[0]
- update_db(tztemp,tzsplit[2])
+ update_db(tztemp, tzsplit[2])
-def cp_and_log(srcfile,destfile):
+def cp_and_log(srcfile, destfile):
#return
if not os.path.exists(srcfile):
- logging.info("%s is not present, skipping...",srcfile)
+ logging.info("%s is not present, skipping...", srcfile)
else:
- cmd = ("rsync -arvp %s %s") %(srcfile,destfile)
+ cmd = ("rsync -arvp %s %s") %(srcfile, destfile)
runcmd(cmd)
- #if os.path.isdir(srcfile):
- #logging.info("Copying directory %s to %s",srcfile,destfile)
- #try:
- #shutil.copytree(srcfile,destfile)
- #except:
- #logging.debug("Couldn't copy directory %s using file by file", srcfile)
- #try:
- #stddir=os.getcwd()
- #os.chdir(srcfile)
- #for FILE in glob.glob("*"):
- #print FILE
- #shutil.copy2(FILE, destfile+"/"+FILE)
- #os.chdir(stddir)
- #except:
- #logging.info("Dir File by file failed: %s", srcfile)
-
- #elif os.path.isfile(srcfile):
- #logging.info("Copying File %s to %s",srcfile,destfile)
- #try:
- #shutil.copy(srcfile,destfile)
- #except:
- #logging.info("Couldn't copy file %s",srcfile)
- #else:
- #logging.debug("Src file is not a file or a directory")
-
-def cp_and_log2(srcfile,destfile,fileglob):
+
+def cp_and_log2(srcfile, destfile, fileglob):
#return
logging.debug("cp_and_log2")
- logging.debug("%s , %s , %s" ,srcfile ,destfile, fileglob)
+ logging.debug("%s, %s, %s", srcfile, destfile, fileglob)
if not os.path.exists(srcfile):
- logging.info("%s is not present, skipping...",srcfile)
+ logging.info("%s is not present, skipping...", srcfile)
else:
- if fileglob=='':
- cmd = ("rsync -arvp %s %s") %(srcfile,destfile)
+ if fileglob == '':
+ cmd = ("rsync -arvp %s %s") %(srcfile, destfile)
runcmd(cmd)
else:
fileglob = "*"
- cmd = ("rsync -arvp %s/%s %s") %(srcfile,fileglob,destfile)
+ cmd = ("rsync -arvp %s/%s %s") %(srcfile, fileglob, destfile)
runcmd(cmd)
- #if os.path.isdir(srcfile):
- #logging.info("Copying directory %s to %s",srcfile,destfile)
- #try:
- #shutil.copytree(srcfile,destfile)
- #except:
- #logging.debug("Couldn't copy directory %s using file by file", srcfile)
- #try:
- #stddir=os.getcwd()
- #os.chdir(srcfile)
- #for FILE in glob.glob(fileglob):
- #logging.debug("copying file %s to %s" ,FILE,destfile+FILE)
- #shutil.copy2(FILE, destfile+FILE)
- #os.chdir(stddir)
- #except:
- #logging.info("Dir File by file failed: %s", srcfile)
- #elif os.path.isfile(srcfile):
- #logging.info("Copying File %s to %s",srcfile,destfile)
- #try:
- #shutil.copy(srcfile,destfile)
- #except:
- #logging.info("Couldn't copy file %s",srcfile)
- #else:
- #logging.debug("Src file is not a file or a directory")
def runcmd(cmd):
- if data_config.NOOPDEBUG=="FALSE":
+ if data_config.NOOPDEBUG == "FALSE":
pass
else:
cmd = "echo "+cmd
- logging.debug(" %s",cmd)
+ logging.debug(" %s", cmd)
cmdout = commands.getoutput(cmd)
- logging.debug(" %s",cmdout)
+ logging.debug(" %s", cmdout)
return cmdout
-def mysqldb(cmd,inchroot):
- if cmd=="start":
+def mysqldb(cmd, inchroot):
+ if cmd == "start":
mycmd = " /etc/rc.d/mysqld start"
- elif cmd=="stop":
+ elif cmd == "stop":
mycmd = " /etc/rc.d/mysqld stop"
- if inchroot=="chroot":
+ if inchroot == "chroot":
mycmd = " chroot %s" %mycmd
runcmd(mycmd)
@@ -255,21 +208,21 @@ def umount_bind_chroot():
runcmd(cmd)
-def partitions_removeall(diskdevice,label):
- logging.info("Removing all partitions for %s %s" ,label,diskdevice)
+def partitions_removeall(diskdevice, label):
+ logging.info("Removing all partitions for %s %s", label, diskdevice)
device = parted.getDevice(diskdevice)
partdisk = parted.Disk(device)
partdisk.deleteAllPartitions()
- if data_config.NOOPDEBUG=="FALSE":
+ if data_config.NOOPDEBUG == "FALSE":
partdisk.commit()
for partition in partdisk.partitions:
- print "type: %s" %partition.type
+ print "type: %s" %partition.type
-def create_partitions(diskdevice,size,ptype,startsector):
+def create_partitions(diskdevice, size, ptype, startsector):
logging.debug("_____Create partitions______")
- if size=="NO":
- logging.info("Size is 0, skipping")
+ if size == "NO":
+ logging.info("Size is 0, skipping")
return "NO"
partlist = []
newstart = 0
@@ -277,52 +230,52 @@ def create_partitions(diskdevice,size,ptype,startsector):
device = parted.getDevice(diskdevice)
partdisk = parted.Disk(device)
for partition in partdisk.partitions:
- if partition.type != parted.PARTITION_FREESPACE:
- partlist.append((partition,
- partition.path,
- partition.getFlag(parted.PARTITION_BOOT),
- partition.geometry.start,
- partition.geometry.end,
- partition.geometry.length,
- partition.type,
- partition.fileSystem))
+ if partition.type != parted.PARTITION_FREESPACE:
+ partlist.append((partition,
+ partition.path,
+ partition.getFlag(parted.PARTITION_BOOT),
+ partition.geometry.start,
+ partition.geometry.end,
+ partition.geometry.length,
+ partition.type,
+ partition.fileSystem))
for slice in partlist:
- (usedpartition, usedpath, usedbootable, usedstart, usedend, usedlength, usedtype, usedfs) = slice
+ (usedpartition, usedpath, usedbootable, usedstart, usedend, usedlength, usedtype, usedfs) = slice
#Start the new partition one after the end of last
newstart = usedend+1
- if startsector==0:
+ if startsector == 0:
newstart = 0
- if size=="ALL":
- logging.debug(" Using the rest of the disk %s",(device.length-newstart) )
+ if size == "ALL":
+ logging.debug(" Using the rest of the disk %s", (device.length-newstart) )
try:
- geom = parted.Geometry(device=device, start=newstart, length=(device.length-newstart))
+ geom = parted.Geometry(device=device, start=newstart, length=(device.length-newstart))
except:
- logging.info("An error occured, probably invalid parition size")
+ logging.info("An error occured, probably invalid parition size")
return
else:
# convert size in MB to a length on the device in sectors
length = (int(size) * (1024 * 1024)) / device.sectorSize
- logging.debug("Size is %s",length)
+ logging.debug("Size is %s", length)
try:
- geom = parted.Geometry(device=device, start=newstart, length=length)
+ geom = parted.Geometry(device=device, start=newstart, length=length)
except:
- logging.info("An error occured, probably invalid parition size")
+ logging.info("An error occured, probably invalid parition size")
return
#collect device constraint
constraint = device.getConstraint()
# new partition
- if ptype=="NORMAL":
- newpart = parted.Partition(disk=partdisk,type=parted.PARTITION_NORMAL, geometry=geom)
- elif ptype=="SWAP":
- newpart = parted.Partition(disk=partdisk,type=parted.PARTITION_NORMAL, geometry=geom)
+ if ptype == "NORMAL":
+ newpart = parted.Partition(disk=partdisk, type=parted.PARTITION_NORMAL, geometry=geom)
+ elif ptype == "SWAP":
+ newpart = parted.Partition(disk=partdisk, type=parted.PARTITION_NORMAL, geometry=geom)
#add the partition to the disk and commit changes
- partdisk.addPartition(partition=newpart, constraint=constraint)
- if data_config.NOOPDEBUG=="FALSE":
+ partdisk.addPartition(partition=newpart, constraint=constraint)
+ if data_config.NOOPDEBUG == "FALSE":
partdisk.commit()
logging.info("created partition %s of %dMB and added it to %s" %
- (newpart.getDeviceNodeName(), newpart.getSize(), diskdevice))
+ (newpart.getDeviceNodeName(), newpart.getSize(), diskdevice))
return newpart.getDeviceNodeName()
@@ -333,23 +286,23 @@ def partition_disk():
rootdisk = hostoptions["rootdisk"]
datadisk = hostoptions["datadisk"]
label = "root"
- partitions_removeall("/dev/"+rootdisk,label)
+ partitions_removeall("/dev/"+rootdisk, label)
label = "data"
- partitions_removeall("/dev/"+datadisk,label)
- hostoptions["rootpartition"] = create_partitions("/dev/"+rootdisk,hostoptions["rootsize"],"NORMAL",0)
- hostoptions["swappartition"] = create_partitions("/dev/"+rootdisk,hostoptions["swapsize"],"SWAP",1)
- if datadisk!=rootdisk:
- hostoptions["datapartition"] = create_partitions("/dev/"+datadisk,hostoptions["datasize"],"NORMAL",0)
+ partitions_removeall("/dev/"+datadisk, label)
+ hostoptions["rootpartition"] = create_partitions("/dev/"+rootdisk, hostoptions["rootsize"], "NORMAL", 0)
+ hostoptions["swappartition"] = create_partitions("/dev/"+rootdisk, hostoptions["swapsize"], "SWAP", 1)
+ if datadisk != rootdisk:
+ hostoptions["datapartition"] = create_partitions("/dev/"+datadisk, hostoptions["datasize"], "NORMAL", 0)
else:
- hostoptions["datapartition"] = create_partitions("/dev/"+datadisk,hostoptions["datasize"],"NORMAL",1)
+ hostoptions["datapartition"] = create_partitions("/dev/"+datadisk, hostoptions["datasize"], "NORMAL", 1)
time.sleep(5)
def fscmd(fstype):
- fscmds = {"reiserfs":"mkreiserfs -q -l ROOT" , "xfs": "mkfs -t xfs -f" , "ext3": "mkfs.ext3","jfs":"mkfs.jfs -q","ext4":"mkfs.ext4","Do_not_format":"noformat","no_format":"noformat"}
+ fscmds = {"reiserfs":"mkreiserfs -q -l ROOT", "xfs": "mkfs -t xfs -f", "ext3": "mkfs.ext3", "jfs":"mkfs.jfs -q", "ext4":"mkfs.ext4", "Do_not_format":"noformat", "no_format":"noformat"}
try:
rc = fscmds[fstype]
except:
- logging.critical(" %s is not a valid fs type, exiting now",fstype)
+ logging.critical(" %s is not a valid fs type, exiting now", fstype)
sys.exit(3)
return rc
@@ -363,36 +316,36 @@ def format_disk(install_type):
datadisk = hostoptions["datadisk"]
rootpartition = hostoptions["rootpartition"]
datapartition = hostoptions["datapartition"]
- if install_type!="upgrade":
+ if install_type != "upgrade":
swapsize = hostoptions["swapsize"]
swappartition = hostoptions["swappartition"]
- logging.debug(" Format command for rootfs %s : %s ", rootfs,rootpartition)
+ logging.debug(" Format command for rootfs %s : %s ", rootfs, rootpartition)
if ( rootfs != "noformat"):
- logging.info("Starting format of %s",rootpartition)
- cmd = " %s /dev/%s" %( rootfs , rootpartition)
+ logging.info("Starting format of %s", rootpartition)
+ cmd = " %s /dev/%s" %( rootfs, rootpartition)
#os.system(cmd)
runcmd(cmd)
else:
- logging.info("Will not format root partition: %s",rootpartition)
+ logging.info("Will not format root partition: %s", rootpartition)
- logging.debug(" Format command for datafs %s : %s ", datafs,datapartition)
+ logging.debug(" Format command for datafs %s : %s ", datafs, datapartition)
if (datafs != "noformat"):
- logging.info("Starting format of %s",datapartition)
- cmd = " %s /dev/%s" %( datafs , datapartition)
+ logging.info("Starting format of %s", datapartition)
+ cmd = " %s /dev/%s" %( datafs, datapartition)
#os.system(cmd)
runcmd(cmd)
else:
- logging.info("Will not format data partition: %s", datapartition)
+ logging.info("Will not format data partition: %s", datapartition)
- if install_type=="install":
+ if install_type == "install":
if (hostoptions["swapsize"] != "NO"):
- logging.info("Starting format for swap %s",swappartition)
+ logging.info("Starting format for swap %s", swappartition)
cmd = " mkswap /dev/%s" % swappartition
#os.system(cmd)
runcmd(cmd)
else:
- logging.debug(" Swap is set to NO, will not run mkswap")
+ logging.debug(" Swap is set to NO, will not run mkswap")
logging.debug("_____End of format______")
@@ -403,13 +356,13 @@ def mount_it():
try:
mountpoint = data_config.MOUNTPOINT
mp = mountpoint
- logging.info("Creating mountpoints %s",mp)
+ logging.info("Creating mountpoints %s", mp)
os.makedirs(mp)
except OSError:
- logging.debug(" Could not create %s",mp)
+ logging.debug(" Could not create %s", mp)
# Mount root
- cmd = "mount /dev/%s %s" %(hostoptions["rootpartition"],mountpoint)
+ cmd = "mount /dev/%s %s" %(hostoptions["rootpartition"], mountpoint)
runcmd(cmd)
#logging.debug(cmd)
#cmdout=commands.getoutput(cmd)
@@ -420,12 +373,12 @@ def mount_it():
mountpoint = data_config.MOUNTPOINT
datapoint = data_config.DATAMOUNT
mp = mountpoint+datapoint
- logging.info("Creating mountpoints %s",mp)
+ logging.info("Creating mountpoints %s", mp)
os.makedirs(mp)
except OSError:
- logging.debug(" Could not create %s",mp)
+ logging.debug(" Could not create %s", mp)
- cmd = "mount /dev/%s %s" %(hostoptions["datapartition"],mp)
+ cmd = "mount /dev/%s %s" %(hostoptions["datapartition"], mp)
runcmd(cmd)
#logging.debug(cmd)
#cmdout=commands.getoutput(cmd)
@@ -452,7 +405,7 @@ def unmount_it():
def create_squashlist():
logging.debug("Creating squashlist")
squashfile = data_config.SQUASHFILE
- f = open(squashfile, 'w')
+ f = open(squashfile, 'w')
for i in data_config.SQUASHLIST:
f.write(i)
f.write("\n")
@@ -473,20 +426,20 @@ def copy_it(install_type):
if ( install_type == "upgrade"):
logging.info("Upgrading system")
create_squashlist()
- cmd = " unsquashfs -e %s -f -d %s /.livesys/medium/system.sqf" %(data_config.SQUASHFILE , data_config.MOUNTPOINT)
+ cmd = " unsquashfs -e %s -f -d %s /.livesys/medium/system.sqf" %(data_config.SQUASHFILE, data_config.MOUNTPOINT)
runcmd(cmd)
#logging.debug(cmd)
#cmdout=commands.getoutput(cmd)
# Create the missing dir
- i = ("sys","proc","dev","tmp","mnt","media","media/cdrom","media/dvd","var/log/mythtv")
+ i = ("sys", "proc", "dev", "tmp", "mnt", "media", "media/cdrom", "media/dvd", "var/log/mythtv")
mountpoint = data_config.MOUNTPOINT
for item in i:
try:
mp = mountpoint+"/"+item
- logging.info("Creating mountpoints %s",mp)
+ logging.info("Creating mountpoints %s", mp)
os.makedirs(mp)
except OSError:
- logging.debug(" __Could not create %s",mp)
+ logging.debug(" __Could not create %s", mp)
# General fixup
cmd = "chmod 777 %s/tmp" %(data_config.MOUNTPOINT)
runcmd(cmd)
@@ -509,20 +462,20 @@ def create_fstab(extralines):
logging.info("Creating new fstab file")
fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
fstab_list = []
- f = open(fstabfile, 'w')
+ f = open(fstabfile, 'w')
line = "# <file system> <dir> <type> <options> <dump> <pass> \n"
fstab_list.append(line)
line = "none /dev/pts devpts defaults 0 0 \n"
fstab_list.append(line)
line = "none /dev/shm tmpfs defaults 0 0\n"
fstab_list.append(line)
- line = "/dev/cdrom /media/cdrom auto ro,user,noauto,unhide 0 0\n"
+ line = "/dev/cdrom /media/cdrom auto ro, user, noauto, unhide 0 0\n"
fstab_list.append(line)
- line = "/dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0\n"
+ line = "/dev/dvd /media/dvd auto ro, user, noauto, unhide 0 0\n"
fstab_list.append(line)
- line = "UUID=ROOTUID / auto defaults,noatime 0 1\n"
+ line = "UUID=ROOTUID / auto defaults, noatime 0 1\n"
fstab_list.append(line)
- line = "UUID=DATAUID %s auto defaults,noatime 0 1\n" %(data_config.DATAMOUNT)
+ line = "UUID=DATAUID %s auto defaults, noatime 0 1\n" %(data_config.DATAMOUNT)
fstab_list.append(line)
line = "UUID=SWAPUID swap swap defaults 0 0 \n"
fstab_list.append(line)
@@ -534,18 +487,18 @@ def create_fstab(extralines):
f.close()
def find_uuid(partition):
- logging.info("Finding the UUID for %s...",partition)
+ logging.info("Finding the UUID for %s...", partition)
cmd = "blkid -s UUID /dev/%s" %partition
tmpuuid = runcmd(cmd)
splituuid = tmpuuid.partition("=")
- uuid = splituuid[2].replace('"',"")
- logging.info("The uuid is %s",uuid)
+ uuid = splituuid[2].replace('"', "")
+ logging.info("The uuid is %s", uuid)
return uuid.strip()
def pick_out_vg():
logging.info("Searching for Volume Groups in old fstab")
vglines = []
- f = open("/tmp/etc/fstab", 'r')
+ f = open("/tmp/etc/fstab", 'r')
oldfscontents = f.readlines()
for line in oldfscontents:
if line.startswith("/dev/vg"):
@@ -553,47 +506,47 @@ def pick_out_vg():
templine = line.split()
mdir = templine[1]
if not os.path.exists (mdir):
- logging.debug("Creating dir %s for VG mount",mdir)
+ logging.debug("Creating dir %s for VG mount", mdir)
os.makedirs (mdir)
# Might need to os.chown to mythtv:users
else:
- logging.debug("Directory %s for VG mount already present",mdir)
+ logging.debug("Directory %s for VG mount already present", mdir)
return vglines
def fstab_it(install_type):
logging.info("______Checking fstab______")
kmvg = []
fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
-# Check for knoppmyth install, if found create new
- if install_type=="upgrade":
+# Check for knoppmyth install, if found create new
+ if install_type == "upgrade":
if os.path.exists("/tmp/etc/KnoppMyth-version"):
- logging.debug(" KnoppMyth-Version found, creating new fstab")
+ logging.debug(" KnoppMyth-Version found, creating new fstab")
kmvg = pick_out_vg()
create_fstab(kmvg)
elif os.path.exists("/tmp/etc/fstab"):
- logging.debug(" Upgrade and not Knoppmyth, using old fstab")
- cp_and_log("/tmp/etc/fstab",fstabfile)
+ logging.debug(" Upgrade and not Knoppmyth, using old fstab")
+ cp_and_log("/tmp/etc/fstab", fstabfile)
# Catch all for creating new fstab
if not os.path.exists(data_config.MOUNTPOINT+"/etc"):
os.makedirs(data_config.MOUNTPOINT+"/etc")
if not os.path.exists(fstabfile):
- create_fstab(kmvg)
+ create_fstab(kmvg)
- logging.info("____UUID check for %s" , "swap")
+ logging.info("____UUID check for %s", "swap")
swapuuid = find_uuid(hostoptions["swappartition"])
- logging.info("____UUID check for %s" , "data")
+ logging.info("____UUID check for %s", "data")
datauuid = find_uuid(hostoptions["datapartition"])
- logging.info("____UUID check for %s" , "root")
+ logging.info("____UUID check for %s", "root")
rootuuid = find_uuid(hostoptions["rootpartition"])
fstabfile = data_config.MOUNTPOINT+"/etc/fstab"
- logging.info("Correcting UUID's in %s",fstabfile)
- f = open(fstabfile, 'r')
+ logging.info("Correcting UUID's in %s", fstabfile)
+ f = open(fstabfile, 'r')
oldfscontents = f.readlines()
newfstab = []
- f.close
+ f.close()
for line in oldfscontents:
if line.startswith("UUID"):
templine = line.split()
@@ -639,12 +592,12 @@ def fstab_it(install_type):
logging.debug( newline)
newfstab.append(newline)
else:
- logging.debug(" Line didn't match, adding to newfstab:")
+ logging.debug(" Line didn't match, adding to newfstab:")
logging.debug( line)
newfstab.append(line)
logging.info("Writing out newfstab")
logging.debug("______This is the new fstab_____")
- f = open(fstabfile, 'w')
+ f = open(fstabfile, 'w')
for line in newfstab:
logging.debug(line)
f.write(line)
@@ -663,10 +616,10 @@ def grub_it():
logging.info("Adding root uuid to grub menu")
grubfile = data_config.MOUNTPOINT+"/boot/grub/menu.lst"
try:
- f = open(grubfile, 'r')
+ f = open(grubfile, 'r')
oldgrub = f.readlines()
newgrub = []
- f.close
+ f.close()
for line in oldgrub:
if line.startswith("kernel"):
templine = line.split()
@@ -682,12 +635,12 @@ def grub_it():
logging.debug( newline)
newgrub.append(newline)
else:
- logging.debug("Line didn't match, adding to newgrub:")
+ logging.debug("Line didn't match, adding to newgrub:")
logging.debug( line)
newgrub.append( line)
logging.info("Writing out new grub file")
logging.debug("______This is the new grub_____")
- f = open(grubfile, 'w')
+ f = open(grubfile, 'w')
for line in newgrub:
logging.debug(line)
f.write(line)
@@ -717,23 +670,23 @@ def apply_new_auth():
try:
MVROOT = os.environ["MV_ROOT"]
except:
- logging.debug("MVROOT was not defined, using the default value")
+ logging.debug("MVROOT was not defined, using the default value")
MVROOT = "/usr/MythVantage"
- if data_config.NOOPDEBUG=="FALSE":
+ if data_config.NOOPDEBUG == "FALSE":
cmdprefix = "chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i "
else:
cmdprefix = "echo chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i "
try:
- f = open(passfile, 'r')
+ f = open(passfile, 'r')
passcmds = f.readlines()
- f.close
+ f.close()
for cmd in passcmds:
execmd = cmdprefix+cmd
# Using os.system because runcmd fails
logging.debug(execmd)
os.system(execmd)
except:
- logging.debug("Applying password updates failed, couldn't open %s",passfile)
+ logging.debug("Applying password updates failed, couldn't open %s", passfile)
logging.debug
def swapsearch():
@@ -743,72 +696,72 @@ def swapsearch():
os.chdir("/sys/block")
partitionlist = glob.glob("*")
for item in partitionlist:
- try:
- newitem = item.strip().rpartition(" ")[2]
- if (not newitem=='') and (not newitem.startswith("loop")):
- path = "/dev/"+newitem.strip()
- path = path.strip()
- device = parted.getDevice(path)
- (cylinders, heads, sectors) = device.biosGeometry
- sizeInBytes = device.length * device.sectorSize
- disk = parted.Disk(device)
- for partition in disk.partitions:
- if partition.type == parted.PARTITION_PROTECTED or \
- partition.type == parted.PARTITION_METADATA or \
- partition.type == parted.PARTITION_FREESPACE:
- continue
-
- partlist.append((partition,
- partition.path,
- partition.getFlag(parted.PARTITION_BOOT),
- partition.geometry.start,
- partition.geometry.end,
- partition.geometry.length,
- partition.type,
- partition.fileSystem))
- for slice in partlist:
- (partition, path, bootable, start, end, length, type, fs) = slice
- if partition.getFlag(parted.PARTITION_SWAP) or fs.type=="linux-swap":
- print "found swap"
- print path
- except:
- pass
+ try:
+ newitem = item.strip().rpartition(" ")[2]
+ if (not newitem == '') and (not newitem.startswith("loop")):
+ path = "/dev/"+newitem.strip()
+ path = path.strip()
+ device = parted.getDevice(path)
+ (cylinders, heads, sectors) = device.biosGeometry
+ sizeInBytes = device.length * device.sectorSize
+ disk = parted.Disk(device)
+ for partition in disk.partitions:
+ if partition.type == parted.PARTITION_PROTECTED or \
+ partition.type == parted.PARTITION_METADATA or \
+ partition.type == parted.PARTITION_FREESPACE:
+ continue
+
+ partlist.append((partition,
+ partition.path,
+ partition.getFlag(parted.PARTITION_BOOT),
+ partition.geometry.start,
+ partition.geometry.end,
+ partition.geometry.length,
+ partition.type,
+ partition.fileSystem))
+ for slice in partlist:
+ (partition, path, bootable, start, end, length, type, fs) = slice
+ if partition.getFlag(parted.PARTITION_SWAP) or fs.type == "linux-swap":
+ print "found swap"
+ print path
+ except:
+ pass
os.chdir(stddir)
def sane_settings(file):
#Remove some settings from file_name
- removeline = ("HOSTrootfstype", "HOSTrootfstype", "HOSTdatafstype", "HOSTOSsize", "HostUseALLdata", "HOSTDATAsize", "HOSTuprootfstype", "HostUseSWAP", "HOSTSWAPsize")
+ removeline = ("HOSTrootfstype", "HOSTrootfstype", "HOSTdatafstype", "HOSTOSsize", "HostUseALLdata", "HOSTDATAsize", "HOSTuprootfstype", "HostUseSWAP", "HOSTSWAPsize")
logging.debug("__Running sane settings")
try:
- f = open(file, 'r')
+ f = open(file, 'r')
filecontents = f.readlines()
- f.close
+ f.close()
except:
- logging.debug(" Couldn't find file %s to sane",file)
+ logging.debug(" Couldn't find file %s to sane", file)
try:
- f = open(file,'w')
+ f = open(file, 'w')
for line in filecontents:
for item in removeline:
if line.startsize(line.strip()):
- logging.debug(" Found a line to remove in %s, %s",file,line)
+ logging.debug(" Found a line to remove in %s, %s", file, line)
else:
f.write(line)
except:
- logging.debug(" Couldn't open file %s for writing",file)
+ logging.debug(" Couldn't open file %s for writing", file)
logging.debug(" __End sane settings")
def restore_default_settings():
try:
MVROOT = os.environ["MV_ROOT"]
except:
- logging.debug(" MVROOT was not defined, using the default value")
+ logging.debug(" MVROOT was not defined, using the default value")
MVROOT = "/usr/MythVantage"
logging.info("Saving syssettings")
- cmd = "%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT,data_config.MVHOSTNAME)
+ cmd = "%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME)
runcmd(cmd)
SE = os.environ["TEMPLATES"]+"/settings/syssettings/"
- cp_and_log(SE,data_config.MOUNTPOINT+SE)
- cp_and_log("/etc/mtab",data_config.MOUNTPOINT+"/etc/mtab")
+ cp_and_log(SE, data_config.MOUNTPOINT+SE)
+ cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab")
copy_updates()
fix_permissions()
@@ -817,22 +770,22 @@ def full_install(hostoptions):
try:
MVROOT = os.environ["MV_ROOT"]
except:
- logging.debug(" MVROOT was not defined, using the default value")
+ logging.debug(" MVROOT was not defined, using the default value")
MVROOT = "/usr/MythVantage"
try:
os.remove("/tmp/.this_is_upgrade")
except OSError:
- logging.debug(" File /tmp/.this_is_upgrade not present, couldn't delete it")
+ logging.debug(" File /tmp/.this_is_upgrade not present, couldn't delete it")
pass
# Partition disk
statusmsg = "Partitioning %s" %( hostoptions["rootdisk"])
update_status(statusmsg)
progress(1)
- if data_config.NOOPDEBUG=="FALSE":
- partition_disk()
+ if data_config.NOOPDEBUG == "FALSE":
+ partition_disk()
else:
- logging.debug(" Debug mode, skipping partitioning step")
+ logging.debug(" Debug mode, skipping partitioning step")
# Format disk
statusmsg = "Preparing %s" %( hostoptions["rootdisk"])
@@ -860,7 +813,7 @@ def full_install(hostoptions):
try:
os.remove(fstabfile)
except OSError:
- logging.debug(" ERROR: deleting %s",fstabfile)
+ logging.debug(" ERROR: deleting %s", fstabfile)
fstab_it("full_install")
# Configure system
msg = "Configuring system"
@@ -869,65 +822,65 @@ def full_install(hostoptions):
grub_it()
# Configuring the system
logging.info("______Configuring system________")
- cp_and_log("/etc/systemconfig",data_config.MOUNTPOINT+"/etc/systemconfig")
- cp_and_log("/root/xorg.conf.install",data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
+ cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig")
+ cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
restore_default_settings()
#try:
#MVROOT=os.environ["MV_ROOT"]
#except:
- #logging.debug(" MVROOT was not defined, using the default value")
+ #logging.debug(" MVROOT was not defined, using the default value")
#MVROOT="/usr/MythVantage"
#logging.info("Saving syssettings")
- #cmd="%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT,data_config.MVHOSTNAME)
+ #cmd="%s/bin/restore_default_settings.sh -c save -t syssettings -h %s -d localhost" %(MVROOT, data_config.MVHOSTNAME)
#runcmd(cmd)
#SE=os.environ["TEMPLATES"]+"/settings/syssettings"
- #cp_and_log(SE,data_config.MOUNTPOINT+SE)
- #cp_and_log("/etc/mtab",data_config.MOUNTPOINT+"/etc/mtab")
- #cp_and_log2(MVROOT+"/bin/",data_config.MOUNTPOINT+MVROOT+"/bin/","*.sh")
- #cp_and_log2(MVROOT+"/bin/",data_config.MOUNTPOINT+MVROOT+"/bin/","*.py")
+ #cp_and_log(SE, data_config.MOUNTPOINT+SE)
+ #cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab")
+ #cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin/", "*.sh")
+ #cp_and_log2(MVROOT+"/bin/", data_config.MOUNTPOINT+MVROOT+"/bin/", "*.py")
#fix_permissions()
apply_new_auth()
if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ):
-# This install will need a DB, so install it
+# This install will need a DB, so install it
logging.info("______Installing Database in CHROOT________")
- mysqldb("stop",'')
+ mysqldb("stop", '')
mount_bind_chroot()
- cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
logging.info("Running systemconfig in chroot")
- cmd = " chroot %s %s/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
- mysqldb("stop","chroot")
+ mysqldb("stop", "chroot")
kill_dhcp_chroot()
logging.info("____End Database in CHROOT____")
- mysqldb("start",'')
+ mysqldb("start", '')
umount_bind_chroot()
else:
- logging.info("______No database required, continuing configuration________")
+ logging.info("______No database required, continuing configuration________")
mount_bind_chroot()
- cmd = " chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore,default 1" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s DISPLAY=127.0.0.1:0 %s/bin/MythVantage -t restore, default 1" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
# Need to check for to touch /tmp/.dbsysfailed
- cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
if ( 'x' == '1' ):
logging.debug("touching /tmp/.dbsysfailed")
else:
- cmd = " chroot %s %s/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
- cmd = " chroot %s %s/bin/restore_default_settings.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/restore_default_settings.sh -c ACCESSCONTROL " %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
umount_bind_chroot()
- cmd = " chroot %s %s/bin/systemconfig.sh advanced,user" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh advanced, user" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
- cmd = " touch %s%s/.configure" %(data_config.MOUNTPOINT,data_config.MYTHHOME)
+ cmd = " touch %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
runcmd(cmd)
- cmd = " chmod 777 %s%s/.configure" %(data_config.MOUNTPOINT,data_config.MYTHHOME)
+ cmd = " chmod 777 %s%s/.configure" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
runcmd(cmd)
msg = "Done"
update_status(msg)
- cp_and_log("/tmp/mythvantage_install.log",data_config.MOUNTPOINT+"/var/log/mythvantage_install.log")
- cp_and_log("/tmp/mv_debug.log",data_config.MOUNTPOINT+"/var/log/mv_debug.log")
+ cp_and_log("/tmp/mythvantage_install.log", data_config.MOUNTPOINT+"/var/log/mythvantage_install.log")
+ cp_and_log("/tmp/mv_debug.log", data_config.MOUNTPOINT+"/var/log/mv_debug.log")
unmount_it()
logging.debug("_____End of full install_____")
@@ -935,55 +888,55 @@ def find_upgrade():
logging.info("_____Start of find_upgrade_____")
global hostoptions
#try to mount first partition of disk
- #copy old /etc/systemconfig to live, import settings into db
+ #copy old /etc/systemconfig to live, import settings into db
#umount drive.
#check for clean upgrade
if ( clean_upgrade() ):
- logging.info("Clean upgrade requested, not using old data")
+ logging.info("Clean upgrade requested, not using old data")
return
mount_it()
oldbackupfile = data_config.MOUNTPOINT+"/root/backup/"+data_config.BACKUPFILE
newbackupfile = "/tmp/"+data_config.BACKUPFILE
if os.path.exists(oldbackupfile):
- logging.debug("Setting backup file to %s",newbackupfile)
+ logging.debug("Setting backup file to %s", newbackupfile)
hostoptions["backupfile"] = newbackupfile
- cp_and_log(oldbackupfile,newbackupfile)
+ cp_and_log(oldbackupfile, newbackupfile)
srcfile = data_config.MOUNTPOINT+"/etc/systemconfig"
- logging.info("Searching for systemconfig file %s",srcfile)
+ logging.info("Searching for systemconfig file %s", srcfile)
if os.path.exists(srcfile):
- logging.info("Found systemconfig file %fs",srcfile)
+ logging.info("Found systemconfig file %fs", srcfile)
TEMPLATES = os.environ["TEMPLATES"]+"/settings/syssettings"
- cp_and_log2(data_config.MOUNTPOINT+TEMPLATES,data_config.TEMP_TEMPLATES,'')
+ cp_and_log2(data_config.MOUNTPOINT+TEMPLATES, data_config.TEMP_TEMPLATES, '')
sane_settings("/tmp/templates/settings/syssettings/settings.txt")
- cp_and_log2(data_config.TEMP_TEMPLATES,TEMPLATES,'')
- cp_and_log(srcfile,"/etc/systemconfig")
- cp_and_log(data_config.MOUNTPOINT+"/etc/","/tmp/etc/")
- cp_and_log(data_config.MOUNTPOINT+"/var/lib/oss/","/tmp/oss")
- cp_and_log("/tmp/etc/mdadm.conf","/etc/mdadm.conf")
+ cp_and_log2(data_config.TEMP_TEMPLATES, TEMPLATES, '')
+ cp_and_log(srcfile, "/etc/systemconfig")
+ cp_and_log(data_config.MOUNTPOINT+"/etc/", "/tmp/etc/")
+ cp_and_log(data_config.MOUNTPOINT+"/var/lib/oss/", "/tmp/oss")
+ cp_and_log("/tmp/etc/mdadm.conf", "/etc/mdadm.conf")
else:
- logging.info("Could not find systemconfig file %s",srcfile)
- cp_and_log(data_config.MOUNTPOINT+"/etc/","/tmp/etc/")
- cp_and_log("/tmp/etc/mdadm.conf","/etc")
- timezone_to_db("/tmp/etc/timezone")
+ logging.info("Could not find systemconfig file %s", srcfile)
+ cp_and_log(data_config.MOUNTPOINT+"/etc/", "/tmp/etc/")
+ cp_and_log("/tmp/etc/mdadm.conf", "/etc")
+ timezone_to_db("/tmp/etc/timezone")
unmount_it()
logging.debug("End of find_upgrade")
def upgrade_mount_search():
#Search for data/myth partition based on contents of fstab
logging.debug("______Start of upgrade_mount_search_____")
- cmd = "umount %s%s" %(data_config.MOUNTPOINT,data_config.DATAMOUNT)
+ cmd = "umount %s%s" %(data_config.MOUNTPOINT, data_config.DATAMOUNT)
runcmd(cmd)
fstab_list = []
fstab_data_mount = ''
try:
- f = open("/tmp/etc/fstab", 'r')
+ f = open("/tmp/etc/fstab", 'r')
oldfscontents = f.readlines()
f.close()
- ## ['UUID=', '/myth', 'auto', 'defaults,noatime', '0', '1']
+ ## ['UUID=', '/myth', 'auto', 'defaults, noatime', '0', '1']
#for line in oldfscontents:
#mountdir=line.split()
- #if mountdir[1]==(data_config.DATAMOUNT):
+ #if mountdir[1] == (data_config.DATAMOUNT):
#fstablist.append(mountdir)
except:
logging.debug(" Couldn't open /tmp/etc/fstab")
@@ -992,13 +945,13 @@ def upgrade_mount_search():
continue
mountdir=line.split()
try:
- if mountdir[1]==(data_config.DATAMOUNT):
+ if mountdir[1] == (data_config.DATAMOUNT):
fstablist.append(mountdir)
except:
continue
#search fstab for data/myth mountpoint
for i in fstab_list:
- if i[1]==data_config.DATAMOUNT:
+ if i[1] == data_config.DATAMOUNT:
fstab_data_mount = i[0]
break
@@ -1009,15 +962,15 @@ def upgrade_mount_search():
mdadm_assemble_all
- if re.search("UUID",fstab_data_mount):
+ if re.search("UUID", fstab_data_mount):
fstab_data_uuid = fstab_data_mount.split("=")[1]
cmd = "blkid -t UUID=%s" %fstab_data_uuid
- retcode = call(cmd, shell=True)
+ retcode = call(cmd, shell=True)
if retcode != 0:
- logging.debug(" Couldn't find uuid %s , starting md support",fstab_data_uuid)
+ logging.debug(" Couldn't find uuid %s, starting md support", fstab_data_uuid)
mdadm_assemble_all
#hoping everything is up and running and data/myth will be available for mount
- cmd = "mount -U %s %s" %(fstab_data_uuid,data_config.MOUNTPOINT)
+ cmd = "mount -U %s %s" %(fstab_data_uuid, data_config.MOUNTPOINT)
runcmd(cmd)
cmd = "blkid -t UUID=%s|cut -d: -f1" %fstab_data_uuid
logging.debug(cmd)
@@ -1025,7 +978,7 @@ def upgrade_mount_search():
cmd = "basename %s" %datadisk
datadisk = commands.getoutput(cmd)
else:
- cmd = "mount %s %s" %(fstab_data_mount,data_config.MOUNTPOINT)
+ cmd = "mount %s %s" %(fstab_data_mount, data_config.MOUNTPOINT)
runcmd(cmd)
cmd = "basename %s" %fstab_data_mount
datadisk = commands.getoutput(cmd)
@@ -1034,11 +987,11 @@ def upgrade_mount_search():
if not backup_sql_check():
newbackupfile = "/tmp/"+data_config.BACKUPFILE
if os.path.exists(newbackupfile):
- logging.debug("Setting backup file to %s",newbackupfile)
- cp_and_log(newbackupfile,data_config.MOUNTPOINT+newbackupfile)
+ logging.debug("Setting backup file to %s", newbackupfile)
+ cp_and_log(newbackupfile, data_config.MOUNTPOINT+newbackupfile)
hostoptions["backupfile"] = newbackupfile
else:
- logging.info("Couldn't find any database to restore, upgrade will continue with a new database")
+ logging.info("Couldn't find any database to restore, upgrade will continue with a new database")
@@ -1047,7 +1000,7 @@ def upgrade(hostoptions):
try:
MVROOT = os.environ["MV_ROOT"]
except:
- logging.debug("MVROOT was not defined, using the default value")
+ logging.debug("MVROOT was not defined, using the default value")
MVROOT = "/usr/MythVantage"
logging.info("______Start of upgrade______")
cmd = "touch /tmp/.this_is_upgrade"
@@ -1073,29 +1026,29 @@ def upgrade(hostoptions):
cmd = "rm -rf %s/etc.old" %data_config.MOUNTPOINT
runcmd(cmd)
- cp_and_log("/tmp/etc/",data_config.MOUNTPOINT+"/etc.old/")
- cp_and_log("/tmp/oss",data_config.MOUNTPOINT+"/var/lib/oss.old")
+ cp_and_log("/tmp/etc/", data_config.MOUNTPOINT+"/etc.old/")
+ cp_and_log("/tmp/oss", data_config.MOUNTPOINT+"/var/lib/oss.old")
srcfile = "%s/etc.old/ssh/" %(data_config.MOUNTPOINT)
destfile = "%s/etc/ssh/" %(data_config.MOUNTPOINT)
- cp_and_log2(srcfile,destfile,'*.pub')
- cp_and_log2(srcfile,destfile,'*.key')
- cp_and_log2(srcfile,destfile,'*key')
+ cp_and_log2(srcfile, destfile, '*.pub')
+ cp_and_log2(srcfile, destfile, '*.key')
+ cp_and_log2(srcfile, destfile, '*key')
mdfile = mdadm_find("/tmp")
- cp_and_log("/tmp"+mdfile,data_config.MOUNTPOINT+"/etc")
+ cp_and_log("/tmp"+mdfile, data_config.MOUNTPOINT+"/etc")
srcfile = "%s/etc.old/asound.state" %(data_config.MOUNTPOINT)
destfile = "%s/etc/asound.state" %(data_config.MOUNTPOINT)
- cp_and_log(srcfile,destfile)
- if not os.path.exists("tmp/etc/KnoppMyth-version"):
- logging.debug(" standard upgrade, restoring auth files")
- cp_and_log(data_config.MOUNTPOINT+"/etc.old/passwd",data_config.MOUNTPOINT+"/etc/passwd")
- cp_and_log(data_config.MOUNTPOINT+"/etc.old/shadow",data_config.MOUNTPOINT+"/etc/shadow")
- cp_and_log(data_config.MOUNTPOINT+"/etc.old/group",data_config.MOUNTPOINT+"/etc/group")
+ cp_and_log(srcfile, destfile)
+ if not os.path.exists("/tmp/etc/KnoppMyth-version"):
+ logging.debug(" standard upgrade, restoring auth files")
+ cp_and_log(data_config.MOUNTPOINT+"/etc.old/passwd", data_config.MOUNTPOINT+"/etc/passwd")
+ cp_and_log(data_config.MOUNTPOINT+"/etc.old/shadow", data_config.MOUNTPOINT+"/etc/shadow")
+ cp_and_log(data_config.MOUNTPOINT+"/etc.old/group", data_config.MOUNTPOINT+"/etc/group")
msg = "Configuring system"
update_status(msg)
progress(98)
logging.info("______Configuring system________")
- cp_and_log("/etc/systemconfig",data_config.MOUNTPOINT+"/etc/systemconfig")
+ cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig")
if not backup_sql_check():
upgrade_mount_search()
fstab_it("upgrade")
@@ -1103,34 +1056,34 @@ def upgrade(hostoptions):
grub_it()
time.sleep(1)
#needed to get around a bug with pacman
- cp_and_log("/root/xorg.conf.install",data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
- cp_and_log("/etc/mtab",data_config.MOUNTPOINT+"/etc/mtab")
+ cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
+ cp_and_log("/etc/mtab", data_config.MOUNTPOINT+"/etc/mtab")
if clean_upgrade() or os.path.exists("/tmp/etc/KnoppMyth-version"):
- logging.debug("clean upgrade or knoppmyth upgrade detected, running restore settings")
+ logging.debug("clean upgrade or knoppmyth upgrade detected, running restore settings")
restore_default_settings()
if clean_upgrade():
- file = "%s/%s/.kmupgrade" %(data_config.MOUNTPOINT,data_config.MYTHHOME)
- cmd = "touch %s && chmod 777 %s" %(file,file)
+ file = "%s/%s/.kmupgrade" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
+ cmd = "touch %s && chmod 777 %s" %(file, file)
runcmd(cmd)
copy_updates()
fix_permissions()
mount_bind_chroot()
logging.info("Running systemconfig in chroot")
- cmd = " chroot %s %s/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
- mysqldb("stop","")
+ mysqldb("stop", "")
if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ):
if clean_upgrade() or not backup_sql_check():
logging.info("Installing new database")
- cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/install_db_chroot.sh |tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
else:
logging.info("Restoring database")
- cmd = " chroot %s %s/bin/restore_km_db_chroot.sh %s|tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT,MVROOT,hostoptions["backupfile"])
+ cmd = " chroot %s %s/bin/restore_km_db_chroot.sh %s|tee /tmp/chrootdb.out" %(data_config.MOUNTPOINT, MVROOT, hostoptions["backupfile"])
runcmd(cmd)
if os.path.exists("/tmp/etc/KnoppMyth-version"):
- cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t hostsettings " %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
logging.debug("Correcting permissions because of km->linhes upgrade")
cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT)
@@ -1138,25 +1091,25 @@ def upgrade(hostoptions):
cmd = " chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup")
runcmd(cmd)
else:
- cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/restore_default_settings.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
logging.info("Running systemconfig in chroot 2nd time")
- cmd = " chroot %s %s/bin/systemconfig.sh misc,hostype,network,advanced,user,this_is_install" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
logging.info("Running systemconfig in chroot")
- cmd = " chroot %s %s/bin/systemconfig.sh advanced" %(data_config.MOUNTPOINT,MVROOT)
+ cmd = " chroot %s %s/bin/systemconfig.sh advanced" %(data_config.MOUNTPOINT, MVROOT)
runcmd(cmd)
- mysqldb("stop",'chroot')
+ mysqldb("stop", 'chroot')
apply_new_auth()
kill_dhcp_chroot()
umount_bind_chroot()
- cp_and_log("/tmp/mythvantage_install.log",data_config.MOUNTPOINT+"/var/log/mythvantage_install.log")
- cp_and_log("/tmp/mv_debug.log",data_config.MOUNTPOINT+"/var/log/mv_debug.log")
+ cp_and_log("/tmp/mythvantage_install.log", data_config.MOUNTPOINT+"/var/log/mythvantage_install.log")
+ cp_and_log("/tmp/mv_debug.log", data_config.MOUNTPOINT+"/var/log/mv_debug.log")
unmount_it()
msg = "Done"
update_status(msg)
- mysqldb("start",'')
+ mysqldb("start", '')
@@ -1164,14 +1117,14 @@ def upgrade(hostoptions):
def main(argv):
global hostoptions
try:
- opts, args = getopt.getopt(argv, 'c:h' , ["help", "rootdisk=", "rootfs=" , "rootsize=" , "datafs=" , "datasize=", "datadisk=" , "swapsize=" , "datapartition=" ] )
- except getopt.GetoptError,why:
+ opts, args = getopt.getopt(argv, 'c:h', ["help", "rootdisk=", "rootfs=", "rootsize=", "datafs=", "datasize=", "datadisk=", "swapsize=", "datapartition=" ] )
+ except getopt.GetoptError, why:
print why
usage()
sys.exit(2)
hostoptions = {"op": 'null'}
- for opt, arg in opts:
- if opt in ("-h", "--help"):
+ for opt, arg in opts:
+ if opt in ("-h", "--help"):
usage()
sys.exit(0)
elif opt in ( "--rootdisk"):
@@ -1193,9 +1146,9 @@ def main(argv):
hostoptions["swapsize"] = arg
elif opt in ("-c"):
- validop = ["full_install","upgrade","netboot","find_upgrade"]
+ validop = ["full_install", "upgrade", "netboot", "find_upgrade"]
if arg not in validop:
- logging.critical("-c %s is not a valid option",arg)
+ logging.critical("-c %s is not a valid option", arg)
sys.exit(2)
else:
hostoptions["op"] = arg
@@ -1243,7 +1196,7 @@ logging.getLogger('').addHandler(console)
#infoformatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
infoformatter = logging.Formatter("%(message)s")
-infofile = logging.FileHandler(LOG_FILENAME,'w')
+infofile = logging.FileHandler(LOG_FILENAME, 'w')
infofile.setFormatter(infoformatter)
infofile.setLevel(logging.INFO)
logging.getLogger('').addHandler(infofile)
@@ -1255,20 +1208,20 @@ file_name = "/etc/systemconfig"
try:
config_file = open(file_name)
except:
- logging.debug("%s could not be opened",file_name)
- config_file=''
+ logging.debug("%s could not be opened", file_name)
+ config_file = ''
for line in config_file:
line = line.strip()
if line and line[0] is not "#" and line[-1] is not "=":
- var,val = line.rsplit("=",1)
+ var, val = line.rsplit("=", 1)
val = val.strip('"')
systemconfig[var.strip()] = val.strip()
if __name__ == "__main__":
config_file = "mv_config"
- data_config = __import__(config_file, globals(), locals(), [])
+ data_config = __import__(config_file, globals(), locals(), [])
logging.debug("___________START OF DEBUG_________________________")
cmdoptions = main(sys.argv[1:])
logging.debug("______cmd line options______")