develop
asamoukin 15 years ago
parent c1af56f5b2
commit b8ee9a6b5e

@ -234,7 +234,7 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
# self.data
self.progName = { 'cl-client':0,
'cl-createhome':1,
'cl-sync':2
'cl-sync':2,
}
# Cвязь длинных опций помощи и выводимых разделов помощи с опциями
@ -346,6 +346,11 @@ WHEN may be 'never', 'always', or 'auto'")
'helpChapter':_("Common options"),
'help':_("always join the user profiles and preferences")
},
{'progAccess':(0,),
'longOption':"install",
'helpChapter':_("Common options"),
'help':_("Adds use of scripts this package for window manager")
},
{'progAccess':(0,),
'longOption':"mount",
'helpChapter':_("Common options"),
@ -613,6 +618,18 @@ conjunction with the 'login' or 'logout'")
else:
return dirsFiles
def applyProfilesFromSystem(self):
"""Применяем профили для cистемы"""
# Cоздаем объект профиль
clProf = cl_profile.profile(self.clVars)
# Объединяем профили
dirsFiles = clProf.applyProfiles()
if clProf.getError():
self.printERROR(clProf.getError())
return False
else:
return dirsFiles
def getUserPassword(self, pwDialog=False):
"""Получить пароль у пользователя
@ -709,6 +726,34 @@ conjunction with the 'login' or 'logout'")
alwProfilePath.append(prPath)
return alwProfilePath
def setDaemonAutostart(self, daemon):
"""Прописывает демона в автозагрузку"""
execStr = "rc-update add %s default" %daemon
textLine = self.execProg(execStr)
if "added to runlevel" in textLine or\
"already installed in runlevel" in textLine:
return True
else:
self.printERROR(_("ERROR") + ": " + execStr)
self.printERROR(_("Can not add at default runlevel"))
return False
def delDaemonAutostart(self, daemon):
"""Удаляет демона из автозагрузки"""
execStr = "rc-update del %s default" %daemon
textLine = self.execProg(execStr)
if "removed from the following runlevels" in textLine or\
"not found in any of the specified runlevels" in textLine:
return True
#Для openrc
elif "removed from runlevel" in textLine or\
"is not in the runlevel" in textLine:
return True
else:
self.printERROR(_("ERROR") + ": " + execStr)
self.printERROR(_("Not deleted from default runlevel"))
return False
def createHome(self, userName, applyAlways=False, progress=False):
"""Создание пользовательской директории с настройками для kde4"""
# Имя пользователя
@ -912,10 +957,58 @@ conjunction with the 'login' or 'logout'")
return False
self.clVars.Delete("cl_remote_host","local")
self.clVars.Delete("cl_remote_pw","local")
self.execProg("calculate -P install/6intranet")
self.clVars.Set("cl_remote_host","",True)
self.clVars.Set("cl_remote_pw","",True)
# Наложим профили install/domain
# Новые пути к профилям
profPaths=['/usr/lib/calculate/calculate-client/profile/install/domain',
'/var/calculate/remote/client-profile/install/domain',
'/var/calculate/client-profile/install/domain']
# Изменяем переменную хранения профилей
self.clVars.Set("cl_profile_path",profPaths,True)
# Наложим профили
dirsAndFiles = self.applyProfilesFromSystem()
if not dirsAndFiles:
self.printERROR(_("Not apply 'install/domain' profiles"))
return False
if not self.delDaemonAutostart("client"):
return False
self.printOK(_("Computer removed from domain %s")%domain + " ...")
return True
def getProfilePath(self, profPaths):
"""список накладываемых профилей"""
profpath = []
for profPath in profPaths:
if os.path.exists(profPath):
profpath.append(profPath)
return profpath
def applyProfilesClient(self, clVars=False, printSuccess=True):
"""Наложение профиля клиента"""
if not clVars:
#Создаем объект переменных
self.createClVars()
clVars = self.clVars
# Изменяем базовую директорию наложения профилей
clVars.Set("cl_root_path","/",True)
# Новые пути к профилям
profPaths=['/usr/lib/calculate/calculate-client/profile/install/client',
'/var/calculate/remote/client-profile/install/client',
'/var/calculate/client-profile/install/client']
# Изменяем переменную хранения профилей
clVars.Set("cl_profile_path",profPaths,True)
# Наложим профили
dirsAndFiles = self.applyProfilesFromSystem()
if not dirsAndFiles:
self.printERROR(_("Not apply 'install/client' profiles"))
return False
if printSuccess:
self.printOK(_("Added use of scripts this package for window \
manager") + " ...")
return True
def addDomain(self, domainName):
"""Вводим в домен"""
# Проверяем на root
@ -1016,16 +1109,30 @@ conjunction with the 'login' or 'logout'")
self.printERROR("ld_services_dn or ld_unix_dn \
or ld_bind_dn or ld_bind_pw")
return False
execStr = "calculate --set-server_url=%s --set-ldap_base=%s \
--set-ldap_root=%s --set-ldap_bind=%s --set-ldap_bindpw=%s -P \
install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
self.execProg(execStr)
# Наложим профили install/client
if not self.applyProfilesClient(self.clVars, False):
return False
# Наложим профили install/domain
# Новые пути к профилям
profPaths=['/usr/lib/calculate/calculate-client/profile/install/domain',
'/var/calculate/remote/client-profile/install/domain',
'/var/calculate/client-profile/install/domain']
# Изменяем переменную хранения профилей
self.clVars.Set("cl_profile_path",profPaths,True)
# Наложим профили
dirsAndFiles = self.applyProfilesFromSystem()
if not dirsAndFiles:
self.printERROR(_("Not apply 'install/domain' profiles"))
return False
# Рестартуем dbus
if os.path.exists('/etc/init.d/dbus'):
textLines = self.execProg("/etc/init.d/dbus restart", False, False)
if not (textLines and type(textLines) == types.ListType and\
"ok" in textLines[-1] or textLines and "ok" in textLines):
self.printWARNING(_("Error restarting /etc/init.d/dbus")+ " ...")
return False
if not self.setDaemonAutostart("client"):
return False
self.printOK(_("Computer added to domain %s")%domain + " ...")
return True

@ -28,23 +28,21 @@
class Data:
#базовый суффикс LDAP
#Vl soft_ldap_base
ld_base_dn = {}
#DN всех сервисов
#V soft_ldap_sevices_dn
ld_services_dn = {}
#DN админстратора сервиса Unix (он, же DN сервиса)
#V soft_ldap_admin_unix
ld_unix_dn = {}
#DN админстратора сервиса Samba (он, же DN сервиса)
ld_samba_dn = {}
#bind суффикс LDAP
#Vl soft_ldap_bind
ld_bind_dn = {}
#пароль для пользователя для чтения
#Vl soft_ldap_bindpw
ld_bind_pw = {}
# имя компьютера с настроенным сервисом Mail
@ -80,19 +78,15 @@ class Data:
#путь к директории относительно которой происходит наложение профилей на
#файлы системы
#setup_path_install
cl_root_path = {}
##список накладываемых профилей при установке, наложении профилей
#setup_path_profinstall
cl_profile_path = {}
#Логин LDAP пользователя
#V soft_ldap_user_login
ur_login = {'mode':"w"}
#Полное имя LDAP пользователя
#V soft_ldap_user_full_name
ur_fullname = {'mode':"w"}
# Почтовый адрес пользователя
@ -139,5 +133,4 @@ class Data:
# Calculate плюс версия калкулэйта для записи в заголовок файла
# объединяемого с профилем
#setup_name
cl_ver = {'value':'Calculate-client 2.0.17'}

@ -63,6 +63,9 @@ if __name__ == "__main__":
elif optObj.opt.has_key('mount'):
if not ldapObj.mountRemote():
flagError = True
elif optObj.opt.has_key('install'):
if not ldapObj.applyProfilesClient():
flagError = True
if flagError:
sys.exit(1)
else:

@ -21,6 +21,7 @@ import glob
import sys
import re
from distutils.core import setup, Extension
from distutils.command.install_data import install_data
module1 = Extension('calculate-client.pym._cl_keys',
library_dirs = ['/usr/lib'],
@ -106,7 +107,39 @@ def create_data_files (data_dirs, prefix=""):
data_files += create_data_files (data_dirs_local)
data_files += create_data_files (data_dirs_share, share_calculate_dir)
data_files += [('/etc/init.d', ['data/client'])]
data_files += [('/usr/share/calculate/xdm', ['data/login',
'data/logout',
'data/cmd_login'])]
class cl_install_data(install_data):
def run (self):
install_data.run(self)
data_file = [("/etc/init.d/client",0755),
("/usr/share/calculate/xdm/login",0755),
("/usr/share/calculate/xdm/logout",0755),
("/usr/share/calculate/xdm/cmd_login",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)
data_find = {}
for i in range(len(fileNames)):
listNames[i].reverse()
data_find[fileNames[i]] =[listNames[i],data_file[i][1]]
for path in self.get_outputs():
nameFile = os.path.split(path)[1]
if nameFile in data_find.keys():
data = data_find[nameFile][0]
mode = data_find[nameFile][1]
flagFound = True
iMax = len(data)
pathFile = path
for i in range(iMax):
if data[i] != os.path.split(pathFile)[1]:
flagFound = False
break
pathFile = os.path.split(pathFile)[0]
if flagFound:
os.chmod(path, mode)
setup(
name = 'calculate-client',
@ -123,4 +156,5 @@ setup(
"./scripts/cl-client",
"./scripts/cl-sync"],
ext_modules = [module1],
cmdclass={'install_data': cl_install_data},
)

Loading…
Cancel
Save