From d33c5d7d51534b425f0777192437e79ba27e9874 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 20 Jul 2010 11:59:29 +0400 Subject: [PATCH] Fix change root password. Change view of report info. Add calculate daemon. --- data/calculate | 21 +++++++++++++ pym/cl_install.py | 68 ++++++++++++++++------------------------- pym/cl_migrate_users.py | 16 +++++----- pym/cl_share_cmd.py | 8 ++--- setup.py | 4 +-- 5 files changed, 63 insertions(+), 54 deletions(-) create mode 100755 data/calculate diff --git a/data/calculate b/data/calculate new file mode 100755 index 0000000..5aba6be --- /dev/null +++ b/data/calculate @@ -0,0 +1,21 @@ +#!/sbin/runscript + +depend() { + need localmount root fsck modules keymaps consolefont + before keymaps consolefont dbus + use swap +} + +start() { + /usr/bin/cl-install --live + + /usr/sbin/env-update + source /etc/profile + /sbin/update-modules + + /sbin/rc-update --update +} + +stop() { + rc-update del calculate boot +} diff --git a/pym/cl_install.py b/pym/cl_install.py index 36e82f2..21221a5 100644 --- a/pym/cl_install.py +++ b/pym/cl_install.py @@ -585,10 +585,8 @@ class cl_install(color_print): return dirsFiles def printInfo(self,sourceDistr,targetDistr): - self.printSUCCESS(_("Installation") + "%s %s"% - (self.clVars.Get('os_install_linux_name'), - self.clVars.Get('os_install_linux_subname'))) - self.defaultPrint(_("System information\n")) + self.printSUCCESS(_("Installation") + " Calculate Linux") + self.defaultPrint("%s\n"%_("System information")) self.printSUCCESS(_("Computer name")+": %s"% self.clVars.Get('os_net_hostname')) self.printSUCCESS(_("Domain name")+": %s"% @@ -598,7 +596,7 @@ class cl_install(color_print): self.printSUCCESS(_("Installed system")+": %s %s"% (self.clVars.Get('os_linux_name'), self.clVars.Get('os_linux_ver'))) - self.defaultPrint(_("Hardware\n")) + self.defaultPrint("%s\n"%_("Hardware")) self.printSUCCESS(_("Machine hardware name")+": %s"% self.clVars.Get('os_arch_machine')) self.printSUCCESS(_("Quantity processors")+": %s"% @@ -607,7 +605,7 @@ class cl_install(color_print): '') self.printSUCCESS(_("Screen resolution")+": %s"% '') - self.defaultPrint(_("Localization\n")) + self.defaultPrint("%s\n"%_("Localization")) self.printSUCCESS(_("Language")+": %s"% self.clVars.Get('os_locale_lang')) self.printSUCCESS(_("Keymap")+": %s"% @@ -615,33 +613,22 @@ class cl_install(color_print): self.printSUCCESS(_("Timezone")+": %s"% self.clVars.Get('os_clock_timezone')) - self.defaultPrint(_("Location\n")) - self.printSUCCESS(_("Working volume")+": %s"% - self.getDeviceByField("mount",'/', - secondPrefix="os_install_disk") or "unknown") - self.printSUCCESS(_("Installation volume")+": %s"% - self.clVars.Get('os_root_dev')) - self.printSUCCESS(_("File system")+": %s"% - self.getFieldByField("format","mount","/", - firstPrefix="os_install_disk", - secondPrefix="os_install_disk")) - self.printSUCCESS(_("Swap disk")+": %s"% - self.getFieldByField("dev","mount","swap", - secondPrefix="os_install_disk")) - self.printSUCCESS(_("Mounted disks")+": %s"% - ", ".join(map(lambda x: x[0], - filter(lambda x: not x[1] in ["","/","swap"], - zip(self.clVars.Get('os_disk_dev'), - self.clVars.Get('os_disk_mount')))))) - - self.defaultPrint(_("Network services\n")) + #self.defaultPrint("%s\n"%_("Location")) + title, headerList, dataList = self.generateTableData() + tableObj = tableReport(title, headerList, dataList) + #cl_overriding.printSUCCESS("") + tableObj.printReport() + #cl_overriding.printSUCCESS("") + + self.defaultPrint("%s\n"%_("Network services")) + self.printSUCCESS(_("Authentification")+": %s"% + "") self.printSUCCESS(_("PROXY")+": %s"% "") self.printSUCCESS(_("NTP")+": %s"% "") - self.printSUCCESS(_("Authentification")+": %s"% - "") + self.defaultPrint("%s\n"%_("Perform pre-install checkups")) self.printSUCCESS("Found update: %s %s %s"% (self.clVars.Get('os_install_linux_name'), self.clVars.Get('os_install_linux_subname'), @@ -948,7 +935,7 @@ class cl_install(color_print): def generateTableData(self): """Get data from print table""" - title = _("New partition table") + title = _("Location") allDevicesOpt = self.listDisksOptions + self.listSwapsOptions listIsFormat = [] for dev in self.clVars.Get('os_disk_dev'): @@ -977,12 +964,15 @@ class cl_install(color_print): headerList = [_("Size"),_("Device"),_("Directory"),_("File system"), _("Format"), _("Partition")] - dataList = zip(listSize, - self.clVars.Get('os_disk_dev'), - listMountPoint, - listFileSystem, - listIsFormat, - self.clVars.Get('os_disk_part')) + dataList = map(lambda x:x[:-1], + filter(lambda x:x[-1] != "", + zip(listSize, + self.clVars.Get('os_disk_dev'), + listMountPoint, + listFileSystem, + listIsFormat, + self.clVars.Get('os_disk_part'), + self.clVars.Get('os_install_disk_mount')))) return title, headerList, dataList def getPwdHashUser(self, userName): @@ -1034,7 +1024,6 @@ class cl_install(color_print): if distName: # print info sourceDistr = distRep.getDistributiveByFile(distName) - self.printInfo(sourceDistr,targetDistr) # wait 10 sec #waittime = 3 #self.printSUCCESS(_("Installation will start pass %d seconds.") @@ -1049,12 +1038,8 @@ class cl_install(color_print): bootDiskGrub=listbootDiskGrub[0] else: raise InstallError(_("Cann't found disk %s")%bootDisk) + self.printInfo(sourceDistr,targetDistr) if not force: - title, headerList, dataList = self.generateTableData() - tableObj = tableReport(title, headerList, dataList) - cl_overriding.printSUCCESS("") - tableObj.printReport() - cl_overriding.printSUCCESS("") dialogMessage = _("Continue with the installation of \ the system") + " (yes/no)" dialogRes = dialogYesNo(dialogMessage) @@ -1127,6 +1112,7 @@ the system") + " (yes/no)" # install distributive self.printSUCCESS(_("Unpacking system image into target")) targetDistr.installFrom(sourceDistr) + self.printOK("Unpacking complete") # join templates self.printSUCCESS(_("Update config")) diff --git a/pym/cl_migrate_users.py b/pym/cl_migrate_users.py index b5e8c6d..9185018 100644 --- a/pym/cl_migrate_users.py +++ b/pym/cl_migrate_users.py @@ -276,7 +276,7 @@ class migrate(color_print): def changePassword(self, userName, pwdHash, maxDays="99999", warnDays="7"): if not filter(lambda x: x[0]==userName, self.dataUsers): - self.printERROR(_("Nof found user %s")%userName) + self.printERROR(_("Not found user %s")%userName) return False indexFoundUser = False for i, data in enumerate(self.dataShadow): @@ -334,6 +334,7 @@ class migrate(color_print): migrateShadow.fileShadow] checkNewFiles = map(lambda x: pathJoin(self.prefixNewSystem,x), checkThisFiles) + parentDir = lambda x: "".join(os.path.split(x)[:-1]) notRead = lambda x: not os.access(x, os.R_OK) notWrite = lambda x: not os.access(x, os.W_OK) filesNotRead = filter(notRead,checkThisFiles) @@ -392,15 +393,16 @@ class migrate(color_print): self.addThisUsersToGroups(thisUsers) for userName, pwdHash, maxDays, warnDays in pwdUsersList: if userName == "root": - rootHash = map(lambda x: x[1], - filter(lambda x: x[0] == "root", - objShadow.getData())) + # find root password hash + rootHash = reduce(lambda x,y: y[1] if y[0] == "root" else x, + objShadow.getData(), + None) + # if password of current root is not "root" trasfer + # it to new system if rootHash: - rootHash = rootHash[0] salt = "".join(rootHash.rpartition("$")[:1]) if crypt("root",salt) != rootHash: - self.dataShadow[0]=["root",rootHash,"0","","","","",""] - continue + pwdHash = rootHash if not self.changePassword(userName, pwdHash, maxDays=maxDays, warnDays=warnDays): diff --git a/pym/cl_share_cmd.py b/pym/cl_share_cmd.py index cec0b1d..27f9fd3 100644 --- a/pym/cl_share_cmd.py +++ b/pym/cl_share_cmd.py @@ -29,7 +29,7 @@ class share_cmd(color_print, _error): """Печать переменных""" if optObj.vars: terms = optObj.vars.split(",") - self.logicObj.printVars(terms) + self.printVars(terms) def setVars(self, optObj): """Установка переменных""" @@ -37,8 +37,8 @@ class share_cmd(color_print, _error): for vals in optObj.set: for val in vals.split(','): k,o,v = val.partition('=') - if self.logicObj.clVars.exists(k): - if not self.logicObj.clVars.SetWriteVar(k,v): + if self.clVars.exists(k): + if not self.clVars.SetWriteVar(k,v): return False else: self.printERROR(_('variable %s not found')%k) @@ -48,7 +48,7 @@ class share_cmd(color_print, _error): def writeVars(self, optObj): """Запись переменных""" if optObj.set: - if not self.logicObj.clVars.WriteVars(): + if not self.clVars.WriteVars(): errMsg = self.getError() if errMsg: self.printERROR(errMsg.strip()) diff --git a/setup.py b/setup.py index f93a290..ce6d3a1 100755 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ var_data_files = [] data_dirs_template = ['templates'] share_calculate_dir = "/usr/share/calculate-2.2" data_dirs_share = ['i18n'] -#data_files += [('/etc/init.d', ['data/calculate-2.2'])] +data_files += [('/etc/init.d', ['data/calculate'])] template_calculate_dir = os.path.join(share_calculate_dir, "templates") template_replace_dirname = "install" @@ -73,7 +73,7 @@ class cl_install_data(install_data): def run (self): install_data.run(self) #data_file = [("/etc/init.d/calculate-2.2",0755)] - data_file = [] + data_file = [("/etc/init.d/calculate",0755)] fileNames = map(lambda x: os.path.split(x[0])[1], data_file) listNames = map(lambda x: filter(lambda y: y, x[0].split("/")), data_file)