Enable Disable FTP Service.

This commit is contained in:
usmannasir
2018-07-23 22:11:42 +05:00
parent d54e05ec4c
commit e62c9f7d1c
13 changed files with 589 additions and 12 deletions

View File

@@ -687,8 +687,8 @@ class preFlightsChecks:
count = 0
while (1):
command = "wget http://cyberpanel.net/CyberPanel.1.7.0.tar.gz"
#command = "wget http://cyberpanel.net/CyberPanelTemp.tar.gz"
#command = "wget http://cyberpanel.net/CyberPanel.1.7.0.tar.gz"
command = "wget http://cyberpanel.net/CyberPanelTemp.tar.gz"
res = subprocess.call(shlex.split(command))
if res == 1:
@@ -707,8 +707,8 @@ class preFlightsChecks:
count = 0
while(1):
command = "tar zxf CyberPanel.1.7.0.tar.gz"
#command = "tar zxf CyberPanelTemp.tar.gz"
#command = "tar zxf CyberPanel.1.7.0.tar.gz"
command = "tar zxf CyberPanelTemp.tar.gz"
res = subprocess.call(shlex.split(command))
@@ -2818,6 +2818,85 @@ milter_default_action = accept
logging.InstallLog.writeToFile(str(msg) + " [setupVirtualEnv]")
return 0
@staticmethod
def enableDisableDNS(state):
try:
servicePath = '/home/cyberpanel/powerdns'
if state == 'Off':
command = 'sudo systemctl stop pdns'
subprocess.call(shlex.split(command))
command = 'sudo systemctl disable pdns'
subprocess.call(shlex.split(command))
try:
os.remove(servicePath)
except:
pass
else:
writeToFile = open(servicePath, 'w+')
writeToFile.close()
except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [enableDisableDNS]")
return 0
@staticmethod
def enableDisableEmail(state):
try:
servicePath = '/home/cyberpanel/postfix'
if state == 'Off':
command = 'sudo systemctl stop postfix'
subprocess.call(shlex.split(command))
command = 'sudo systemctl disable postfix'
subprocess.call(shlex.split(command))
try:
os.remove(servicePath)
except:
pass
else:
writeToFile = open(servicePath, 'w+')
writeToFile.close()
except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [enableDisableEmail]")
return 0
@staticmethod
def enableDisableFTP(state):
try:
servicePath = '/home/cyberpanel/pureftpd'
if state == 'Off':
command = 'sudo systemctl stop pure-ftpd'
subprocess.call(shlex.split(command))
command = 'sudo systemctl disable pure-ftpd'
subprocess.call(shlex.split(command))
try:
os.remove(servicePath)
except:
pass
else:
writeToFile = open(servicePath, 'w+')
writeToFile.close()
except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [enableDisableEmail]")
return 0
@@ -2826,6 +2905,9 @@ def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
parser.add_argument('publicip', help='Please enter public IP for your VPS or dedicated server.')
parser.add_argument('--mysql', help='Specify number of MySQL instances to be used.')
parser.add_argument('--postfix', help='Enable or disable Email Service.')
parser.add_argument('--powerdns', help='Enable or disable DNS Service.')
parser.add_argument('--ftp', help='Enable or disable ftp Service.')
args = parser.parse_args()
logging.InstallLog.writeToFile("Starting CyberPanel installation..")
@@ -2906,7 +2988,24 @@ def main():
checks.modSecPreReqs()
checks.setupVirtualEnv()
checks.setupPHPAndComposer()
checks.installation_successfull()
try:
postfix = args.postfix
checks.enableDisableEmail(postfix)
except:
checks.enableDisableEmail('On')
try:
powerdns = args.powerdns
checks.enableDisableDNS(powerdns)
except:
checks.enableDisableDNS('On')
try:
ftp = args.ftp
checks.enableDisableFTP(ftp)
except:
checks.enableDisableFTP('On')
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")