Skip to content
Permalink
Browse files
bug fix: website creation
  • Loading branch information
usmannasir committed Mar 6, 2020
1 parent 5b263d6 commit 1f1863f82f8757c160df213ba47c511e1a1c4e10
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
@@ -190,6 +190,8 @@ def sendCommand(command, user=None):
sock = ret[0]

if user == None:
if command.find('sudo') == -1:
command = 'sudo %s' % (command)
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(ProcessUtilities.token + command)
sock.sendall((ProcessUtilities.token + command).encode('utf-8'))
@@ -49,16 +49,13 @@ def addUser(virtualHostUser, path):
else:
command = "adduser " + virtualHostUser + " -M -d " + path

cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(command)

command = "groupadd " + virtualHostUser
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(command)

command = "usermod -a -G " + virtualHostUser + " " + virtualHostUser
cmd = shlex.split(command)
subprocess.call(cmd, stdout=FNULL, stderr=subprocess.STDOUT)
ProcessUtilities.executioner(command)

except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [addingUsers]")
@@ -135,7 +132,8 @@ def createDirectories(path, virtualHostUser, pathHTML, pathLogs, confPath, compl

try:
## For configuration files permissions will be changed later globally.
os.makedirs(confPath)
if not os.path.exists(confPath):
os.makedirs(confPath)
except OSError as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [45 Not able to directories for virtual host [createDirectories]]")
@@ -380,13 +378,22 @@ def deleteVirtualHostConfigurations(virtualHostName):
command = "rm -rf /home/vmail/" + virtualHostName
subprocess.call(shlex.split(command))

##

if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'userdel %s' % (externalApp)
command = 'userdel -r -f %s' % (externalApp)
else:
command = 'deluser %s' % (externalApp)

ProcessUtilities.executioner(command)

#

command = 'groupdel %s' % (externalApp)
ProcessUtilities.executioner(command)

##

except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")
return 0
@@ -398,6 +405,7 @@ def deleteVirtualHostConfigurations(virtualHostName):
vhost.deleteCoreConf(virtualHostName, numberOfSites)

delWebsite = Websites.objects.get(domain=virtualHostName)
externalApp = delWebsite.externalApp

## Cagefs

@@ -427,8 +435,22 @@ def deleteVirtualHostConfigurations(virtualHostName):

## Delete mail accounts

command = "sudo rm -rf /home/vmail/" + virtualHostName
command = "rm -rf /home/vmail/" + virtualHostName
subprocess.call(shlex.split(command))

##

if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'userdel -r -f %s' % (externalApp)
else:
command = 'deluser %s' % (externalApp)

ProcessUtilities.executioner(command)

#

command = 'groupdel %s' % (externalApp)
ProcessUtilities.executioner(command)
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [Not able to remove virtual host configuration from main configuration file.]")

0 comments on commit 1f1863f

Please sign in to comment.