summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_install.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-09-09 01:45:21 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-09-09 01:45:21 (GMT)
commit86a66e21bf7b444dbab401e699da74df38fb9dcf (patch)
tree263609e312ab003d22cad7f56782b02886a4edca /abs/core/LinHES-config/mv_install.py
parent0afe907bbdea5161538713ca313d19ffc737a483 (diff)
downloadlinhes_pkgbuild-86a66e21bf7b444dbab401e699da74df38fb9dcf.zip
linhes_pkgbuild-86a66e21bf7b444dbab401e699da74df38fb9dcf.tar.gz
linhes_pkgbuild-86a66e21bf7b444dbab401e699da74df38fb9dcf.tar.bz2
LinHES-config/system/install: first checkin to get 5 partition upgrade layout working
Diffstat (limited to 'abs/core/LinHES-config/mv_install.py')
-rwxr-xr-xabs/core/LinHES-config/mv_install.py333
1 files changed, 196 insertions, 137 deletions
diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py
index 3bdd791..a447851 100755
--- a/abs/core/LinHES-config/mv_install.py
+++ b/abs/core/LinHES-config/mv_install.py
@@ -22,7 +22,7 @@ def usage():
print " rootfs=ext4"
print " rootsize=5000"
print " datafs=reiserfs"
- print " datasize=ALL"
+ print " datasize=all"
print " datadisk=sda"
print " swapsize=200"
print " op=full_install"
@@ -325,7 +325,7 @@ def create_partitions(diskdevice, size, ptype, startsector):
if startsector == 0:
newstart = 2048
- if size == "ALL":
+ 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))
@@ -403,7 +403,7 @@ def partition_disk():
hostoptions["swappartition"] = create_partitions("/dev/"+rootdisk, hostoptions["swapsize"], "SWAP", 1)
#create extended partition
- hostoptions["extended_partition"] = create_partitions("/dev/"+rootdisk, "ALL", "EXTENDED", 1)
+ hostoptions["extended_partition"] = create_partitions("/dev/"+rootdisk, "all", "EXTENDED", 1)
#create the logical in the extended
hostoptions["home_partition"] = create_partitions("/dev/"+rootdisk, hostoptions["homesize"], "LOGICAL", 1)
@@ -424,8 +424,8 @@ def fscmd(fstype):
"ext3": "mkfs.ext3",
"jfs":"mkfs.jfs -q",
"ext4":"mkfs.ext4",
- "Do_not_format":"noformat",
- "no_format":"noformat",
+ "Do_not_format":"no_format",
+ "no_format":"no_format",
"btrfs":"mkfs.btrfs"}
try:
rc = fscmds[fstype]
@@ -453,14 +453,22 @@ def format_disk(install_type):
sqlpartition = hostoptions["sql_partition"]
+ #if install_type != "upgrade":
+ #swapsize = hostoptions["swapsize"]
+ #swappartition = hostoptions["swappartition"]
- if install_type != "upgrade":
- swapsize = hostoptions["swapsize"]
+ if install_type == "install":
swappartition = hostoptions["swappartition"]
+ if (hostoptions["swapsize"] != "NO"):
+ 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(" Format command for rootfs %s : %s ", rootfs, rootpartition)
-
- if ( rootfs != "noformat"):
+ if ( rootfs != "no_format"):
logging.info(" Starting %s format of %s", rootfs, rootpartition)
cmd = " %s /dev/%s" %( rootfs, rootpartition)
#os.system(cmd)
@@ -469,7 +477,7 @@ def format_disk(install_type):
logging.info(" Will not format root partition: %s", rootpartition)
logging.debug(" Format command for datafs %s : %s ", datafs, datapartition)
- if (datafs != "noformat"):
+ if (datafs != "no_format"):
logging.info(" Starting format %s of %s", datafs, datapartition)
cmd = " %s /dev/%s" %( datafs, datapartition)
#os.system(cmd)
@@ -477,39 +485,31 @@ def format_disk(install_type):
else:
logging.info(" Will not format data partition: %s", datapartition)
- if install_type == "install":
- if (hostoptions["swapsize"] != "NO"):
- 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")
-
- if ( homefs != "noformat"):
- logging.info(" Starting format %s of %s", homefs, homepartition)
- cmd = " %s /dev/%s" %( homefs, homepartition)
- #os.system(cmd)
- runcmd(cmd)
- else:
- logging.info(" Will not format home partition: %s", homepartition)
+ #for upgrades format is set to no_format
+ if ( homefs != "no_format"):
+ logging.info(" Starting format %s of %s", homefs, homepartition)
+ cmd = " %s /dev/%s" %( homefs, homepartition)
+ #os.system(cmd)
+ runcmd(cmd)
+ else:
+ logging.info(" Will not format home partition: %s", homepartition)
- if ( sqlfs != "noformat"):
- logging.info(" Starting format %s of %s", sqlfs, sqlpartition)
- cmd = " %s /dev/%s" %( sqlfs, sqlpartition)
- #os.system(cmd)
- runcmd(cmd)
- else:
- logging.info(" Will not format sql partition: %s", sqlpartition)
+ if ( sqlfs != "no_format"):
+ logging.info(" Starting format %s of %s", sqlfs, sqlpartition)
+ cmd = " %s /dev/%s" %( sqlfs, sqlpartition)
+ #os.system(cmd)
+ runcmd(cmd)
+ else:
+ logging.info(" Will not format sql partition: %s", sqlpartition)
- logging.debug(" Format command for datafs %s : %s ", datafs, datapartition)
- if (datafs != "noformat"):
- logging.info(" Starting format %s of %s", datafs, datapartition)
- cmd = " %s /dev/%s" %( datafs, datapartition)
- #os.system(cmd)
- runcmd(cmd)
- else:
- logging.info(" Will not format data partition: %s", datapartition)
+ logging.debug(" Format command for datafs %s : %s ", datafs, datapartition)
+ if (datafs != "no_format"):
+ logging.info(" Starting format %s of %s", datafs, datapartition)
+ cmd = " %s /dev/%s" %( datafs, datapartition)
+ #os.system(cmd)
+ runcmd(cmd)
+ else:
+ logging.info(" Will not format data partition: %s", datapartition)
logging.debug("_____End of format______")
@@ -779,7 +779,8 @@ def copy_it(install_type):
if ( install_type == "upgrade"):
logging.info("Upgrading system")
- cmdlist = ['rsync -arp /image_mount/root/* /new_boot',
+
+ cmdlist = ['rsync -arp --exclude /home --exclude /data/srv/mysql /image_mount/root/* /new_boot',
'rsync -arp /image_mount/lib/* /new_boot/lib/',
'rsync -arp /image_mount/usr /new_boot',
'rsync -arp /image_mount/var /new_boot']
@@ -1019,7 +1020,7 @@ def fstab_it(install_type):
newfstab.append(newline)
elif ( templine[1] == data_config.SQLMOUNT):
- logging.debug(" Found HOME mount")
+ logging.debug(" Found database mount")
logging.debug( templine)
templine[0] = "UUID=%s" %(sqluuid)
if sqlacl:
@@ -1044,10 +1045,10 @@ def fstab_it(install_type):
for i in templine:
newline+=i
newline+=" "
- newline+="\n"
- logging.debug(" New fstab line:")
- logging.debug( newline)
- newfstab.append(newline)
+ newline+="\n"
+ logging.debug(" New fstab line:")
+ logging.debug( newline)
+ newfstab.append(newline)
else:
logging.debug(" Line didn't match, adding to newfstab:")
logging.debug( line)
@@ -1744,15 +1745,18 @@ def upgrade_mount_search():
def upgrade(hostoptions):
-
try:
MVROOT = os.environ["MV_ROOT"].strip()
except:
logging.debug("MVROOT was not defined, using the default value")
MVROOT = "/usr/MythVantage"
+ hostoptions["backupfile"] = data_config.BACKUPPATH+data_config.BACKUPFILE
+
logging.info("______Start of upgrade______")
cmd = "touch /tmp/.this_is_upgrade"
runcmd(cmd)
+
+ #format disk
if hostoptions["rootfs"] == "Do_not_format":
logging.info("Will not format root filesystem")
else:
@@ -1760,18 +1764,26 @@ def upgrade(hostoptions):
update_status(statusmsg)
progress(2)
format_disk("upgrade")
- #sys.exit(2)
+
+ #mount partitions
statusmsg = "Mounting %s" %( hostoptions["rootdisk"])
update_status(statusmsg)
progress(3)
mount_it()
swapon()
+
hostoptions["backupfile"] = data_config.BACKUPPATH+data_config.BACKUPFILE
+ #Find number of bytes written to disk before starting copy. This is used to
+ #give a somewhat decent progress indication
statgrab( hostoptions["rootdisk"])
msg = "Upgrading %s" %(systemconfig["hostname"])
update_status(msg)
time.sleep(3)
+
+ #copy system to disk
copy_it("upgrade")
+
+ #Restore /etc and key files. This is the copy found when running find_upgrade
cmd = "rm -rf %s/etc.old" %data_config.MOUNTPOINT
runcmd(cmd)
cmd = "rm -rf %s/alsa.old" %data_config.MOUNTPOINT
@@ -1812,14 +1824,19 @@ def upgrade(hostoptions):
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"
+
+ #configure system
+ msg = "Configuring system"
update_status(msg)
progress(98)
logging.info("______Configuring system________")
cp_and_log("/etc/systemconfig", data_config.MOUNTPOINT+"/etc/systemconfig")
- if not backup_sql_check():
- upgrade_mount_search()
+ #New partition layout, we do not need to search for backup file
+ #if not backup_sql_check():
+ #upgrade_mount_search()
+
+ #check fstab, see if it needs any updates
fstab_it("upgrade")
time.sleep(1)
@@ -1829,10 +1846,12 @@ def upgrade(hostoptions):
genlocale()
time.sleep(1)
- #needed to get around a bug with pacman
+
special_hardware_check()
cp_and_log("/root/xorg.conf.install", data_config.MOUNTPOINT+"/etc/X11/xorg.conf.install")
+ #this was needed to get around a pacman bug
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")
restore_default_settings()
@@ -1840,53 +1859,67 @@ def upgrade(hostoptions):
file = "%s/%s/.kmupgrade" %(data_config.MOUNTPOINT, data_config.MYTHHOME)
cmd = "touch %s && chmod 777 %s" %(file, file)
runcmd(cmd)
+
+ #these are also run by restore_default_settings in install
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 all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
- rc = runcmd(cmd)[0]
- if rc != 0 :
- error_out("Running systemconfig")
- mysqldb("stop", "")
+ apply_new_auth()
+ umount_bind_chroot()
+
+
+ #logging.info("Running systemconfig in chroot")
+ #cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ #rc = runcmd(cmd)[0]
+ #if rc != 0 :
+ #error_out("Running systemconfig")
+ #mysqldb("stop", "")
+
if ( systemconfig["SystemType"] == "Master_backend" or systemconfig["SystemType"] == "Standalone" ):
- if clean_upgrade() or not backup_sql_check():
+ if clean_upgrade():
+ mysqldb("stop", "")
+ mount_bind_chroot()
logging.info("Installing new database")
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"])
- runcmd(cmd)
+ umount_bind_chroot()
- if os.path.exists("/tmp/etc/KnoppMyth-version"):
- cmd = "chroot %s %s/bin/myth_settings_wrapper.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)
- runcmd(cmd)
- cmd = "chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup")
- runcmd(cmd)
- else:
- cmd = "chroot %s %s/bin/myth_settings_wrapper.sh -c restore -t syssettings " %(data_config.MOUNTPOINT, MVROOT)
- runcmd(cmd)
+ #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)
+ #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"])
+ #runcmd(cmd)
+
+ #if os.path.exists("/tmp/etc/KnoppMyth-version"):
+ #cmd = "chroot %s %s/bin/myth_settings_wrapper.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)
+ #runcmd(cmd)
+ #cmd = "chown -R root:root %s" %(data_config.MOUNTPOINT+data_config.DATAMOUNT+"/backup")
+ #runcmd(cmd)
+ #else:
+ #cmd = "chroot %s %s/bin/myth_settings_wrapper.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)
+ #run systemconfig in chroot
+ mount_bind_chroot()
+ logging.info("Running systemconfig in chroot time")
cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
rc = runcmd(cmd)[0]
if rc != 0 :
error_out("Running systemconfig")
- #logging.info("Running systemconfig in chroot")
- #cmd = " chroot %s %s/bin/systemconfig.sh advanced" %(data_config.MOUNTPOINT, MVROOT)
- #runcmd(cmd)
- mysqldb("stop", 'chroot')
- apply_new_auth()
- kill_dhcp_chroot()
umount_bind_chroot()
+ kill_dhcp_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")
+
unmount_it()
msg = "Done"
update_status(msg)
@@ -1899,83 +1932,109 @@ def main(argv):
print install_conf
global hostoptions
hostoptions = {}
- conflist=["rootdisk","rootfs","rootsize",
+ conflist=["op",
+ "rootdisk","rootfs","rootsize",
"datafs","datasize","datadisk","datapartition",
- "swapsize","op","homesize","sqlsize"]
+ "swapsize",
+ "homesize","homefs",
+ "sqlsize","sqlfs",
+ "uprootfs"]
for i in conflist:
try:
- hostoptions[i] = install_conf[i]
+ hostoptions[i] = install_conf[i].lower()
except:
pass
- hostoptions["sqlfs"] = hostoptions["rootfs"]
- hostoptions["homefs"] = hostoptions["rootfs"]
+ try: #op is not set for find_upgrade
+ if hostoptions["op"] == "upgrade":
+ #rootfs is used by both upgrade and install
+ hostoptions["rootfs"] == hostoptions["uprootfs"]
+ except:
+ pass
- if len(hostoptions) < 1:
- try:
- opts, args = getopt.getopt(argv, 'c:h', ["help", "rootdisk=", "rootfs=", "rootsize=", "datafs=", "datasize=", "datadisk=", "swapsize=", "datapartition=" ] )
- except getopt.GetoptError, why:
- print why
+ try:
+ 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"):
usage()
- sys.exit(2)
- hostoptions = {"op": 'null'}
- for opt, arg in opts:
- if opt in ("-h", "--help"):
- usage()
- sys.exit(0)
- elif opt in ( "--rootdisk"):
- hostoptions["rootdisk"] = arg
- hostoptions["rootpartition"] = arg+str(1)
- elif opt in ("--rootfs"):
- hostoptions["rootfs"] = arg
- elif opt in ("--rootsize"):
- hostoptions["rootsize"] = arg
- elif opt in ("--datafs"):
- hostoptions["datafs"] = arg
- elif opt in ("--datasize"):
- hostoptions["datasize"] = arg
- elif opt in ("--datadisk"):
- hostoptions["datadisk"] = arg
- elif opt in ("--datapartition"):
- hostoptions["datapartition"] = arg
- elif opt in ("--swapsize"):
- hostoptions["swapsize"] = arg
-
- elif opt in ("-c"):
- 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)
- else:
- hostoptions["op"] = arg
+ sys.exit(0)
+ elif opt in ( "--rootdisk"):
+ hostoptions["rootdisk"] = arg
+ hostoptions["rootpartition"] = arg+str(1)
+ elif opt in ("--rootfs"):
+ hostoptions["rootfs"] = arg
+ elif opt in ("--rootsize"):
+ hostoptions["rootsize"] = arg
+ elif opt in ("--datafs"):
+ hostoptions["datafs"] = arg
+ elif opt in ("--datasize"):
+ hostoptions["datasize"] = arg
+ elif opt in ("--datadisk"):
+ hostoptions["datadisk"] = arg
+ elif opt in ("--datapartition"):
+ hostoptions["datapartition"] = arg
+ elif opt in ("--swapsize"):
+ hostoptions["swapsize"] = arg
+
+ elif opt in ("-c"):
+ 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)
+ else:
+ hostoptions["op"] = arg
validop = ["full_install", "upgrade", "netboot", "find_upgrade"]
if hostoptions["op"] not in validop:
logging.critical("-c %s is not a valid option", hostoptions["op"])
sys.exit(2)
- try:
- hostoptions["datadisk"]
- except:
- 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)
+ if ( hostoptions["op"] == "upgrade") or ( hostoptions["op"] == "find_upgrade" ):
+ hostoptions["datafs"] = "no_format"
+ hostoptions["homefs"] = "no_format"
+ hostoptions["sqlfs"] = "no_format"
+
+ #hardcoding partitions
+ hostoptions["rootpartition"] = hostoptions["rootdisk"]+str(1) ##hardcoded partition 1
+ hostoptions["swappartition"] = hostoptions["rootdisk"] + str(2)
+
+ try:
+ hostoptions["datadisk"]
+ except:
+ hostoptions["datadisk"] = hostoptions["rootdisk"]
+ #home/sql do not needed to be valid values for the upgrade, but using real values for reference
+ try:
+ hostoptions["home_partition"]
+ except:
+ hostoptions["home_partition"] = hostoptions["rootdisk"]+str(5)
+
+ try:
+ hostoptions["sql_partition"]
+ except:
+ hostoptions["sql_partition"] = hostoptions["rootdisk"]+str(6)
+
+ try:
+ hostoptions["datapartition"]
+ except:
+ hostoptions["datapartition"] = hostoptions["datadisk"]+str(7)
if ( hostoptions["op"] == "full_install" ) :
full_install(hostoptions)
+
elif (hostoptions["op"] == "upgrade" ) :
- hostoptions["datafs"] = "no_format"
find_upgrade()
upgrade(hostoptions)
+
elif (hostoptions["op"] == "find_upgrade" ) :
find_upgrade()
return hostoptions
@@ -2027,7 +2086,7 @@ for line in config_file:
#Read in install_conf
global install_conf
install_conf = {}
-file_name = "/tmp/install_conf"
+file_name = "/etc/install_layout"
try:
config_file = open(file_name)
except: