def doGrubCfg(startconf, group, kopts): grubcfg = constants.LINBOGRUBDIR + '/' + group + '.cfg' rc, content = readTextfile(grubcfg) if rc == True and not constants.MANAGEDSTR in content: printScript(' > Keeping pxe configuration.') return True # get grub partition name of cache cache = getStartconfOption(startconf, 'LINBO', 'Cache') partnr = getStartconfPartnr(startconf, cache) systemtype = getStartconfOption(startconf, 'LINBO', 'SystemType') cacheroot = getGrubPart(cache, systemtype) cachelabel = getStartconfPartlabel(startconf, partnr) # if cache is not defined provide a forced netboot cfg if cacheroot == None: netboottpl = constants.LINBOTPLDIR + '/grub.cfg.forced_netboot' printScript(' > Creating minimal pxe configuration. start.conf is incomplete!') rc = os.system('cp ' + netboottpl + ' ' + grubcfg) return else: printScript(' > Creating pxe configuration.') # create gobal part for group cfg globaltpl = constants.LINBOTPLDIR + '/grub.cfg.global' rc, content = readTextfile(globaltpl) if rc == False: return rc replace_list = [('@@group@@', group), ('@@cachelabel@@', cachelabel), ('@@cacheroot@@', cacheroot), ('@@kopts@@', kopts)] for item in replace_list: content = content.replace(item[0], item[1]) rc = writeTextfile(grubcfg, content, 'w') # get os infos from group's start.conf oslists = getStartconfOsValues(startconf) if oslists == None: return False # write os parts to grub cfg ostpl = constants.LINBOTPLDIR + '/grub.cfg.os' for oslist in oslists: osname, partition, kernel, initrd, kappend, osnr = oslist osroot = getGrubPart(partition, systemtype) ostype = getGrubOstype(osname) partnr = getStartconfPartnr(startconf, partition) oslabel = getStartconfPartlabel(startconf, partnr) rc, content = readTextfile(ostpl) if rc == False: return rc replace_list = [('@@group@@', group), ('@@cachelabel@@', cachelabel), ('@@cacheroot@@', cacheroot), ('@@osname@@', osname), ('@@osnr@@', osnr), ('@@ostype@@', ostype), ('@@oslabel@@', oslabel), ('@@osroot@@', osroot), ('@@partnr@@', partnr), ('@@kernel@@', kernel), ('@@initrd@@', initrd), ('@@kopts@@', kopts), ('@@append@@', kappend)] for item in replace_list: content = content.replace(item[0], item[1]) rc = writeTextfile(grubcfg, content, 'a') if rc == False: return rc
def doLinboStartconf(group): startconf = constants.LINBODIR + '/start.conf.' + group # provide simple start.conf if there is none for this group if not os.path.isfile(startconf): msg = ' > Creating minimal start.conf. Further configuration is necessary!' printScript(msg, '', True) os.system('cp ' + constants.LINBODIR + '/start.conf ' + startconf) # read values from start.conf group_s = getStartconfOption(startconf, 'LINBO', 'Group') serverip_s = getStartconfOption(startconf, 'LINBO', 'Server') kopts_s = getStartconfOption(startconf, 'LINBO', 'KernelOptions') try: serverip_k = re.findall(r'server=[^ ]*', kopts_s, re.IGNORECASE)[0].split('=')[1] except: serverip_k = None # determine whether global values from start conf have to changed if serverip_k != None and isValidHostIpv4(serverip_k) == True: serverip_r = serverip_k else: serverip_r = serverip if kopts_s == None: kopts_r = 'splash quiet' else: kopts_r = kopts_s if group_s != group: group_r = group else: group_r = group # change global startconf options if necessary if serverip_s != serverip_r: rc = setGlobalStartconfOption(startconf, 'Server', serverip_r) if rc == False: return rc if kopts_s != kopts_r: rc = setGlobalStartconfOption(startconf, 'KernelOptions', kopts_r) if rc == False: return rc if group_s != group_r: rc = setGlobalStartconfOption(startconf, 'Group', group_r) if rc == False: return rc # process grub cfgs doGrubCfg(startconf, group, kopts_r)
# grub image filename img = constants.LINBOGRUBDIR + '/hostcfg/' + hostname + '.img' imgrel = img.replace(constants.LINBOGRUBDIR, 'boot/grub') # path to host specific cfg hostcfg = img.replace('.img', '.cfg') # get other host parameters from hostrow field1, field2, group, mac, ip, field6, field7, field8, field9, field10, field11 = hostrow # path to group specific cfg groupcfg = constants.LINBOGRUBDIR + '/' + group + '.cfg' # get systemtype specific parameters startconf = constants.LINBODIR + '/start.conf.' + group systemtype = getStartconfOption(startconf, 'LINBO', 'SYSTEMTYPE').lower() normal = '\n' if systemtype == 'bios' or systemtype == 'bios64': platform = 'i386-pc' imgtype = platform + '-pxe' iface = 'pxe' modules = constants.GRUBI386MODS normal = 'normal' elif systemtype == 'efi32': platform = 'i386-efi' imgtype = platform iface = 'efinet0' modules = constants.GRUBEFIMODS elif systemtype == 'efi64': platform = 'x86_64-efi' imgtype = platform