install log in py

This commit is contained in:
Usman Nasir
2021-03-22 14:48:42 +05:00
parent 2a3180e6d9
commit 0990d755b6
4 changed files with 15 additions and 4 deletions

View File

@@ -1021,7 +1021,7 @@ Debug_Log2 "Necessary components installed..,5"
} }
Pre_Install_System_Tweak() { Pre_Install_System_Tweak() {
Debug_Log2 "Setting up sytem tweak...,90" Debug_Log2 "Setting up sytem tweak...,20"
Line_Number=$(grep -n "127.0.0.1" /etc/hosts | cut -d: -f 1) Line_Number=$(grep -n "127.0.0.1" /etc/hosts | cut -d: -f 1)
My_Hostname=$(hostname) My_Hostname=$(hostname)

View File

@@ -2157,8 +2157,10 @@ def main():
parser.add_argument('--mysqluser', help='MySQL user if remote is chosen.') parser.add_argument('--mysqluser', help='MySQL user if remote is chosen.')
parser.add_argument('--mysqlpassword', help='MySQL password if remote is chosen.') parser.add_argument('--mysqlpassword', help='MySQL password if remote is chosen.')
parser.add_argument('--mysqlport', help='MySQL port if remote is chosen.') parser.add_argument('--mysqlport', help='MySQL port if remote is chosen.')
args = parser.parse_args() args = parser.parse_args()
logging.InstallLog.ServerIP = args.publicip
logging.InstallLog.writeToFile("Starting CyberPanel installation..,10") logging.InstallLog.writeToFile("Starting CyberPanel installation..,10")
preFlightsChecks.stdOut("Starting CyberPanel installation..") preFlightsChecks.stdOut("Starting CyberPanel installation..")

View File

@@ -1,9 +1,14 @@
import json
import time import time
import requests
class InstallLog: class InstallLog:
fileName = "/var/log/installLogs.txt" fileName = "/var/log/installLogs.txt"
currentPercent = '10' currentPercent = '10'
LogURL = 'http://cloud.cyberpanel.net:8000/servers/RecvData'
ServerIP = ''
@staticmethod @staticmethod
def writeToFile(message): def writeToFile(message):
@@ -22,3 +27,6 @@ class InstallLog:
file.writelines("[" + time.strftime( file.writelines("[" + time.strftime(
"%m.%d.%Y_%H-%M-%S") + "] " + message + "\n") "%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")
file.close() file.close()
finalData = json.dumps({'ipAddress': InstallLog.ServerIP, "InstallCyberPanelStatus": message})
requests.post(InstallLog.LogURL, data=finalData, verify=False)

View File

@@ -10,6 +10,8 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
class UpgradeCyberPanel: class UpgradeCyberPanel:
LogURL = "http://cloud.cyberpanel.net:8000/settings/RecvData"
def __init__(self, branch, mail, dns, ftp): def __init__(self, branch, mail, dns, ftp):
ipFile = "/etc/cyberpanel/machineIP" ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile) f = open(ipFile)
@@ -18,8 +20,7 @@ class UpgradeCyberPanel:
def PostStatus(self, message): def PostStatus(self, message):
finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message}) finalData = json.dumps({'ipAddress': self.ipAddress, "UpgradeCyberPanelStatus": message})
url = "http://de-a.cyberhosting.org:8000/settings/RecvData" resp = requests.post(UpgradeCyberPanel.LogURL, data=finalData, verify=False)
resp = requests.post(url, data=finalData, verify=False)
print (resp.text) print (resp.text)
def UpgardeNow(self): def UpgardeNow(self):