|
|
|
@ -30,7 +30,7 @@ import _cl_keys
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
Version = "calculate-client 2.0.13"
|
|
|
|
|
Version = "calculate-client 2.0.14"
|
|
|
|
|
|
|
|
|
|
tr = cl_base.lang()
|
|
|
|
|
tr.setLanguage(sys.modules[__name__])
|
|
|
|
@ -660,27 +660,19 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
self.createClVars()
|
|
|
|
|
pathRemote = "/var/calculate/remote"
|
|
|
|
|
pathHome = "/var/calculate/client-home"
|
|
|
|
|
foundMountRemote =self.isMount(pathRemote ,"cifs")
|
|
|
|
|
foundMountHome =self.isMount(pathHome ,"none",False)
|
|
|
|
|
foundMountRemote = self.isMount(pathRemote ,"cifs")
|
|
|
|
|
foundMountHome = self.isMount(pathHome ,"none",False)
|
|
|
|
|
domain = self.clVars.Get("cl_remote_host")
|
|
|
|
|
if not domain:
|
|
|
|
|
self.printWARNING("The computer is not in domain")
|
|
|
|
|
return True
|
|
|
|
|
if foundMountRemote:
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
umountStr = "umount %s"%(pathRemote)
|
|
|
|
|
textLine = self.execProg(umountStr)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba resource [remote]") +\
|
|
|
|
|
" ...")
|
|
|
|
|
textLineUmount = self.umountSleepPath(pathRemote)
|
|
|
|
|
if not textLineUmount:
|
|
|
|
|
return False
|
|
|
|
|
if foundMountHome:
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
umountStr = "umount %s"%(pathHome)
|
|
|
|
|
textLine = self.execProg(umountStr)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not unmount") + " " + pathHome +\
|
|
|
|
|
" ...")
|
|
|
|
|
textLineUmount = self.umountSleepPath(pathHome ,"none", False)
|
|
|
|
|
if not textLineUmount:
|
|
|
|
|
return False
|
|
|
|
|
self.clVars.Delete("cl_remote_host","local")
|
|
|
|
|
self.clVars.Delete("cl_remote_pw","local")
|
|
|
|
@ -808,6 +800,28 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
os.remove(rmFile)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def umountSleepPath(self, path, typeMount='cifs', secondPath=True):
|
|
|
|
|
"""Отмонтирует путь при неудаче задержка потом повтор"""
|
|
|
|
|
#Проверяем на монтирование директории
|
|
|
|
|
if self.isMount(path, typeMount, secondPath):
|
|
|
|
|
textLine = self.execProg("umount %s"%path)
|
|
|
|
|
if textLine != None:
|
|
|
|
|
i = 0
|
|
|
|
|
flagError = False
|
|
|
|
|
while (i<len(self.sleeps) and textLine != None):
|
|
|
|
|
# Задержка перед следующей попыткой
|
|
|
|
|
time.sleep(self.sleeps[i])
|
|
|
|
|
# Отмонтируем Samba ресурс
|
|
|
|
|
if self.isMount(path, typeMount, secondPath):
|
|
|
|
|
textLine = self.execProg("umount %s"%path)
|
|
|
|
|
else:
|
|
|
|
|
textLine = None
|
|
|
|
|
break
|
|
|
|
|
if textLine != None:
|
|
|
|
|
self.printERROR(_("Can not unmount path %s")%path + " ...")
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def umountUserRes(self, userName):
|
|
|
|
|
"""Отмонтирование пользовательских ресурсов и синхронизация настроек"""
|
|
|
|
|
# Проверяем на root
|
|
|
|
@ -866,11 +880,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
# Записывает доменное имя сервера если
|
|
|
|
|
# с сервером корректно соединились
|
|
|
|
|
FD.close()
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLine = self.execProg("umount %s"%path)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba resource \
|
|
|
|
|
[%s]")%res + " ...")
|
|
|
|
|
textLine = self.umountSleepPath(path)
|
|
|
|
|
if not textLine:
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if os.path.exists(path) and not os.listdir(path):
|
|
|
|
@ -926,10 +937,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
self.moveHomeDir(homeDir)
|
|
|
|
|
for path, res in pathRemote:
|
|
|
|
|
if self.isMount(path ,"cifs"):
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLine = self.execProg("umount %s"%path)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not unmount dir %s")%path + " ...")
|
|
|
|
|
textLine = self.umountSleepPath(path)
|
|
|
|
|
if not textLine:
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if os.path.exists(path) and not os.listdir(path):
|
|
|
|
@ -979,9 +988,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
mountUidList=['ftp','share']):
|
|
|
|
|
"""Монтирует Samba ресурсы"""
|
|
|
|
|
#Экранируем символы
|
|
|
|
|
#print "PWD", userPwd
|
|
|
|
|
escUserPwd = re.sub("(\W)", r"\\\1",userPwd)
|
|
|
|
|
#print "escPWD", escUserPwd
|
|
|
|
|
if res in mountUidList:
|
|
|
|
|
# Монтируем директории c uid
|
|
|
|
|
mountStr="PASSWD=%s mount -t cifs -o user=%s,uid=%s,gid=%s"\
|
|
|
|
@ -994,7 +1001,6 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
userName)+\
|
|
|
|
|
" //%s/%s %s" %(self.clVars.Get("cl_remote_host"),
|
|
|
|
|
res, path)
|
|
|
|
|
#print mountStr
|
|
|
|
|
textLine = self.execProg(mountStr)
|
|
|
|
|
return textLine
|
|
|
|
|
|
|
|
|
@ -1125,11 +1131,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
if not self.syncUser(userName, homeDir, "login"):
|
|
|
|
|
return False
|
|
|
|
|
# Отмонтируем ресурс
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLine = self.execProg("umount %s"%defaultPath)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba resource \
|
|
|
|
|
[%s]")%"unix" + " ...")
|
|
|
|
|
textLine = self.umountSleepPath(defaultPath)
|
|
|
|
|
if not textLine:
|
|
|
|
|
return False
|
|
|
|
|
if prevHost and prevHost != self.clVars.Get("cl_remote_host"):
|
|
|
|
|
# Монтируем настройки пользователя удаленного сервера
|
|
|
|
@ -1141,11 +1144,8 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
self.clVars.Set("cl_remote_host", defaultHost, True)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
if self.isMount(defaultPath, 'cifs'):
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLineUmount=self.execProg("umount %s"%path)
|
|
|
|
|
if not (textLineUmount == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba \
|
|
|
|
|
resource [%s]")%res + " ...")
|
|
|
|
|
textLine = self.umountSleepPath(defaultPath)
|
|
|
|
|
if not textLine:
|
|
|
|
|
return False
|
|
|
|
|
# Монтируем текущий сервер если ошибка подключения к
|
|
|
|
|
# к найденному серверу
|
|
|
|
@ -1176,11 +1176,8 @@ resource [%s]")%res + " ...")
|
|
|
|
|
if pathReplRun and mountServer == "remote":
|
|
|
|
|
# В случае репликации перемонтируем ресурс профилей
|
|
|
|
|
# на текущий сервер (в случае необходимости)
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLine = self.execProg("umount %s"%defaultPath)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba resource \
|
|
|
|
|
[%s]")%"unix" + " ...")
|
|
|
|
|
textLine = self.umountSleepPath(defaultPath)
|
|
|
|
|
if not textLine:
|
|
|
|
|
return False
|
|
|
|
|
textLine = self.mountSambaRes(userName,userPwd,uid,gid,
|
|
|
|
|
"unix",defaultPath)
|
|
|
|
@ -1204,12 +1201,8 @@ resource [%s]")%res + " ...")
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
# Проверяем на монтирование директории
|
|
|
|
|
if self.isMount(path, 'cifs'):
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLineUmount=\
|
|
|
|
|
self.execProg("umount %s"%path)
|
|
|
|
|
if not (textLineUmount == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba \
|
|
|
|
|
resource [%s]")%res + " ...")
|
|
|
|
|
textLineUmount = self.umountSleepPath(path)
|
|
|
|
|
if not textLineUmount:
|
|
|
|
|
return False
|
|
|
|
|
i = 0
|
|
|
|
|
while (i<len(self.sleeps) and not (textLine == None)):
|
|
|
|
@ -1221,11 +1214,8 @@ resource [%s]")%res + " ...")
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
# Проверяем на монтирование директории
|
|
|
|
|
if self.isMount(path, 'cifs'):
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
textLineUmount=self.execProg("umount %s"%path)
|
|
|
|
|
if not (textLineUmount == None):
|
|
|
|
|
self.printERROR(_("Can not unmount Samba \
|
|
|
|
|
resource [%s]")%res + " ...")
|
|
|
|
|
textLineUmount = self.umountSleepPath(path)
|
|
|
|
|
if not textLineUmount:
|
|
|
|
|
return False
|
|
|
|
|
i += 1
|
|
|
|
|
return textLine
|
|
|
|
|