@@ -49,16 +49,13 @@ def addUser(virtualHostUser, path):
49
49
else :
50
50
command = "adduser " + virtualHostUser + " -M -d " + path
51
51
52
- cmd = shlex .split (command )
53
- subprocess .call (cmd , stdout = FNULL , stderr = subprocess .STDOUT )
52
+ ProcessUtilities .executioner (command )
54
53
55
54
command = "groupadd " + virtualHostUser
56
- cmd = shlex .split (command )
57
- subprocess .call (cmd , stdout = FNULL , stderr = subprocess .STDOUT )
55
+ ProcessUtilities .executioner (command )
58
56
59
57
command = "usermod -a -G " + virtualHostUser + " " + virtualHostUser
60
- cmd = shlex .split (command )
61
- subprocess .call (cmd , stdout = FNULL , stderr = subprocess .STDOUT )
58
+ ProcessUtilities .executioner (command )
62
59
63
60
except BaseException as msg :
64
61
logging .CyberCPLogFileWriter .writeToFile (str (msg ) + " [addingUsers]" )
@@ -135,7 +132,8 @@ def createDirectories(path, virtualHostUser, pathHTML, pathLogs, confPath, compl
135
132
136
133
try :
137
134
## For configuration files permissions will be changed later globally.
138
- os .makedirs (confPath )
135
+ if not os .path .exists (confPath ):
136
+ os .makedirs (confPath )
139
137
except OSError as msg :
140
138
logging .CyberCPLogFileWriter .writeToFile (
141
139
str (msg ) + " [45 Not able to directories for virtual host [createDirectories]]" )
@@ -380,13 +378,22 @@ def deleteVirtualHostConfigurations(virtualHostName):
380
378
command = "rm -rf /home/vmail/" + virtualHostName
381
379
subprocess .call (shlex .split (command ))
382
380
381
+ ##
382
+
383
383
if ProcessUtilities .decideDistro () == ProcessUtilities .centos :
384
- command = 'userdel %s' % (externalApp )
384
+ command = 'userdel -r -f %s' % (externalApp )
385
385
else :
386
386
command = 'deluser %s' % (externalApp )
387
387
388
388
ProcessUtilities .executioner (command )
389
389
390
+ #
391
+
392
+ command = 'groupdel %s' % (externalApp )
393
+ ProcessUtilities .executioner (command )
394
+
395
+ ##
396
+
390
397
except BaseException as msg :
391
398
logging .CyberCPLogFileWriter .writeToFile (str (msg ) + " [Not able to remove virtual host configuration from main configuration file.]" )
392
399
return 0
@@ -398,6 +405,7 @@ def deleteVirtualHostConfigurations(virtualHostName):
398
405
vhost .deleteCoreConf (virtualHostName , numberOfSites )
399
406
400
407
delWebsite = Websites .objects .get (domain = virtualHostName )
408
+ externalApp = delWebsite .externalApp
401
409
402
410
## Cagefs
403
411
@@ -427,8 +435,22 @@ def deleteVirtualHostConfigurations(virtualHostName):
427
435
428
436
## Delete mail accounts
429
437
430
- command = "sudo rm -rf /home/vmail/" + virtualHostName
438
+ command = "rm -rf /home/vmail/" + virtualHostName
431
439
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 )
432
454
except BaseException as msg :
433
455
logging .CyberCPLogFileWriter .writeToFile (
434
456
str (msg ) + " [Not able to remove virtual host configuration from main configuration file.]" )
0 commit comments