@@ -49,16 +49,13 @@ def addUser(virtualHostUser, path):
4949 else :
5050 command = "adduser " + virtualHostUser + " -M -d " + path
5151
52- cmd = shlex .split (command )
53- subprocess .call (cmd , stdout = FNULL , stderr = subprocess .STDOUT )
52+ ProcessUtilities .executioner (command )
5453
5554 command = "groupadd " + virtualHostUser
56- cmd = shlex .split (command )
57- subprocess .call (cmd , stdout = FNULL , stderr = subprocess .STDOUT )
55+ ProcessUtilities .executioner (command )
5856
5957 command = "usermod -a -G " + virtualHostUser + " " + virtualHostUser
60- cmd = shlex .split (command )
61- subprocess .call (cmd , stdout = FNULL , stderr = subprocess .STDOUT )
58+ ProcessUtilities .executioner (command )
6259
6360 except BaseException as msg :
6461 logging .CyberCPLogFileWriter .writeToFile (str (msg ) + " [addingUsers]" )
@@ -135,7 +132,8 @@ def createDirectories(path, virtualHostUser, pathHTML, pathLogs, confPath, compl
135132
136133 try :
137134 ## For configuration files permissions will be changed later globally.
138- os .makedirs (confPath )
135+ if not os .path .exists (confPath ):
136+ os .makedirs (confPath )
139137 except OSError as msg :
140138 logging .CyberCPLogFileWriter .writeToFile (
141139 str (msg ) + " [45 Not able to directories for virtual host [createDirectories]]" )
@@ -380,13 +378,22 @@ def deleteVirtualHostConfigurations(virtualHostName):
380378 command = "rm -rf /home/vmail/" + virtualHostName
381379 subprocess .call (shlex .split (command ))
382380
381+ ##
382+
383383 if ProcessUtilities .decideDistro () == ProcessUtilities .centos :
384- command = 'userdel %s' % (externalApp )
384+ command = 'userdel -r -f %s' % (externalApp )
385385 else :
386386 command = 'deluser %s' % (externalApp )
387387
388388 ProcessUtilities .executioner (command )
389389
390+ #
391+
392+ command = 'groupdel %s' % (externalApp )
393+ ProcessUtilities .executioner (command )
394+
395+ ##
396+
390397 except BaseException as msg :
391398 logging .CyberCPLogFileWriter .writeToFile (str (msg ) + " [Not able to remove virtual host configuration from main configuration file.]" )
392399 return 0
@@ -398,6 +405,7 @@ def deleteVirtualHostConfigurations(virtualHostName):
398405 vhost .deleteCoreConf (virtualHostName , numberOfSites )
399406
400407 delWebsite = Websites .objects .get (domain = virtualHostName )
408+ externalApp = delWebsite .externalApp
401409
402410 ## Cagefs
403411
@@ -427,8 +435,22 @@ def deleteVirtualHostConfigurations(virtualHostName):
427435
428436 ## Delete mail accounts
429437
430- command = "sudo rm -rf /home/vmail/" + virtualHostName
438+ command = "rm -rf /home/vmail/" + virtualHostName
431439 subprocess .call (shlex .split (command ))
440+
441+ ##
442+
443+ if ProcessUtilities .decideDistro () == ProcessUtilities .centos :
444+ command = 'userdel -r -f %s' % (externalApp )
445+ else :
446+ command = 'deluser %s' % (externalApp )
447+
448+ ProcessUtilities .executioner (command )
449+
450+ #
451+
452+ command = 'groupdel %s' % (externalApp )
453+ ProcessUtilities .executioner (command )
432454 except BaseException as msg :
433455 logging .CyberCPLogFileWriter .writeToFile (
434456 str (msg ) + " [Not able to remove virtual host configuration from main configuration file.]" )
0 commit comments