Добавлен перенос /etc/skel при создании пользовательского профиля

master-3.5 3.5.1.1
parent 0d52620b7a
commit f88b51a024

@ -26,8 +26,8 @@ from calculate.lib.utils.files import (isMount, process,
getRunCommands, STDOUT, childMounts,
getLoopFromPath,
getMdRaidDevices, listDirectory,
removeDir,
makeDirectory, getProgPath)
removeDir, rsync_files, RsyncOptions,
makeDirectory, getProgPath, FilesError)
from calculate.lib.utils.common import (mountEcryptfs,
CommonError, isBootstrapDataOnly)
@ -339,3 +339,15 @@ class Desktop(MethodsInterface):
return True
else:
return False
def syncSkel(self, ur_home_path, uid, gid):
"""
Скопировать содержимое /etc/skel в каталог пользователя
"""
try:
rsync_files('/etc/skel', ur_home_path,
opts=(RsyncOptions.Archive,
RsyncOptions.Chown(uid, gid),))
except FilesError as e:
raise DesktopError(str(e))
return True

@ -18,7 +18,7 @@ import sys
from os import path
from calculate.core.server.func import Action, Tasks
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
from calculate.lib.utils.files import FilesError, isMount
from calculate.lib.utils.files import FilesError, isMount, listDirectory
from calculate.desktop.desktop import DesktopError
from calculate.lib.cl_template import TemplatesError
@ -48,6 +48,15 @@ class ClDesktopLogoutAction(Action):
'method': 'Desktop.waitLogout(cl_desktop_login,300)'}
]
def need_skel(Get):
home_path = Get('ur_home_path')
if path.exists(home_path):
files = listDirectory(home_path, onlyDir=True)
if len(files) == 1 and ".calculate" in files:
return True
return False
return True
class ClDesktopAction(Action):
"""
@ -63,6 +72,9 @@ class ClDesktopAction(Action):
# список задач для действия
tasks = [
{'name': 'need_skel',
'condition': need_skel
},
# создать домашниюю директорию
{'name': 'create_home',
'message': __("Creating the home directory for {ur_login}"),
@ -96,6 +108,10 @@ class ClDesktopAction(Action):
'condition': lambda Get: (Get('cl_desktop_force_setup_set') == 'on' or
Get('cl_desktop_update_profile_set') == 'on')
},
{'name': 'need_skel:sync_skel',
'message': _("Coping skel data"),
'method': 'Desktop.syncSkel(ur_home_path,ur_uid,ur_gid)'
},
{'name': 'fast_login',
'method': 'Desktop.setFastlogin(ur_login)',
'essential': False,

Loading…
Cancel
Save