Improve set xautologin.

master3.3
Mike Hiretsky 13 years ago
parent 4fa466b7b5
commit 9b5cf5bb42

@ -1458,10 +1458,13 @@ class fillVars(object, glob_attr):
else: else:
return self.Get('cl_chroot_path') return self.Get('cl_chroot_path')
def get_cl_install_autologin(self): def get_cl_autologin(self):
"""Migration of autologin""" """Autologin"""
if self.Get('os_root_type') == "livecd" and if self.Get('os_install_root_type') == "livecd" or \
self.Get('os_linux_shortname') != 'CMC': self.Get('os_install_linux_shortname') == "CMC":
return "" nonRootUsers = filter(lambda x: x != "root",
self.Get('cl_migrate_user'))
if nonRootUsers:
return nonRootUsers[0]
else: else:
return self.Get('cl_autologin') return ""

@ -1645,10 +1645,18 @@ class cl_install(color_print, SignalInterrupt):
return False return False
return True return True
def setUsers(self,listUsers): def setUsers(self,listUsers,autologinUser):
"""Set users data (migration)""" """Set users data (migration)"""
if listUsers: if autologinUser == "none":
migrateUsers = list(set(listUsers)) autologinUser = ""
if autologinUser or autologinUser == "":
self.clVars.Set('cl_autologin', autologinUser, force=True)
else:
autologinUser = self.clVars.Get('cl_autologin')
autologinUser = [autologinUser] if autologinUser else []
listUsers = listUsers or []
if listUsers or autologinUser:
migrateUsers = list(set(listUsers+autologinUser))
migrateUsers.sort() migrateUsers.sort()
migrateUsers = ["root"] + filter(lambda x: x!="root", migrateUsers) migrateUsers = ["root"] + filter(lambda x: x!="root", migrateUsers)
self.clVars.Set('cl_migrate_user', migrateUsers, force=True) self.clVars.Set('cl_migrate_user', migrateUsers, force=True)
@ -1713,10 +1721,10 @@ class cl_install(color_print, SignalInterrupt):
return True return True
def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers, def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers,
brDisk): autologinUser, brDisk):
"""Set install options (set users, disks and boot record""" """Set install options (set users, disks and boot record"""
try: try:
if self.setUsers(listUsers) and \ if self.setUsers(listUsers,autologinUser) and \
self.setDisks(listDisks,listBinds,listSwaps) and \ self.setDisks(listDisks,listBinds,listSwaps) and \
self.setBR(brDisk): self.setBR(brDisk):
return self.createListOptions() return self.createListOptions()
@ -2224,13 +2232,19 @@ class cl_install(color_print, SignalInterrupt):
self.stdoutHide = None self.stdoutHide = None
self.stderrHide = None self.stderrHide = None
def configureSystem(self): def configureSystem(self,autologin):
"""configure current system""" """configure current system"""
configureMessage = _("Configure system") configureMessage = _("Configure system")
error = None error = None
keyInter = None keyInter = None
try: try:
try: try:
if autologin:
objUsers = currentUsers()
if not objUsers.hasUsers(autologin):
self.printERROR(_("User %s is not exists")%autologin)
else:
self.setUsers([],autologin)
# install this package # install this package
self.installPackage() self.installPackage()
self.printMessageForTest(configureMessage) self.printMessageForTest(configureMessage)

@ -87,6 +87,11 @@ CMD_OPTIONS = [{'shortOption':"d",
'action':'append', 'action':'append',
'help':_("add user to installed system") 'help':_("add user to installed system")
}, },
{'shortOption':"A",
'longOption':"autologin",
'optVal':"USER",
'help':_("add autologin user to installed system")
},
{'longOption':"hostname", {'longOption':"hostname",
'optVal':"HOSTNAME", 'optVal':"HOSTNAME",
'help':_("set short hostname of full hostname") 'help':_("set short hostname of full hostname")
@ -263,6 +268,8 @@ class install_cmd(share_cmd):
self.checkIncompatibleStartup() self.checkIncompatibleStartup()
if values.dhcp: if values.dhcp:
self.checkIncompatibleDhcp() self.checkIncompatibleDhcp()
if values.A == "root":
self.optobj.error(_("Autologin user can not be root"))
if not values.v: if not values.v:
if values.filter: if values.filter:
errMsg = _("incorrect option") + ":" + " %s" %"--filter" +\ errMsg = _("incorrect option") + ":" + " %s" %"--filter" +\
@ -434,7 +441,7 @@ class install_cmd(share_cmd):
self.logicObj.clVars.Set('cl_action',"system",True) self.logicObj.clVars.Set('cl_action',"system",True)
def checkAndSetInstallOptions(self,diskOptions, swapOptions, def checkAndSetInstallOptions(self,diskOptions, swapOptions,
usersOptions): usersOptions, autologinOptions):
"""Check and set disk, swap and bind cmd options""" """Check and set disk, swap and bind cmd options"""
if self.optobj.values.s: if self.optobj.values.s:
self.logicObj.setLinuxName(self.optobj.values.s.upper()) self.logicObj.setLinuxName(self.optobj.values.s.upper())
@ -471,6 +478,7 @@ class install_cmd(share_cmd):
return False return False
if not self.logicObj.setInstallOptions(listDiskOptions, listBindOptions, if not self.logicObj.setInstallOptions(listDiskOptions, listBindOptions,
listSwapOptions, usersOptions, listSwapOptions, usersOptions,
autologinOptions,
self.optobj.values.mbr): self.optobj.values.mbr):
return False return False
return True return True
@ -563,9 +571,9 @@ class install_cmd(share_cmd):
def showPartitions(self): def showPartitions(self):
self.logicObj.printAllPartitonsTable() self.logicObj.printAllPartitonsTable()
def configureSystem(self): def configureSystem(self,autologin):
"""Run configure system""" """Run configure system"""
if self.logicObj.configureSystem(): if self.logicObj.configureSystem(autologin):
return True return True
else: else:
return False return False

@ -406,8 +406,8 @@ class Data:
# (on or off) autoupdate config from install program for install # (on or off) autoupdate config from install program for install
cl_install_autoupdate_set = {'mode':'w','value': "off"} cl_install_autoupdate_set = {'mode':'w','value': "off"}
# variable for migrate autologin # variable for autologin
cl_install_autologin = {} cl_autologin = {}
# lib vars # lib vars
os_locale_xkb = {} os_locale_xkb = {}

@ -54,7 +54,7 @@ if __name__ == "__main__":
if not (options.startup or options.install or options.uninstall or if not (options.startup or options.install or options.uninstall or
options.live): options.live):
if not install.checkAndSetInstallOptions(options.d,options.w, if not install.checkAndSetInstallOptions(options.d,options.w,
options.u): options.u,options.A):
sys.exit(1) sys.exit(1)
# print variables # print variables
if options.v or options.filter or options.xml: if options.v or options.filter or options.xml:
@ -68,7 +68,7 @@ if __name__ == "__main__":
sys.exit(1) sys.exit(1)
# configurate current system # configurate current system
if options.startup: if options.startup:
if not install.configureSystem(): if not install.configureSystem(options.A):
sys.exit(1) sys.exit(1)
elif options.install: elif options.install:
if not install.installPackage(): if not install.installPackage():

Loading…
Cancel
Save