From ff2d91be9cdefb895cafb88cefd9bc23f6d61e4a Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Thu, 18 Aug 2011 12:31:50 +0400 Subject: [PATCH] Add --live option for cl-desktop. --live option used for set cl_action -> live. ac_desktop_desktop is on for only cl_action "desktop" ac_desktop_live is on for cl_action "live" or "desktop". In script configure user profile add condition of run by --live if local user login in live system. --- data/login.d/20desktop | 28 ++++++++++++++++++---------- pym/cl_desktop.py | 10 +++++++--- pym/cl_desktop_cmd.py | 6 ++++-- pym/cl_fill_desktop.py | 22 +++++++++++++++++++--- pym/cl_vars_desktop.py | 9 ++++++--- 5 files changed, 54 insertions(+), 21 deletions(-) diff --git a/data/login.d/20desktop b/data/login.d/20desktop index c55f333..43a0138 100644 --- a/data/login.d/20desktop +++ b/data/login.d/20desktop @@ -27,16 +27,24 @@ then [[ -z "`ls ${userHome}`" ]] || diff -uq <(ls -A1 /etc/skel | wc) <(ls -A1 ${userHome} | sort) &>/dev/null then - ERRORLOG=`/usr/bin/cl-desktop --progress --color=never $USER 2>&1` - # raise xmessage error if cl-desktop failed - if [ "$?" -gt "0" ]; - then - # write error message to logfile - echo "$ERRORLOG" >> $FILE_LOG - # display error by xmessage - xmes cl-desktop "$ERRORLOG" - exit 1 - fi + APPENDCMD="" + # run configure only mutable params of user profile if it is live system + # and profile already configured + elif [[ "`desktop_variable_value os_root_type`" != "hdd" ]] + then + APPENDCMD="--live" + else + exit 0 + fi + ERRORLOG=`/usr/bin/cl-desktop $APPENDCMD --progress --color=never $USER 2>&1` + # raise xmessage error if cl-desktop failed + if [ "$?" -gt "0" ]; + then + # write error message to logfile + echo "$ERRORLOG" >> $FILE_LOG + # display error by xmessage + xmes cl-desktop "$ERRORLOG" + exit 1 fi fi exit 0 diff --git a/pym/cl_desktop.py b/pym/cl_desktop.py index 22e59d6..9e7e577 100644 --- a/pym/cl_desktop.py +++ b/pym/cl_desktop.py @@ -182,7 +182,7 @@ class desktop(share): else: return dirsFiles - def createHome(self, progress=False): + def createHome(self, progress=False, live=False): """Создание профиля пользователя (пользовательской директории)""" # Имя пользователя uid = os.getuid() @@ -225,8 +225,12 @@ class desktop(share): if not os.path.exists(homeDir): flagHomeExists = False self.createUserDir(uid, gid, homeDir) - # Действие - шаблоны пользователя - self.clVars.Set("cl_action", "desktop", True) + # if live action then action update mutable params of profile (live) + # else action is update user profile + if live: + self.clVars.Set("cl_action", "live", True) + else: + self.clVars.Set("cl_action", "desktop", True) # Применяем профили для пользователя dirsAndFiles = self.applyTemplatesFromUser(progress) if not dirsAndFiles: diff --git a/pym/cl_desktop_cmd.py b/pym/cl_desktop_cmd.py index b6c496f..b252bef 100644 --- a/pym/cl_desktop_cmd.py +++ b/pym/cl_desktop_cmd.py @@ -35,7 +35,9 @@ EXAMPLES = _("%prog user_name") DESCRIPTION = _("Create home directory for the new user account") # Опции командной строки -CMD_OPTIONS = [{'longOption':"set"}, +CMD_OPTIONS = [{'longOption':"live", + 'help':_("update only mutable parameters of user profile")}, + {'longOption':"set"}, {'longOption':"install", 'help':_("install package")}, {'longOption':"uninstall", @@ -141,7 +143,7 @@ class desktop_cmd(share_cmd): def createHome(self, optObj): """Создание домашней директории""" - return self.logicObj.createHome(optObj.progress) + return self.logicObj.createHome(optObj.progress,optObj.live) def install(self): """Инсталяция программы""" diff --git a/pym/cl_fill_desktop.py b/pym/cl_fill_desktop.py index 9637744..8b3a753 100644 --- a/pym/cl_fill_desktop.py +++ b/pym/cl_fill_desktop.py @@ -34,7 +34,9 @@ class fillVars(): return "" def get_ac_desktop_install(self): - """переключатель для шаблонов инсталяции и удаления программы""" + """ + Trigger for templates of package installation and uninstallation + """ ret = "" action = self.Get("cl_action") if action in ("install","merge"): @@ -44,7 +46,9 @@ class fillVars(): return ret def get_ac_desktop_merge(self): - """переключатель для шаблонов merge""" + """ + Trigger for the merge templates + """ ret = "" action = self.Get("cl_action") if action in ("install","merge"): @@ -52,13 +56,25 @@ class fillVars(): return ret def get_ac_desktop_desktop(self): - """переключатель для шаблонов создания пользовательского профиля""" + """ + Trigger for templates of user profile creating + """ ret = "" action = self.Get("cl_action") if action in ("desktop",): ret = "up" return ret + def get_ac_desktop_live(self): + """ + Trigger for templates update live configuration of profile + """ + ret = "" + action = self.Get("cl_action") + if action in ("desktop","live"): + ret = "up" + return ret + def get_ur_domain_set(self): '''доменный пользователь "on", "off"''' ret = "off" diff --git a/pym/cl_vars_desktop.py b/pym/cl_vars_desktop.py index bcd6715..8d19381 100644 --- a/pym/cl_vars_desktop.py +++ b/pym/cl_vars_desktop.py @@ -54,15 +54,18 @@ class Data: # Host Jabber пользователя ur_jid_host = {'mode':"w"} - # переключатель для шаблонов merge + # trigger for the merge templates ac_desktop_merge = {} - # переключатель для шаблонов инсталяции и удаления программы + # trigger for templates of package installation and uninstallation ac_desktop_install = {} - # переключатель для шаблонов создания пользовательского профиля + # trigger for templates of user profile creating ac_desktop_desktop = {} + # trigger for templates update live configuration of profile + ac_desktop_live = {} + # доменный пользователь "on", "off" ur_domain_set = {}