diff options
author | James Meyer <james.meyer@operamail.com> | 2009-05-07 14:20:33 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2009-05-07 14:20:33 (GMT) |
commit | 8ae2b89f966938986b7389721363f1ddffc9ae40 (patch) | |
tree | 2c278699ce76cac40d8a590582be895f9dfb32c6 /abs/core-testing/LinHES-config | |
parent | 246c0471433375b63988e3fb2ca69c1670bed340 (diff) | |
download | linhes_pkgbuild-8ae2b89f966938986b7389721363f1ddffc9ae40.zip linhes_pkgbuild-8ae2b89f966938986b7389721363f1ddffc9ae40.tar.gz linhes_pkgbuild-8ae2b89f966938986b7389721363f1ddffc9ae40.tar.bz2 |
mv_install: Add space to either side of =, remove etc.old before recreating it.
Diffstat (limited to 'abs/core-testing/LinHES-config')
-rwxr-xr-x | abs/core-testing/LinHES-config/PKGBUILD | 2 | ||||
-rwxr-xr-x | abs/core-testing/LinHES-config/mv_install.py | 487 |
2 files changed, 247 insertions, 242 deletions
diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index 44fe66f..b20af81 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=407 +pkgrel=410 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 33a74a4..a945e34 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 , shutil,glob,time -import getopt,re +import sys , os, commands , glob, time +import getopt, re, MySQLdb import logging try: import parted @@ -16,7 +16,7 @@ def clean_upgrade(): return False def progress(pgnum): - progressline=str(pgnum)+ " complete" + progressline = str(pgnum) + " complete" logging.debug("Progress: %s" , pgnum) f = open('/tmp/.install_percent', 'w') f.write(progressline) @@ -30,15 +30,15 @@ def update_status(status): def kill_dhcp_chroot(): logging.debug("Killing off chroot dhcpcd") - stddir=os.getcwd() - piddir=("%s/var/run/") %data_config.MOUNTPOINT + stddir = os.getcwd() + piddir = ("%s/var/run/") %data_config.MOUNTPOINT try: os.chdir(piddir) for FILE in glob.glob("dhcpcd-*.pid"): - f=open(FILE,'r') - pid=f.readline() + f = open(FILE,'r') + pid = f.readline() f.close - cmd="kill -9 %s" %pid + cmd = "kill -9 %s" %pid runcmd(cmd) os.remove(FILE) os.chdir(stddir) @@ -46,13 +46,13 @@ def kill_dhcp_chroot(): pass def statgrab(disk): - cmd="statgrab -M disk. |grep %s.write_bytes" % hostoptions["rootdisk"] - out=commands.getoutput(cmd) + cmd = "statgrab -M disk. |grep %s.write_bytes" % hostoptions["rootdisk"] + out = commands.getoutput(cmd) try: - prewritebytes=out.split("=")[1].strip() + prewritebytes = out.split("=")[1].strip() except: - prewritebytes="1024" - outline="STARTSIZE=%s" %prewritebytes + prewritebytes = "1024" + outline = "STARTSIZE=%s" %prewritebytes f = open('/tmp/.startsize.io', 'w') f.write(str(outline)) f.close() @@ -74,9 +74,9 @@ def backup_sql_check(): def mdadm_find(PREFIX): logging.debug("Searching for mdadm.conf") if os.path.exists(PREFIX+"/etc/KnoppMyth-version"): - mdadmconf="/etc/mdadm/mdadm.conf" + mdadmconf = "/etc/mdadm/mdadm.conf" else: - mdadmconf="/etc/mdadm.conf" + mdadmconf = "/etc/mdadm.conf" logging.debug("Using %s for mdadm.conf",mdadmconf) return mdadmconf @@ -84,33 +84,33 @@ def mdadm_assemble_all(): # read mdadm.conf and start the arrays #ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 logging.debug("Starting mdadm support") - mdadmconf_file=mdadm_find("/tmp") - cmd="cdadm --assemble --scan -c /tmp/%s" %mdadmconf_file + mdadmconf_file = mdadm_find("/tmp") + cmd = "cdadm --assemble --scan -c /tmp/%s" %mdadmconf_file runcmd(cmd) - mdadm_contents='' + mdadm_contents = '' try: - f=open(mdadmconf_file, 'r') - mdadm_contents=f.readlines + 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) - array=line.split()[1] + array = line.split()[1] logging.info(" assembling array: %s",array) - cmd="mdadm --assemble -c /tmp%s %s" %(mdadmconf_file,array) + cmd = "mdadm --assemble -c /tmp%s %s" %(mdadmconf_file,array) runcmd(cmd) time.sleep(2) - cmd="fsck -p %s" %array + cmd = "fsck -p %s" %array runcmd def copy_updates(): try: - MVROOT=os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"] except: logging.debug("MVROOT was not defined, using the default value") - MVROOT="/usr/MythVantage" + 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") @@ -123,7 +123,7 @@ def cp_and_log(srcfile,destfile): if not os.path.exists(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) @@ -159,11 +159,11 @@ def cp_and_log2(srcfile,destfile,fileglob): logging.info("%s is not present, skipping...",srcfile) else: if fileglob=='': - cmd=("rsync -arvp %s %s") %(srcfile,destfile) + cmd = ("rsync -arvp %s %s") %(srcfile,destfile) runcmd(cmd) else: - fileglob="*" - cmd=("rsync -arvp %s/%s %s") %(srcfile,fileglob,destfile) + fileglob = "*" + 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) @@ -193,45 +193,45 @@ def runcmd(cmd): if data_config.NOOPDEBUG=="FALSE": pass else: - cmd="echo "+cmd + cmd = "echo "+cmd logging.debug(" %s",cmd) - cmdout=commands.getoutput(cmd) + cmdout = commands.getoutput(cmd) logging.debug(" %s",cmdout) return cmdout def mysqldb(cmd,inchroot): if cmd=="start": - mycmd=" /etc/rc.d/mysqld start" + mycmd = " /etc/rc.d/mysqld start" elif cmd=="stop": - mycmd=" /etc/rc.d/mysqld stop" + mycmd = " /etc/rc.d/mysqld stop" if inchroot=="chroot": - mycmd=" chroot %s" %mycmd + mycmd = " chroot %s" %mycmd runcmd(mycmd) def mount_bind_chroot(): logging.debug("Mounting dev/proc/sysfs for chroot") - cmd=" mount --bind /dev %s" %data_config.MOUNTPOINT+"/dev" + cmd = " mount --bind /dev %s" %data_config.MOUNTPOINT+"/dev" runcmd(cmd) - cmd=" mount --bind /proc %s" %data_config.MOUNTPOINT+"/proc" + cmd = " mount --bind /proc %s" %data_config.MOUNTPOINT+"/proc" runcmd(cmd) - cmd=" mount -t sysfs none %s" %data_config.MOUNTPOINT+"/sys" + cmd = " mount -t sysfs none %s" %data_config.MOUNTPOINT+"/sys" runcmd(cmd) def umount_bind_chroot(): logging.debug("UnMounting dev/proc/sysfs for chroot") - cmd=" umount -l %s" %data_config.MOUNTPOINT+"/dev" + cmd = " umount -l %s" %data_config.MOUNTPOINT+"/dev" runcmd(cmd) - cmd=" umount -l %s" %data_config.MOUNTPOINT+"/proc" + cmd = " umount -l %s" %data_config.MOUNTPOINT+"/proc" runcmd(cmd) - cmd=" umount -l %s" %data_config.MOUNTPOINT+"/sys" + cmd = " umount -l %s" %data_config.MOUNTPOINT+"/sys" runcmd(cmd) def partitions_removeall(diskdevice,label): logging.info("Removing all partitions for %s %s" ,label,diskdevice) - device=parted.getDevice(diskdevice) - partdisk=parted.Disk(device) + device = parted.getDevice(diskdevice) + partdisk = parted.Disk(device) partdisk.deleteAllPartitions() if data_config.NOOPDEBUG=="FALSE": partdisk.commit() @@ -245,10 +245,10 @@ def create_partitions(diskdevice,size,ptype,startsector): logging.info("Size is 0, skipping") return "NO" partlist = [] - newstart=0 - totalused=0 - device=parted.getDevice(diskdevice) - partdisk=parted.Disk(device) + newstart = 0 + totalused = 0 + device = parted.getDevice(diskdevice) + partdisk = parted.Disk(device) for partition in partdisk.partitions: if partition.type != parted.PARTITION_FREESPACE: partlist.append((partition, @@ -262,10 +262,10 @@ def create_partitions(diskdevice,size,ptype,startsector): for slice in partlist: (usedpartition, usedpath, usedbootable, usedstart, usedend, usedlength, usedtype, usedfs) = slice #Start the new partition one after the end of last - newstart=usedend+1 + newstart = usedend+1 if startsector==0: - newstart=0 + newstart = 0 if size=="ALL": logging.debug(" Using the rest of the disk %s",(device.length-newstart) ) try: @@ -303,24 +303,24 @@ def partition_disk(): global hostoptions logging.info("Partitioning") logging.debug("____start of partition_disk____") - rootdisk=hostoptions["rootdisk"] - datadisk=hostoptions["datadisk"] - label="root" + rootdisk = hostoptions["rootdisk"] + datadisk = hostoptions["datadisk"] + label = "root" partitions_removeall("/dev/"+rootdisk,label) - label="data" + 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) + 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) + 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 -1 -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] + rc = fscmds[fstype] except: logging.critical(" %s is not a valid fs type, exiting now",fstype) sys.exit(3) @@ -329,21 +329,21 @@ def fscmd(fstype): def format_disk(install_type): logging.info("______Starting Disk Format______") - rootfs=fscmd(hostoptions["rootfs"]) - datafs=fscmd(hostoptions["datafs"]) + rootfs = fscmd(hostoptions["rootfs"]) + datafs = fscmd(hostoptions["datafs"]) - rootdisk=hostoptions["rootdisk"] - datadisk=hostoptions["datadisk"] - rootpartition=hostoptions["rootpartition"] - datapartition=hostoptions["datapartition"] + rootdisk = hostoptions["rootdisk"] + datadisk = hostoptions["datadisk"] + rootpartition = hostoptions["rootpartition"] + datapartition = hostoptions["datapartition"] if install_type!="upgrade": - swapsize=hostoptions["swapsize"] - swappartition=hostoptions["swappartition"] + swapsize = hostoptions["swapsize"] + swappartition = hostoptions["swappartition"] 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) + cmd = " %s /dev/%s" %( rootfs , rootpartition) #os.system(cmd) runcmd(cmd) else: @@ -352,7 +352,7 @@ def format_disk(install_type): 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) + cmd = " %s /dev/%s" %( datafs , datapartition) #os.system(cmd) runcmd(cmd) else: @@ -361,7 +361,7 @@ def format_disk(install_type): if install_type=="install": if (hostoptions["swapsize"] != "NO"): logging.info("Starting format for swap %s",swappartition) - cmd=" mkswap /dev/%s" % swappartition + cmd = " mkswap /dev/%s" % swappartition #os.system(cmd) runcmd(cmd) else: @@ -374,15 +374,15 @@ def mount_it(): logging.info("______Mounting disk______") # Create mount points try: - mountpoint=data_config.MOUNTPOINT - mp=mountpoint + mountpoint = data_config.MOUNTPOINT + mp = mountpoint logging.info("Creating mountpoints %s",mp) os.makedirs(mp) except OSError: 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) @@ -390,15 +390,15 @@ def mount_it(): # Mount data #make mountpoint after mounting / try: - mountpoint=data_config.MOUNTPOINT - datapoint=data_config.DATAMOUNT - mp=mountpoint+datapoint + mountpoint = data_config.MOUNTPOINT + datapoint = data_config.DATAMOUNT + mp = mountpoint+datapoint logging.info("Creating mountpoints %s",mp) os.makedirs(mp) except OSError: 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) @@ -406,25 +406,25 @@ def mount_it(): def unmount_it(): logging.info("______Unmounting disk______") - cmd="umount %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) + cmd = "umount %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) runcmd(cmd) time.sleep(2) - cmd="swapoff /dev/%s" %(hostoptions["swappartition"]) + cmd = "swapoff /dev/%s" %(hostoptions["swappartition"]) runcmd(cmd) - cmd="sync" + cmd = "sync" runcmd(cmd) - cmd="umount %s" %(data_config.MOUNTPOINT) + cmd = "umount %s" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="sync" + cmd = "sync" runcmd(cmd) def create_squashlist(): logging.debug("Creating squashlist") - squashfile=data_config.SQUASHFILE + squashfile = data_config.SQUASHFILE f = open(squashfile, 'w') for i in data_config.SQUASHLIST: f.write(i) @@ -438,7 +438,7 @@ def copy_it(install_type): logging.debug( install_type) if ( install_type == "install"): logging.info("Transferring system") - cmd=" unsquashfs -f -d %s /.livesys/medium/system.sqf" %(data_config.MOUNTPOINT) + cmd = " unsquashfs -f -d %s /.livesys/medium/system.sqf" %(data_config.MOUNTPOINT) runcmd(cmd) #logging.debug(cmd) #cmdout=commands.getoutput(cmd) @@ -446,58 +446,58 @@ 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") - mountpoint=data_config.MOUNTPOINT + 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 + mp = mountpoint+"/"+item logging.info("Creating mountpoints %s",mp) os.makedirs(mp) except OSError: logging.debug(" __Could not create %s",mp) # General fixup - cmd="chmod 777 %s/tmp" %(data_config.MOUNTPOINT) + cmd = "chmod 777 %s/tmp" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="mknod %s/dev/null c 1 5" %(data_config.MOUNTPOINT) + cmd = "mknod %s/dev/null c 1 5" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="mknod %s/dev/console c 5 1" %(data_config.MOUNTPOINT) + cmd = "mknod %s/dev/console c 5 1" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="chmod +s %s/usr/bin/Xorg" %(data_config.MOUNTPOINT) + cmd = "chmod +s %s/usr/bin/Xorg" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="chmod +s %s/usr/bin/crontab" %(data_config.MOUNTPOINT) + cmd = "chmod +s %s/usr/bin/crontab" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="chmod +s %s/usr/bin/sudo" %(data_config.MOUNTPOINT) + cmd = "chmod +s %s/usr/bin/sudo" %(data_config.MOUNTPOINT) runcmd(cmd) - cmd="chmod +s %s/bin/mount" %(data_config.MOUNTPOINT) + cmd = "chmod +s %s/bin/mount" %(data_config.MOUNTPOINT) runcmd(cmd) logging.debug("__End of copy_it__") def create_fstab(extralines): logging.debug("______Creating new fstab file_______") logging.info("Creating new fstab file") - fstabfile=data_config.MOUNTPOINT+"/etc/fstab" - fstab_list=[] + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" + fstab_list = [] f = open(fstabfile, 'w') - line="# <file system> <dir> <type> <options> <dump> <pass> \n" + line = "# <file system> <dir> <type> <options> <dump> <pass> \n" fstab_list.append(line) - line="none /dev/pts devpts defaults 0 0 \n" + line = "none /dev/pts devpts defaults 0 0 \n" fstab_list.append(line) - line="none /dev/shm tmpfs defaults 0 0\n" + 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" + line = "UUID=SWAPUID swap swap defaults 0 0 \n" fstab_list.append(line) for vline in extralines: fstab_list.append(vline) @@ -508,23 +508,23 @@ def create_fstab(extralines): def find_uuid(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('"',"") + cmd = "blkid -s UUID /dev/%s" %partition + tmpuuid = runcmd(cmd) + splituuid = tmpuuid.partition("=") + 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=[] + vglines = [] f = open("/tmp/etc/fstab", 'r') - oldfscontents=f.readlines() + oldfscontents = f.readlines() for line in oldfscontents: if line.startswith("/dev/vg"): vglines.append(line) - templine=line.split() - mdir=templine[1] + templine = line.split() + mdir = templine[1] if not os.path.exists (mdir): logging.debug("Creating dir %s for VG mount",mdir) os.makedirs (mdir) @@ -535,13 +535,13 @@ def pick_out_vg(): def fstab_it(install_type): logging.info("______Checking fstab______") - kmvg=[] - fstabfile=data_config.MOUNTPOINT+"/etc/fstab" + kmvg = [] + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" # 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") - kmvg=pick_out_vg() + kmvg = pick_out_vg() create_fstab(kmvg) elif os.path.exists("/tmp/etc/fstab"): logging.debug(" Upgrade and not Knoppmyth, using old fstab") @@ -553,28 +553,28 @@ def fstab_it(install_type): create_fstab(kmvg) logging.info("____UUID check for %s" , "swap") - swapuuid=find_uuid(hostoptions["swappartition"]) + swapuuid = find_uuid(hostoptions["swappartition"]) logging.info("____UUID check for %s" , "data") - datauuid=find_uuid(hostoptions["datapartition"]) + datauuid = find_uuid(hostoptions["datapartition"]) logging.info("____UUID check for %s" , "root") - rootuuid=find_uuid(hostoptions["rootpartition"]) + rootuuid = find_uuid(hostoptions["rootpartition"]) - fstabfile=data_config.MOUNTPOINT+"/etc/fstab" + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" logging.info("Correcting UUID's in %s",fstabfile) f = open(fstabfile, 'r') - oldfscontents=f.readlines() - newfstab=[] + oldfscontents = f.readlines() + newfstab = [] f.close for line in oldfscontents: if line.startswith("UUID"): - templine=line.split() + templine = line.split() if ( templine[1] == "/"): logging.debug(" Found Root fstab line:") logging.debug( templine) - templine[0]="UUID=%s" %(rootuuid) - newline='' + templine[0] = "UUID=%s" %(rootuuid) + newline = '' for i in templine: newline+=i newline+=" " @@ -586,8 +586,8 @@ def fstab_it(install_type): if ( templine[1] == data_config.DATAMOUNT): logging.debug(" Found DATA mount") logging.debug( templine) - templine[0]="UUID=%s" %(datauuid) - newline='' + templine[0] = "UUID=%s" %(datauuid) + newline = '' for i in templine: newline+=i newline+=" " @@ -602,8 +602,8 @@ def fstab_it(install_type): else: logging.debug(" Found swap partition") logging.debug( templine) - templine[0]="UUID=%s" %(swapuuid) - newline='' + templine[0] = "UUID=%s" %(swapuuid) + newline = '' for i in templine: newline+=i newline+=" " @@ -626,27 +626,27 @@ def fstab_it(install_type): def grub_it(): logging.info("______Start of grub install______") - cmd=" grub-install --recheck --no-floppy --root-directory=%s \"(hd0)\" " % data_config.MOUNTPOINT + cmd = " grub-install --recheck --no-floppy --root-directory=%s \"(hd0)\" " % data_config.MOUNTPOINT logging.info("Running grub-install") runcmd(cmd) - rootuuid=find_uuid(hostoptions["rootpartition"]) - cmd=" mkinitcpio -g %s/boot/kernel26.img" % data_config.MOUNTPOINT + rootuuid = find_uuid(hostoptions["rootpartition"]) + cmd = " mkinitcpio -g %s/boot/kernel26.img" % data_config.MOUNTPOINT logging.info("Running mkinitcpio") runcmd(cmd) logging.info("Adding root uuid to grub menu") - grubfile=data_config.MOUNTPOINT+"/boot/grub/menu.lst" + grubfile = data_config.MOUNTPOINT+"/boot/grub/menu.lst" try: f = open(grubfile, 'r') - oldgrub=f.readlines() - newgrub=[] + oldgrub = f.readlines() + newgrub = [] f.close for line in oldgrub: if line.startswith("kernel"): - templine=line.split() + templine = line.split() logging.debug(" Found kernel Root grubline:") logging.debug( templine) - templine[2]="root=/dev/disk/by-uuid/%s" %(rootuuid) - newline='' + templine[2] = "root=/dev/disk/by-uuid/%s" %(rootuuid) + newline = '' for i in templine: newline+=i newline+=" " @@ -670,38 +670,38 @@ def grub_it(): def fix_permissions(): logging.info("Fixing permissions") - SE=os.environ["TEMPLATES"]+"/settings/syssettings" - cmd=" chmod -R 755 %s" %(data_config.MOUNTPOINT+SE) + SE = os.environ["TEMPLATES"]+"/settings/syssettings" + cmd = " chmod -R 755 %s" %(data_config.MOUNTPOINT+SE) runcmd(cmd) - cmd=" chmod 755 %s" %(data_config.MOUNTPOINT+"/etc/systemconfig") + cmd = " chmod 755 %s" %(data_config.MOUNTPOINT+"/etc/systemconfig") runcmd(cmd) - cmd=" chmod 755 %s" %(data_config.MOUNTPOINT+"/root") + cmd = " chmod 755 %s" %(data_config.MOUNTPOINT+"/root") runcmd(cmd) - cmd=" chown root:mythtv %s" %(data_config.MOUNTPOINT+"/etc/systemconfig") + cmd = " chown root:mythtv %s" %(data_config.MOUNTPOINT+"/etc/systemconfig") runcmd(cmd) - cmd=" chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+SE) + cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+SE) runcmd(cmd) - cmd=" chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+"/var/log/mythtv") + cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+"/var/log/mythtv") runcmd(cmd) def apply_new_auth(): logging.info("_____Applying Password updates_______") - passfile="/root/myth_user_call.out" + passfile = "/root/myth_user_call.out" try: - MVROOT=os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"] except: logging.debug("MVROOT was not defined, using the default value") - MVROOT="/usr/MythVantage" + MVROOT = "/usr/MythVantage" if data_config.NOOPDEBUG=="FALSE": - cmdprefix="chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i " + cmdprefix = "chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i " else: - cmdprefix="echo chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i " + cmdprefix = "echo chroot " + data_config.MOUNTPOINT + " " + MVROOT+"/bin/myth_user_call -i " try: f = open(passfile, 'r') - passcmds=f.readlines() + passcmds = f.readlines() f.close for cmd in passcmds: - execmd=cmdprefix+cmd + execmd = cmdprefix+cmd # Using os.system because runcmd fails logging.debug(execmd) os.system(execmd) @@ -712,15 +712,15 @@ def apply_new_auth(): def swapsearch(): #currently unused! partlist = [] - stddir=os.getcwd() + stddir = os.getcwd() os.chdir("/sys/block") - partitionlist=glob.glob("*") + partitionlist = glob.glob("*") for item in partitionlist: try: - newitem=item.strip().rpartition(" ")[2] + newitem = item.strip().rpartition(" ")[2] if (not newitem=='') and (not newitem.startswith("loop")): - path="/dev/"+newitem.strip() - path=path.strip() + path = "/dev/"+newitem.strip() + path = path.strip() device = parted.getDevice(path) (cylinders, heads, sectors) = device.biosGeometry sizeInBytes = device.length * device.sectorSize @@ -750,11 +750,11 @@ def swapsearch(): 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') - filecontents=f.readlines() + filecontents = f.readlines() f.close except: logging.debug(" Couldn't find file %s to sane",file) @@ -772,14 +772,14 @@ def sane_settings(file): def restore_default_settings(): try: - MVROOT=os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"] except: logging.debug(" MVROOT was not defined, using the default value") - MVROOT="/usr/MythVantage" + 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/" + SE = os.environ["TEMPLATES"]+"/settings/syssettings/" cp_and_log(SE,data_config.MOUNTPOINT+SE) cp_and_log("/etc/mtab",data_config.MOUNTPOINT+"/etc/mtab") copy_updates() @@ -788,10 +788,10 @@ def restore_default_settings(): def full_install(hostoptions): logging.info("______Start of full install______") try: - MVROOT=os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"] except: logging.debug(" MVROOT was not defined, using the default value") - MVROOT="/usr/MythVantage" + MVROOT = "/usr/MythVantage" try: os.remove("/tmp/.this_is_upgrade") @@ -799,7 +799,7 @@ def full_install(hostoptions): logging.debug(" File /tmp/.this_is_upgrade not present, couldn't delete it") pass # Partition disk - statusmsg="Partitioning %s" %( hostoptions["rootdisk"]) + statusmsg = "Partitioning %s" %( hostoptions["rootdisk"]) update_status(statusmsg) progress(1) if data_config.NOOPDEBUG=="FALSE": @@ -808,14 +808,14 @@ def full_install(hostoptions): logging.debug(" Debug mode, skipping partitioning step") # Format disk - statusmsg="Preparing %s" %( hostoptions["rootdisk"]) + statusmsg = "Preparing %s" %( hostoptions["rootdisk"]) update_status(statusmsg) progress(2) format_disk("install") # Mount partitions - statusmsg="Mounting %s" %( hostoptions["rootdisk"]) + statusmsg = "Mounting %s" %( hostoptions["rootdisk"]) update_status(statusmsg) progress(3) mount_it() @@ -823,20 +823,20 @@ def full_install(hostoptions): # Find number of bytes written to disk before starting copy. This is used # to have a somewhat decent progress indication. statgrab( hostoptions["rootdisk"]) - msg="Creating %s" %(systemconfig["hostname"]) + msg = "Creating %s" %(systemconfig["hostname"]) update_status(msg) # Copy system to disk copy_it("install") # Remove old fstab so that a new one is created - fstabfile=data_config.MOUNTPOINT+"/etc/fstab" + fstabfile = data_config.MOUNTPOINT+"/etc/fstab" try: os.remove(fstabfile) except OSError: logging.debug(" ERROR: deleting %s",fstabfile) fstab_it("full_install") # Configure system - msg="Configuring system" + msg = "Configuring system" update_status(msg) progress(98) grub_it() @@ -865,10 +865,10 @@ def full_install(hostoptions): logging.info("______Installing Database in CHROOT________") 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") kill_dhcp_chroot() @@ -878,26 +878,26 @@ def full_install(hostoptions): else: 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" + 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") @@ -915,18 +915,18 @@ def find_upgrade(): 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 + 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) - hostoptions["backupfile"]=newbackupfile + hostoptions["backupfile"] = newbackupfile cp_and_log(oldbackupfile,newbackupfile) - srcfile=data_config.MOUNTPOINT+"/etc/systemconfig" + srcfile = data_config.MOUNTPOINT+"/etc/systemconfig" logging.info("Searching for systemconfig file %s",srcfile) if os.path.exists(srcfile): - logging.info("Found systemconfig file %s",srcfile) - TEMPLATES=os.environ["TEMPLATES"]+"/settings/syssettings" + logging.info("Found systemconfig file %fs",srcfile) + TEMPLATES = os.environ["TEMPLATES"]+"/settings/syssettings" 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,'') @@ -945,13 +945,13 @@ def 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='' + fstab_list = [] + fstab_data_mount = '' try: f = open("/tmp/etc/fstab", 'r') - oldfscontents=f.readlines() + oldfscontents = f.readlines() f.close() ## ['UUID=', '/myth', 'auto', 'defaults,noatime', '0', '1'] #for line in oldfscontents: @@ -972,7 +972,7 @@ def upgrade_mount_search(): #search fstab for data/myth mountpoint for i in fstab_list: if i[1]==data_config.DATAMOUNT: - fstab_data_mount=i[0] + fstab_data_mount = i[0] break #start software raid support if needed @@ -983,85 +983,86 @@ def upgrade_mount_search(): if re.search("UUID",fstab_data_mount): - fstab_data_uuid=fstab_data_mount.split("=")[1] - cmd="blkid -t UUID=%s" %fstab_data_uuid + fstab_data_uuid = fstab_data_mount.split("=")[1] + cmd = "blkid -t UUID=%s" %fstab_data_uuid retcode = call(cmd, shell=True) if retcode != 0: 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 + cmd = "blkid -t UUID=%s|cut -d: -f1" %fstab_data_uuid logging.debug(cmd) - datadisk=commands.getoutput(cmd) - cmd="basename %s" %datadisk - datadisk=commands.getoutput(cmd) + datadisk = commands.getoutput(cmd) + 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) + cmd = "basename %s" %fstab_data_mount + datadisk = commands.getoutput(cmd) time.sleep(3) # hostoptions["backupfile"]=data_config.BACKUPPATH+data_config.BACKUPFILE if not backup_sql_check(): - newbackupfile="/tmp/"+data_config.BACKUPFILE + newbackupfile = "/tmp/"+data_config.BACKUPFILE if os.path.exists(newbackupfile): logging.debug("Setting backup file to %s",newbackupfile) - hostoptions["backupfile"]=newbackupfile + hostoptions["backupfile"] = newbackupfile else: logging.info("Couldn't find any database to restore, upgrade will continue with a new database") def upgrade(hostoptions): -# unmount_it() -# find_upgrade() + try: - MVROOT=os.environ["MV_ROOT"] + MVROOT = os.environ["MV_ROOT"] except: logging.debug("MVROOT was not defined, using the default value") - MVROOT="/usr/MythVantage" + MVROOT = "/usr/MythVantage" logging.info("______Start of upgrade______") - cmd="touch /tmp/.this_is_upgrade" + cmd = "touch /tmp/.this_is_upgrade" runcmd(cmd) if hostoptions["rootfs"] == "Do_not_format": logging.info("Will not format root filesystem") else: - statusmsg="Preparing %s" %( hostoptions["rootdisk"]) + statusmsg = "Preparing %s" %( hostoptions["rootdisk"]) update_status(statusmsg) progress(2) format_disk("upgrade") #sys.exit(2) - statusmsg="Mounting %s" %( hostoptions["rootdisk"]) + statusmsg = "Mounting %s" %( hostoptions["rootdisk"]) update_status(statusmsg) progress(3) mount_it() - hostoptions["backupfile"]=data_config.MOUNTPOINT+data_config.BACKUPPATH+data_config.BACKUPFILE + hostoptions["backupfile"] = data_config.MOUNTPOINT+data_config.BACKUPPATH+data_config.BACKUPFILE statgrab( hostoptions["rootdisk"]) - msg="Upgrading %s" %(systemconfig["hostname"]) + msg = "Upgrading %s" %(systemconfig["hostname"]) update_status(msg) time.sleep(3) copy_it("upgrade") + 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") - srcfile="%s/etc.old/ssh/" %(data_config.MOUNTPOINT) - destfile="%s/etc/ssh/" %(data_config.MOUNTPOINT) + 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') - mdfile=mdadm_find("/tmp") + mdfile = mdadm_find("/tmp") 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) + 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") - msg="Configuring system" + msg = "Configuring system" update_status(msg) progress(98) @@ -1080,43 +1081,43 @@ def upgrade(hostoptions): 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","") 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) + cmd = " chown -R mythtv:mythtv %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT) runcmd(cmd) - cmd=" chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup") + 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') apply_new_auth() @@ -1125,7 +1126,7 @@ def upgrade(hostoptions): 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" + msg = "Done" update_status(msg) mysqldb("start",'') @@ -1147,7 +1148,7 @@ def main(argv): sys.exit(0) elif opt in ( "--rootdisk"): hostoptions["rootdisk"] = arg - hostoptions["rootpartition"]=arg+str(1) + hostoptions["rootpartition"] = arg+str(1) elif opt in ("--rootfs"): hostoptions["rootfs"] = arg elif opt in ("--rootsize"): @@ -1164,7 +1165,7 @@ 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) sys.exit(2) @@ -1173,19 +1174,19 @@ def main(argv): try: hostoptions["datadisk"] except: - hostoptions["datadisk"]=hostoptions["rootdisk"] - hostoptions["datapartition"]=hostoptions["datadisk"]+str(3) + hostoptions["datadisk"] = hostoptions["rootdisk"] + hostoptions["datapartition"] = hostoptions["datadisk"]+str(3) try: hostoptions["datapartition"] except: - hostoptions["datapartition"]=hostoptions["datadisk"]+str(3) - hostoptions["swappartition"] = hostoptions["rootdisk"] + str(2) + hostoptions["datapartition"] = hostoptions["datadisk"]+str(3) + hostoptions["swappartition"] = hostoptions["rootdisk"] + str(2) if ( hostoptions["op"] == "full_install" ) : full_install(hostoptions) elif (hostoptions["op"] == "upgrade" ) : - hostoptions["datafs"]="no_format" + hostoptions["datafs"] = "no_format" find_upgrade() upgrade(hostoptions) elif (hostoptions["op"] == "find_upgrade" ) : @@ -1195,7 +1196,7 @@ def main(argv): #____________________________________________setup the logging______________________________________________________ LOG_FILENAME = '/tmp/mv_status.log' -DEBUGLOG='/tmp/mv_debug.log' +DEBUGLOG = '/tmp/mv_debug.log' logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%m-%d %H:%M', @@ -1223,18 +1224,22 @@ logging.getLogger('').addHandler(infofile) global systemconfig systemconfig = {} file_name = "/etc/systemconfig" -config_file= open(file_name) +try: + config_file = open(file_name) +except: + 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) - val=val.strip('"') + val = val.strip('"') systemconfig[var.strip()] = val.strip() if __name__ == "__main__": - config_file="mv_config" + config_file = "mv_config" data_config = __import__(config_file, globals(), locals(), []) cmdoptions = main(sys.argv[1:]) |