Run CyberPanel as user cyberpanel

This commit is contained in:
usmannasir
2017-11-05 03:02:51 +05:00
parent a0ddb0d556
commit 9b5ec7d12f
31 changed files with 3775 additions and 305 deletions

View File

@@ -5,73 +5,18 @@ from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
import time
from backupUtilities import backupUtilities
import signal
import shlex
import subprocess
def verifyHostKey(IPAddress):
try:
backupUtilities.host_key_verification(IPAddress)
def verifyHostKey(directory):
command = "sudo chmod -R 775 " + directory
password = "hello"
print command
expectation = []
cmd = shlex.shlex(command)
expectation.append("continue connecting (yes/no)?")
expectation.append("password:")
setupSSHKeys = pexpect.spawn("ssh root@" + IPAddress)
index = setupSSHKeys.expect(expectation)
if index == 0:
setupSSHKeys.sendline("yes")
setupSSHKeys.expect("password:")
setupSSHKeys.sendline(password)
expectation = []
expectation.append("password:")
expectation.append(pexpect.EOF)
innerIndex = setupSSHKeys.expect(expectation)
if innerIndex == 0:
setupSSHKeys.kill(signal.SIGTERM)
return [1, "None"]
elif innerIndex == 1:
setupSSHKeys.kill(signal.SIGTERM)
return [1, "None"]
elif index == 1:
setupSSHKeys.expect("password:")
setupSSHKeys.sendline(password)
expectation = []
expectation.append("password:")
expectation.append(pexpect.EOF)
innerIndex = setupSSHKeys.expect(expectation)
if innerIndex == 0:
setupSSHKeys.kill(signal.SIGTERM)
return [1, "None"]
elif innerIndex == 1:
setupSSHKeys.kill(signal.SIGTERM)
return [1, "None"]
except pexpect.TIMEOUT, msg:
logging.writeToFile("Timeout [verifyHostKey]")
return [0,"Timeout [verifyHostKey]"]
except pexpect.EOF, msg:
logging.writeToFile("EOF [verifyHostKey]")
return [0,"EOF [verifyHostKey]"]
except BaseException, msg:
logging.writeToFile(str(msg) + " [verifyHostKey]")
return [0,str(msg)+" [verifyHostKey]"]
res = subprocess.call(cmd)
print verifyHostKey("23.95.216.56")
print verifyHostKey("/home/ssl.cyberpanel.net")