Bug fix to permissions and DNS creation!

This commit is contained in:
usmannasir
2018-02-13 11:45:44 +05:00
parent a010f7982e
commit f942945c13
8 changed files with 54 additions and 19 deletions

View File

@@ -137,6 +137,7 @@ app.controller('adminController', function($scope,$http,$timeout) {
$("#remoteBackups").hide();
$("#packageHome").hide();
$("#packageSub").hide();
$("#createWebsite").hide();
}
}

View File

@@ -46,12 +46,16 @@ def getAdminStatus(request):
else:
admin_type = "Normal User"
serverIPAddress = "192.168.100.1"
# read server IP
try:
serverIPAddress = requests.get('https://api.ipify.org').text
except:
pass
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
serverIPAddress = ipData.split('\n', 1)[0]
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" +str(msg))
serverIPAddress = "192.168.100.1"
adminName = administrator.firstName + " " + administrator.lastName

View File

@@ -259,8 +259,12 @@ def addDeleteDNSRecords(request):
admin = Administrator.objects.get(pk=val)
domainsList = []
if admin.type == 1:
domains = Domains.objects.all()
for items in domains:
domainsList.append(items.name)
else:
domains = admin.domains_set.all()
for items in domains:
domainsList.append(items.name)

View File

@@ -2381,6 +2381,14 @@ def main():
logging.InstallLog.writeToFile("Starting CyberPanel installation..")
preFlightsChecks.stdOut("Starting CyberPanel installation..")
## Writing public IP
os.mkdir("/etc/cyberpanel")
machineIP = open("/etc/cyberpanel/machineIP", "w")
machineIP.writelines(args.publicip)
machineIP.close()
cwd = os.getcwd()
checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP")

View File

@@ -1128,8 +1128,6 @@ def Main(cwd):
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
os.mkdir("/etc/cyberpanel")
password = open("/etc/cyberpanel/mysqlPassword","w")
password.writelines(InstallCyberPanel.mysql_Root_password)

View File

@@ -137,6 +137,7 @@ app.controller('adminController', function($scope,$http,$timeout) {
$("#remoteBackups").hide();
$("#packageHome").hide();
$("#packageSub").hide();
$("#createWebsite").hide();
}
}

View File

@@ -27,6 +27,7 @@
<tr>
<th>Domain</th>
<th>Launch</th>
<th>IP Address</th>
<th>Package</th>
<th>Owner</th>
<th>State</th>
@@ -38,6 +39,7 @@
<tr ng-repeat="web in WebSitesList track by $index">
<td ng-bind="web.domain"></td>
<td><a href="{$ web.domain $}"><img width="30px" height="30" class="center-block" src="{% static 'baseTemplate/assets/image-resources/webPanel.png' %}"></a></td>
<td ng-bind="web.ipAddress"></td>
<td ng-bind="web.package"></td>
<td ng-bind="web.admin"></td>
<td ng-bind="web.state"></td>

View File

@@ -312,7 +312,12 @@ def submitWebsiteCreation(request):
soaRecord.save()
try:
recordContentA = requests.get('https://api.ipify.org').text
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
recordContentA = ipData.split('\n', 1)[0]
zone = Domains.objects.get(name=domain)
record = Records(domainOwner=zone,
domain_id=zone.id,
@@ -324,12 +329,16 @@ def submitWebsiteCreation(request):
disabled=0,
auth=1)
record.save()
except:
pass
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile("Unable to add A record while creating website, error: " + str(msg))
except:
try:
recordContentA = requests.get('https://api.ipify.org').text
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
recordContentA = ipData.split('\n', 1)[0]
zone = Domains.objects.get(name=domain)
record = Records(domainOwner=zone,
domain_id=zone.id,
@@ -341,15 +350,14 @@ def submitWebsiteCreation(request):
disabled=0,
auth=1)
record.save()
except:
pass
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile("Unable to add A record while creating website, error: " + str(msg))
## zone creation
selectedPackage = Package.objects.get(packageName=packageName)
website = Websites(admin=admin, package=selectedPackage, domain=domain, adminEmail=adminEmail,
phpSelection=phpSelection, ssl=data['ssl'], externalApp=externalApp)
website = Websites(admin=admin, package=selectedPackage, domain=domain, adminEmail=adminEmail,phpSelection=phpSelection, ssl=data['ssl'], externalApp=externalApp)
website.save()
@@ -567,12 +575,21 @@ def getFurtherAccounts(request):
json_data = "["
checker = 0
try:
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg))
ipAddress = "192.168.100.1"
for items in websites:
if items.state == 0:
state = "Suspended"
else:
state = "Active"
dic = {'domain': items.domain, 'adminEmail': items.adminEmail,'admin': items.admin.userName,'package': items.package.packageName,'state':state}
dic = {'domain': items.domain, 'adminEmail': items.adminEmail,'ipAddress':ipAddress,'admin': items.admin.userName,'package': items.package.packageName,'state':state}
if checker == 0:
json_data = json_data + json.dumps(dic)