|
|
@ -18,8 +18,8 @@ import os
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
from os import path
|
|
|
|
from os import path
|
|
|
|
from calculate.lib.datavars import Variables,VariableError
|
|
|
|
from calculate.lib.datavars import Variable,VariableError,ReadonlyVariable
|
|
|
|
from calculate.lib.variables import System
|
|
|
|
from calculate.install.variables.net import NetVariable
|
|
|
|
from calculate.install.cl_install import FileSystemManager
|
|
|
|
from calculate.install.cl_install import FileSystemManager
|
|
|
|
from calculate.lib.utils.files import readFile,getProgPath,process
|
|
|
|
from calculate.lib.utils.files import readFile,getProgPath,process
|
|
|
|
from calculate.lib.utils.common import getPasswdUsers
|
|
|
|
from calculate.lib.utils.common import getPasswdUsers
|
|
|
@ -29,133 +29,38 @@ from calculate.lib.encrypt import encrypt
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
setLocalTranslate('cl_install',sys.modules[__name__])
|
|
|
|
setLocalTranslate('cl_install',sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
|
|
class InstallSystem(System):
|
|
|
|
class UserVariable(Variable):
|
|
|
|
vars = ["os_install_scratch","cl_autoupdate_set",
|
|
|
|
"""
|
|
|
|
"cl_install_autoupdate_set",
|
|
|
|
Locale variables not using for flash installation
|
|
|
|
"os_install_proxy","os_install_ntp",
|
|
|
|
"""
|
|
|
|
"os_install_dev_from","os_install_lvm_set",
|
|
|
|
def uncompatible(self):
|
|
|
|
"os_install_mdadm_set","os_grub_conf","os_grub2_path",
|
|
|
|
"""
|
|
|
|
"cl_chroot_grub","os_install_grub_devicemap_conf",
|
|
|
|
User setting up unavailable for flash installation
|
|
|
|
"cl_distfiles_path","cl_pkgdir_path","os_format_type",
|
|
|
|
"""
|
|
|
|
"os_format_use","os_install_makeopts","cl_migrate_user",
|
|
|
|
if self.Get('os_install_root_type') == 'flash':
|
|
|
|
"cl_migrate_data",
|
|
|
|
return \
|
|
|
|
"cl_migrate_user_pwd","os_nvidia_mask","cl_autologin"]
|
|
|
|
_("User configuration unavailable for flash installation")
|
|
|
|
|
|
|
|
return ""
|
|
|
|
# install system in scratch mode
|
|
|
|
|
|
|
|
os_install_scratch = {'mode':'w',
|
|
|
|
|
|
|
|
'type':'bool',
|
|
|
|
|
|
|
|
'opt':['--build'],
|
|
|
|
|
|
|
|
'label':_("Builder mode"),
|
|
|
|
|
|
|
|
'help':_("installation for assemble")}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# filesystem format support by calcualte-install
|
|
|
|
|
|
|
|
os_format_type = {'mode':'r',
|
|
|
|
|
|
|
|
'type':"list"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# avialable format by mkfs utility
|
|
|
|
|
|
|
|
os_format_use = {'mode':'r',
|
|
|
|
|
|
|
|
'type':"list"}
|
|
|
|
|
|
|
|
# (on or off) autoupdate config from install program
|
|
|
|
|
|
|
|
cl_autoupdate_set = {'value': "off",
|
|
|
|
|
|
|
|
'type': "bool",
|
|
|
|
|
|
|
|
'value': "off"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# (on or off) autoupdate config from install program for install
|
|
|
|
|
|
|
|
cl_install_autoupdate_set = {'mode':'w',
|
|
|
|
|
|
|
|
'type': "bool",
|
|
|
|
|
|
|
|
'value': "off"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# proxy server for system
|
|
|
|
|
|
|
|
os_install_proxy = {'mode':'w',
|
|
|
|
|
|
|
|
'value':''}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# nt server for system
|
|
|
|
|
|
|
|
os_install_ntp = {'mode':'w',
|
|
|
|
|
|
|
|
'label':_("NTP server"),
|
|
|
|
|
|
|
|
'opt':['--ntp'],
|
|
|
|
|
|
|
|
'help':_("set the ntp server for the system"),
|
|
|
|
|
|
|
|
'metavalue':"NTP",
|
|
|
|
|
|
|
|
'value':'ntp0.zenon.net'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# type of device for install
|
|
|
|
|
|
|
|
os_install_root_type = {'mode':'w'}
|
|
|
|
|
|
|
|
# root device of installed os
|
|
|
|
|
|
|
|
os_install_root_dev = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# using lvm
|
|
|
|
|
|
|
|
os_install_lvm_set = {'mode':'r',
|
|
|
|
|
|
|
|
'type':"bool"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# using mdadm
|
|
|
|
|
|
|
|
os_install_mdadm_set = {'mode':'r',
|
|
|
|
|
|
|
|
'type':"bool"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# current grub
|
|
|
|
|
|
|
|
os_grub_conf = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# grub2 install path
|
|
|
|
|
|
|
|
os_grub2_path = {'mode':'w'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# grub chroot need for grub-mkconfig
|
|
|
|
|
|
|
|
cl_chroot_grub = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# content of device.map file for grub
|
|
|
|
|
|
|
|
os_install_grub_devicemap_conf = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# DISTFILES value
|
|
|
|
class VariableOsInstallScratch(Variable):
|
|
|
|
cl_distfiles_path = {'mode':'w',
|
|
|
|
"""
|
|
|
|
'value':'/var/calculate/remote/distfiles'}
|
|
|
|
Install system in scratch mode
|
|
|
|
# PKGDIR value
|
|
|
|
"""
|
|
|
|
cl_pkgdir_path = {'mode':'w'}
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
opt = ['--build']
|
|
|
|
# makeconf makeopts
|
|
|
|
label = _("Builder mode")
|
|
|
|
os_install_makeopts = {'mode':'w'}
|
|
|
|
help = _("installation for assemble")
|
|
|
|
|
|
|
|
|
|
|
|
# user migrate data table
|
|
|
|
def get(self):
|
|
|
|
cl_migrate_data = {'type':'table',
|
|
|
|
# for installation default - normal system
|
|
|
|
'mode':'w',
|
|
|
|
|
|
|
|
'opt':["--users","-u"],
|
|
|
|
|
|
|
|
'metavalue':'USERS',
|
|
|
|
|
|
|
|
'source':['cl_migrate_user',
|
|
|
|
|
|
|
|
'cl_migrate_user_pwd'],
|
|
|
|
|
|
|
|
'help':_("add a user to the installed system"),
|
|
|
|
|
|
|
|
'label':_("Migration users")}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# migrate users
|
|
|
|
|
|
|
|
cl_migrate_user = {'type':'list',
|
|
|
|
|
|
|
|
'label':_("Login"),
|
|
|
|
|
|
|
|
'mode':'w'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# migrate users who need to change passwords
|
|
|
|
|
|
|
|
cl_migrate_user_pwd = {'type':'password-list',
|
|
|
|
|
|
|
|
'label':_("Password"),
|
|
|
|
|
|
|
|
'mode':'w'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# nvidia-drivers atom mask
|
|
|
|
|
|
|
|
os_nvidia_mask = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# variable for autologin
|
|
|
|
|
|
|
|
cl_autologin = {'type':'choiceedit',
|
|
|
|
|
|
|
|
'mode':'w',
|
|
|
|
|
|
|
|
'label':_("Autologin"),
|
|
|
|
|
|
|
|
'opt':["--autologin",'-A'],
|
|
|
|
|
|
|
|
'metavalue':"USER",
|
|
|
|
|
|
|
|
'help':_("add an autologin user to the installed system")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# root device of previous installed os
|
|
|
|
|
|
|
|
os_install_dev_from = {'mode':'w'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_install_scratch(self):
|
|
|
|
|
|
|
|
"""Install system in scratch mode"""
|
|
|
|
|
|
|
|
if self.Get('cl_action') == 'system':
|
|
|
|
if self.Get('cl_action') == 'system':
|
|
|
|
return "off"
|
|
|
|
return "off"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return self.Get('os_scratch')
|
|
|
|
return self.Get('os_scratch')
|
|
|
|
|
|
|
|
|
|
|
|
def check_os_install_scratch(self,value):
|
|
|
|
def check(self,value):
|
|
|
|
"""Check abality install in scratch mode"""
|
|
|
|
|
|
|
|
if value == "on":
|
|
|
|
if value == "on":
|
|
|
|
|
|
|
|
# scratch not use for falsh and multipartition
|
|
|
|
if self.Get('os_install_root_type') == "flash":
|
|
|
|
if self.Get('os_install_root_type') == "flash":
|
|
|
|
raise VariableError(
|
|
|
|
raise VariableError(
|
|
|
|
_("Installation to flash disk is not supported"
|
|
|
|
_("Installation to flash disk is not supported"
|
|
|
@ -164,21 +69,212 @@ class InstallSystem(System):
|
|
|
|
raise VariableError(
|
|
|
|
raise VariableError(
|
|
|
|
_("Builder mode does not support multipartition install"))
|
|
|
|
_("Builder mode does not support multipartition install"))
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_format_type(self):
|
|
|
|
class VariableOsFormatType(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Filesystem format support by calcualte-install
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
"""Filesystem format support by calcualte-install"""
|
|
|
|
"""Filesystem format support by calcualte-install"""
|
|
|
|
return FileSystemManager.supportFS.keys()
|
|
|
|
return FileSystemManager.supportFS.keys()
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_format_use(self):
|
|
|
|
class VariableOsFormatUse(ReadonlyVariable):
|
|
|
|
"""Avialable format by mkfs utility"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
Avialable format by mkfs utility
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
# (on or off) autoupdate config from install program
|
|
|
|
|
|
|
|
cl_autoupdate_set = {'value': "off",
|
|
|
|
|
|
|
|
'type': "bool",
|
|
|
|
|
|
|
|
'value': "off"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
return map(lambda x:"yes"
|
|
|
|
return map(lambda x:"yes"
|
|
|
|
if path.exists(FileSystemManager.supportFS[x]["format"])
|
|
|
|
if path.exists(FileSystemManager.supportFS[x]["format"])
|
|
|
|
else "no", self.Get('os_format_type'))
|
|
|
|
else "no", self.Get('os_format_type'))
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_pkgdir_path(self):
|
|
|
|
class VariableClMigrateData(UserVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
User migrate data table
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = 'table'
|
|
|
|
|
|
|
|
opt = ["--users","-u"]
|
|
|
|
|
|
|
|
metavalue = 'USERS'
|
|
|
|
|
|
|
|
help = _("add a user to the installed system")
|
|
|
|
|
|
|
|
label = _("Migration users")
|
|
|
|
|
|
|
|
source = ['cl_migrate_user','cl_migrate_user_pwd']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClMigrateUser(UserVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Migrate users list
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = 'list'
|
|
|
|
|
|
|
|
label = _("Login")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Migration users (root and users above 1000 uid)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return getPasswdUsers()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClMigrateUserPwd(UserVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Migrate users who need to change passwords
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = 'password-list'
|
|
|
|
|
|
|
|
label = _("Password")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Migration users passwords
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
retList = []
|
|
|
|
|
|
|
|
fileName = "/etc/shadow"
|
|
|
|
|
|
|
|
if os.access(fileName, os.R_OK):
|
|
|
|
|
|
|
|
migrateusers = self.Get("cl_migrate_user")
|
|
|
|
|
|
|
|
if migrateusers:
|
|
|
|
|
|
|
|
lenData=9
|
|
|
|
|
|
|
|
shadowData = filter(lambda x: len(x)==lenData,
|
|
|
|
|
|
|
|
map(lambda x: x.rstrip().split(":"),
|
|
|
|
|
|
|
|
open(fileName)))
|
|
|
|
|
|
|
|
shadowData = filter(lambda x: x[0] in migrateusers, shadowData)
|
|
|
|
|
|
|
|
shadowData = map(lambda x: (x[0], x[1]), shadowData)
|
|
|
|
|
|
|
|
shadowUsers = map(lambda x: x[0], shadowData)
|
|
|
|
|
|
|
|
for userName in migrateusers:
|
|
|
|
|
|
|
|
if userName in ("root",):
|
|
|
|
|
|
|
|
if userName in shadowUsers:
|
|
|
|
|
|
|
|
userData = filter(lambda x: x[0]==userName,
|
|
|
|
|
|
|
|
shadowData)
|
|
|
|
|
|
|
|
hashPwd = userData[0][1]
|
|
|
|
|
|
|
|
salt = "".join(hashPwd.rpartition("$")[:1])
|
|
|
|
|
|
|
|
if salt and crypt(userName, salt) == hashPwd:
|
|
|
|
|
|
|
|
retList.append("")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
retList.append(hashPwd)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
retList.append("")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if userName in shadowUsers:
|
|
|
|
|
|
|
|
userData = filter(lambda x: x[0]==userName,
|
|
|
|
|
|
|
|
shadowData)
|
|
|
|
|
|
|
|
hashPwd = userData[0][1]
|
|
|
|
|
|
|
|
retList.append(hashPwd)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
retList.append("")
|
|
|
|
|
|
|
|
return retList
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Check exists password for all migrate users
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
for user,pwd in zip(self.Get('cl_migrate_user'),value):
|
|
|
|
|
|
|
|
if not pwd:
|
|
|
|
|
|
|
|
raise VariableError(
|
|
|
|
|
|
|
|
_("Missed a password for the user %s")%user)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Encrypt passwords
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
reCheck = re.compile("^\$[^$]+\$[^$]+\$.*$")
|
|
|
|
|
|
|
|
encryptObj = encrypt()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return map(lambda x:x if reCheck.match(x) or not x else \
|
|
|
|
|
|
|
|
encryptObj.getHashPasswd(x, "shadow_ssha256"),
|
|
|
|
|
|
|
|
value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClAutologin(UserVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Autologin variable (contains user name for autologin) or
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
empty string if disable
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = 'choiceedit'
|
|
|
|
|
|
|
|
label = _("Autologin")
|
|
|
|
|
|
|
|
opt = ["--autologin",'-A']
|
|
|
|
|
|
|
|
metavalue = "USER"
|
|
|
|
|
|
|
|
help = _("add an autologin user to the installed system")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
# autologin enable for livecd and all install type CMC
|
|
|
|
|
|
|
|
if self.Get('os_install_root_type') == "livecd" or \
|
|
|
|
|
|
|
|
self.Get('os_install_linux_shortname') == "CMC":
|
|
|
|
|
|
|
|
nonRootUsers = filter(lambda x: x != "root",
|
|
|
|
|
|
|
|
self.Get('cl_migrate_user'))
|
|
|
|
|
|
|
|
if nonRootUsers:
|
|
|
|
|
|
|
|
return nonRootUsers[0]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
|
|
|
return filter(lambda x:x != "root",self.Get('cl_migrate_user'))+[""]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Autologin only for migrated non-root users
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if value and not value in self.Get('cl_migrate_user'):
|
|
|
|
|
|
|
|
raise VariableError(_("User %s is not exists")%value)
|
|
|
|
|
|
|
|
if value == "root":
|
|
|
|
|
|
|
|
raise VariableError(_("Autologin is imposible for %s user")%value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClInstallAutoupdateSet(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
(on or off) autoupdate config from install program for install
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
value = "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallMakeopts(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Make.conf makeopts
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
cpunum = self.Get('hr_cpu_num')
|
|
|
|
|
|
|
|
if cpunum == "1":
|
|
|
|
|
|
|
|
return "-j1"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return "-j%d"%(int(cpunum)+1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsGrubConf(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
DEPRICATED content of current grub.conf
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallGrubDevicemapConf(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
DEPRICATED content of device.map file for grub
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
os_install_grub_devicemap_conf = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClDistfilesPath(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
DISTFILES path
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
value = '/var/calculate/remote/distfiles'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClPkgdirPath(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
PKGDIR path
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
return "/var/calculate/remote/packages/%s/%s" % (
|
|
|
|
return "/var/calculate/remote/packages/%s/%s" % (
|
|
|
|
self.Get('os_install_linux_shortname'),
|
|
|
|
self.Get('os_install_linux_shortname'),
|
|
|
|
self.Get('os_install_arch_machine'))
|
|
|
|
self.Get('os_install_arch_machine'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallDevFrom(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Root device of previous installed os
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
# TODO: may be check or set for ini file
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClInstallAutoupdateSet(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Autoupdate for install or configure system
|
|
|
|
|
|
|
|
"""
|
|
|
|
def get_cl_install_autoupdate_set(self):
|
|
|
|
def get_cl_install_autoupdate_set(self):
|
|
|
|
"""Get autoupdate default value"""
|
|
|
|
"""Get autoupdate default value"""
|
|
|
|
if self.Get('ac_install_system') == "up":
|
|
|
|
if self.Get('ac_install_system') == "up":
|
|
|
@ -189,8 +285,11 @@ class InstallSystem(System):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return self.Get('cl_autoupdate_set')
|
|
|
|
return self.Get('cl_autoupdate_set')
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_nvidia_mask(self):
|
|
|
|
class VariableOsNvidiaMask(ReadonlyVariable):
|
|
|
|
"""Get nvidia card mask versions"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
Get nvidia card mask versions
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
image = self.Get('cl_image')
|
|
|
|
image = self.Get('cl_image')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if image:
|
|
|
|
if image:
|
|
|
@ -234,36 +333,48 @@ class InstallSystem(System):
|
|
|
|
image.close()
|
|
|
|
image.close()
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_install_lvm_set(self):
|
|
|
|
class VariableOsInstallLvmSet(ReadonlyVariable):
|
|
|
|
"""Using lvm"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
Using lvm
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
for typeDisk in self.Get('os_install_disk_type'):
|
|
|
|
for typeDisk in self.Get('os_install_disk_type'):
|
|
|
|
if "lvm" in typeDisk:
|
|
|
|
if "lvm" in typeDisk:
|
|
|
|
return "on"
|
|
|
|
return "on"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "off"
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_install_mdadm_set(self):
|
|
|
|
class VariableOsInstallMdadmSet(ReadonlyVariable):
|
|
|
|
"""Using mdadm"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
Using mdadm
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
for typeDisk in self.Get('os_install_disk_type'):
|
|
|
|
for typeDisk in self.Get('os_install_disk_type'):
|
|
|
|
if "lvm" in typeDisk:
|
|
|
|
if "lvm" in typeDisk:
|
|
|
|
return "on"
|
|
|
|
return "on"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return "off"
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_chroot_grub(self):
|
|
|
|
class VariableClChrootGrub(ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Chroot for grub-mkconfig
|
|
|
|
Chroot for grub-mkconfig
|
|
|
|
TODO: check for install scratch system.
|
|
|
|
TODO: check for install scratch system.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
if self.Get('os_install_scratch') == "on":
|
|
|
|
if self.Get('os_install_scratch') == "on":
|
|
|
|
return path.join(self.Get('cl_chroot_path'),"mnt/scratch")
|
|
|
|
return path.join(self.Get('cl_chroot_path'),"mnt/scratch")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return self.Get('cl_chroot_path')
|
|
|
|
return self.Get('cl_chroot_path')
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_grub2_path(self):
|
|
|
|
class VariableOsGrub2Path(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Get Grub2 Install cmd
|
|
|
|
Get Grub2 Install cmd (grub-install or grub2-install)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
# find grub2-install
|
|
|
|
# find grub2-install
|
|
|
|
grubInstall = getProgPath('/sbin/grub2-install')
|
|
|
|
grubInstall = getProgPath('/sbin/grub2-install')
|
|
|
|
if grubInstall:
|
|
|
|
if grubInstall:
|
|
|
@ -274,110 +385,3 @@ class InstallSystem(System):
|
|
|
|
process(grubInstall,'-v')):
|
|
|
|
process(grubInstall,'-v')):
|
|
|
|
return grubInstall
|
|
|
|
return grubInstall
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_migrate_user(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Migration users (root and users above 1000 uid)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return getPasswdUsers()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_migrate_user_pwd(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Migration users passwords
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
retList = []
|
|
|
|
|
|
|
|
fileName = "/etc/shadow"
|
|
|
|
|
|
|
|
if os.access(fileName, os.R_OK):
|
|
|
|
|
|
|
|
migrateusers = self.Get("cl_migrate_user")
|
|
|
|
|
|
|
|
if migrateusers:
|
|
|
|
|
|
|
|
lenData=9
|
|
|
|
|
|
|
|
shadowData = filter(lambda x: len(x)==lenData,
|
|
|
|
|
|
|
|
map(lambda x: x.rstrip().split(":"),
|
|
|
|
|
|
|
|
open(fileName)))
|
|
|
|
|
|
|
|
shadowData = filter(lambda x: x[0] in migrateusers, shadowData)
|
|
|
|
|
|
|
|
shadowData = map(lambda x: (x[0], x[1]), shadowData)
|
|
|
|
|
|
|
|
shadowUsers = map(lambda x: x[0], shadowData)
|
|
|
|
|
|
|
|
for userName in migrateusers:
|
|
|
|
|
|
|
|
if userName in ("root",):
|
|
|
|
|
|
|
|
if userName in shadowUsers:
|
|
|
|
|
|
|
|
userData = filter(lambda x: x[0]==userName,
|
|
|
|
|
|
|
|
shadowData)
|
|
|
|
|
|
|
|
hashPwd = userData[0][1]
|
|
|
|
|
|
|
|
salt = "".join(hashPwd.rpartition("$")[:1])
|
|
|
|
|
|
|
|
if salt and crypt(userName, salt) == hashPwd:
|
|
|
|
|
|
|
|
retList.append("")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
retList.append(hashPwd)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
retList.append("")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
if userName in shadowUsers:
|
|
|
|
|
|
|
|
userData = filter(lambda x: x[0]==userName,
|
|
|
|
|
|
|
|
shadowData)
|
|
|
|
|
|
|
|
hashPwd = userData[0][1]
|
|
|
|
|
|
|
|
retList.append(hashPwd)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
retList.append("")
|
|
|
|
|
|
|
|
return retList
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_cl_migrate_user_pwd(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Check exists password for all migrate users
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
for user,pwd in zip(self.Get('cl_migrate_user'),value):
|
|
|
|
|
|
|
|
if not pwd:
|
|
|
|
|
|
|
|
raise VariableError(
|
|
|
|
|
|
|
|
_("Missed a password for the user %s")%user)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_cl_migrate_user_pwd(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Encrypt passwords
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
reCheck = re.compile("^\$[^$]+\$[^$]+\$.*$")
|
|
|
|
|
|
|
|
encryptObj = encrypt()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return map(lambda x:x if reCheck.match(x) or not x else \
|
|
|
|
|
|
|
|
encryptObj.getHashPasswd(x, "shadow_ssha256"),
|
|
|
|
|
|
|
|
value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_autologin(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Autologin
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.Get('os_install_root_type') == "livecd" or \
|
|
|
|
|
|
|
|
self.Get('os_install_linux_shortname') == "CMC":
|
|
|
|
|
|
|
|
nonRootUsers = filter(lambda x: x != "root",
|
|
|
|
|
|
|
|
self.Get('cl_migrate_user'))
|
|
|
|
|
|
|
|
if nonRootUsers:
|
|
|
|
|
|
|
|
return nonRootUsers[0]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def choice_cl_autologin(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
List of valid users
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return filter(lambda x:x != "root",self.Get('cl_migrate_user'))+[""]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_cl_autologin(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Autologin only migrated users
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if value and not value in self.Get('cl_migrate_user'):
|
|
|
|
|
|
|
|
raise VariableError(_("User %s is not exists")%value)
|
|
|
|
|
|
|
|
if value == "root":
|
|
|
|
|
|
|
|
raise VariableError(_("Autologin is imposible for %s user")%value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def uncompatible_user_vars(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Network setting up unavailable for flash installation
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.Get('os_install_root_type') == 'flash':
|
|
|
|
|
|
|
|
return \
|
|
|
|
|
|
|
|
_("User configuration unavailable for flash installation")
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uncompatible_cl_autologin = \
|
|
|
|
|
|
|
|
uncompatible_cl_migrate_data = \
|
|
|
|
|
|
|
|
uncompatible_user_vars
|
|
|
|
|
|
|
|