diff --git a/pym/cl_fill_install.py b/pym/cl_fill_install.py index 0001dad..f7e861c 100644 --- a/pym/cl_fill_install.py +++ b/pym/cl_fill_install.py @@ -1458,10 +1458,13 @@ class fillVars(object, glob_attr): else: return self.Get('cl_chroot_path') - def get_cl_install_autologin(self): - """Migration of autologin""" - if self.Get('os_root_type') == "livecd" and - self.Get('os_linux_shortname') != 'CMC': - return "" + 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 self.Get('cl_autologin') + return "" diff --git a/pym/cl_install.py b/pym/cl_install.py index f19f198..8130e8c 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -1645,10 +1645,18 @@ class cl_install(color_print, SignalInterrupt): return False return True - def setUsers(self,listUsers): + def setUsers(self,listUsers,autologinUser): """Set users data (migration)""" - if listUsers: - migrateUsers = list(set(listUsers)) + if autologinUser == "none": + 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 = ["root"] + filter(lambda x: x!="root", migrateUsers) self.clVars.Set('cl_migrate_user', migrateUsers, force=True) @@ -1713,10 +1721,10 @@ class cl_install(color_print, SignalInterrupt): return True def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers, - brDisk): + autologinUser, brDisk): """Set install options (set users, disks and boot record""" try: - if self.setUsers(listUsers) and \ + if self.setUsers(listUsers,autologinUser) and \ self.setDisks(listDisks,listBinds,listSwaps) and \ self.setBR(brDisk): return self.createListOptions() @@ -2224,13 +2232,19 @@ class cl_install(color_print, SignalInterrupt): self.stdoutHide = None self.stderrHide = None - def configureSystem(self): + def configureSystem(self,autologin): """configure current system""" configureMessage = _("Configure system") error = None keyInter = None 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 self.installPackage() self.printMessageForTest(configureMessage) diff --git a/pym/cl_install_cmd.py b/pym/cl_install_cmd.py index 65f305c..570ecbe 100644 --- a/pym/cl_install_cmd.py +++ b/pym/cl_install_cmd.py @@ -87,6 +87,11 @@ CMD_OPTIONS = [{'shortOption':"d", 'action':'append', 'help':_("add user to installed system") }, + {'shortOption':"A", + 'longOption':"autologin", + 'optVal':"USER", + 'help':_("add autologin user to installed system") + }, {'longOption':"hostname", 'optVal':"HOSTNAME", 'help':_("set short hostname of full hostname") @@ -263,6 +268,8 @@ class install_cmd(share_cmd): self.checkIncompatibleStartup() if values.dhcp: self.checkIncompatibleDhcp() + if values.A == "root": + self.optobj.error(_("Autologin user can not be root")) if not values.v: if values.filter: errMsg = _("incorrect option") + ":" + " %s" %"--filter" +\ @@ -434,7 +441,7 @@ class install_cmd(share_cmd): self.logicObj.clVars.Set('cl_action',"system",True) def checkAndSetInstallOptions(self,diskOptions, swapOptions, - usersOptions): + usersOptions, autologinOptions): """Check and set disk, swap and bind cmd options""" if self.optobj.values.s: self.logicObj.setLinuxName(self.optobj.values.s.upper()) @@ -471,6 +478,7 @@ class install_cmd(share_cmd): return False if not self.logicObj.setInstallOptions(listDiskOptions, listBindOptions, listSwapOptions, usersOptions, + autologinOptions, self.optobj.values.mbr): return False return True @@ -563,9 +571,9 @@ class install_cmd(share_cmd): def showPartitions(self): self.logicObj.printAllPartitonsTable() - def configureSystem(self): + def configureSystem(self,autologin): """Run configure system""" - if self.logicObj.configureSystem(): + if self.logicObj.configureSystem(autologin): return True else: return False diff --git a/pym/cl_vars_install.py b/pym/cl_vars_install.py index 6ed2408..8d7f59d 100644 --- a/pym/cl_vars_install.py +++ b/pym/cl_vars_install.py @@ -406,8 +406,8 @@ class Data: # (on or off) autoupdate config from install program for install cl_install_autoupdate_set = {'mode':'w','value': "off"} - # variable for migrate autologin - cl_install_autologin = {} + # variable for autologin + cl_autologin = {} # lib vars os_locale_xkb = {} diff --git a/scripts/cl-install b/scripts/cl-install index 25b97fd..fb030b5 100644 --- a/scripts/cl-install +++ b/scripts/cl-install @@ -54,7 +54,7 @@ if __name__ == "__main__": if not (options.startup or options.install or options.uninstall or options.live): if not install.checkAndSetInstallOptions(options.d,options.w, - options.u): + options.u,options.A): sys.exit(1) # print variables if options.v or options.filter or options.xml: @@ -68,7 +68,7 @@ if __name__ == "__main__": sys.exit(1) # configurate current system if options.startup: - if not install.configureSystem(): + if not install.configureSystem(options.A): sys.exit(1) elif options.install: if not install.installPackage():