mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-02-28 01:10:44 +01:00
Improved DNS Module.
This commit is contained in:
@@ -47,7 +47,7 @@ app.controller('createNameserver', function($scope,$http) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.NSCreation == 1){
|
||||
if(response.data.NSCreation === 1){
|
||||
$scope.createNameserverLoading = true;
|
||||
$scope.nameserverCreationFailed = true;
|
||||
$scope.nameserverCreated = false;
|
||||
@@ -119,7 +119,7 @@ app.controller('createDNSZone', function($scope,$http) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.zoneCreation == 1){
|
||||
if(response.data.zoneCreation === 1){
|
||||
$scope.createDNSZoneLoading = true;
|
||||
$scope.dnsZoneCreationFailed = true;
|
||||
$scope.dnsZoneCreated = false;
|
||||
@@ -160,23 +160,46 @@ app.controller('createDNSZone', function($scope,$http) {
|
||||
|
||||
app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
|
||||
$scope.addRecordsBox = true;
|
||||
$scope.currentRecords = true;
|
||||
$scope.canNotFetchRecords = true;
|
||||
$scope.recordsFetched = true;
|
||||
$scope.recordDeleted = true;
|
||||
$scope.recordAdded = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.recordsLoading = true;
|
||||
$scope.recordDeleted = true;
|
||||
$scope.couldNotDeleteRecords = true;
|
||||
$scope.couldNotAddRecord = true;
|
||||
$scope.recordValueDefault = false;
|
||||
$scope.recordValueMX = true;
|
||||
$scope.recordValueAAAA = true;
|
||||
$scope.recordValueCNAME = true;
|
||||
$scope.recordValueSPF = true;
|
||||
$scope.recordValueTXT = true;
|
||||
$scope.addRecordsBox = true;
|
||||
$scope.currentRecords = true;
|
||||
$scope.canNotFetchRecords = true;
|
||||
$scope.recordsFetched = true;
|
||||
$scope.recordDeleted = true;
|
||||
$scope.recordAdded = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.recordsLoading = true;
|
||||
$scope.recordDeleted = true;
|
||||
$scope.couldNotDeleteRecords = true;
|
||||
$scope.couldNotAddRecord = true;
|
||||
$scope.recordValueDefault = false;
|
||||
|
||||
// Hide records boxes
|
||||
$(".aaaaRecord").hide();
|
||||
$(".cNameRecord").hide();
|
||||
$(".mxRecord").hide();
|
||||
$(".txtRecord").hide();
|
||||
$(".spfRecord").hide();
|
||||
$(".nsRecord").hide();
|
||||
$(".soaRecord").hide();
|
||||
$(".srvRecord").hide();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var currentSelection = "aRecord";
|
||||
$("#"+currentSelection).addClass("active");
|
||||
|
||||
$scope.fetchRecordsTabs = function (recordType) {
|
||||
$("#"+currentSelection).removeClass("active");
|
||||
$("."+currentSelection).hide();
|
||||
$scope.recordsLoading = false;
|
||||
currentSelection = recordType;
|
||||
$("#"+currentSelection).addClass("active");
|
||||
$("."+currentSelection).show();
|
||||
populateCurrentRecords();
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.fetchRecords = function(){
|
||||
@@ -186,7 +209,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
$scope.addDNSRecord = function(){
|
||||
$scope.addDNSRecord = function(type){
|
||||
|
||||
$scope.recordsLoading = false;
|
||||
|
||||
@@ -194,56 +217,82 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
url = "/dns/addDNSRecord";
|
||||
|
||||
|
||||
var selectedZone = $scope.selectedZone;
|
||||
var recordName = $scope.recordName;
|
||||
var recordType = $scope.recordType;
|
||||
|
||||
//specific values
|
||||
|
||||
var recordContentMX = "";
|
||||
var recordContentA = "";
|
||||
var recordContentAAAA = "";
|
||||
var recordContentCNAME = "";
|
||||
var recordContentSPF = "";
|
||||
var recordContentTXT = "";
|
||||
|
||||
|
||||
|
||||
// Record specific values
|
||||
|
||||
if($scope.recordType=="MX"){
|
||||
recordContentMX = $scope.recordContentMX;
|
||||
var data = {};
|
||||
|
||||
if(type === "MX"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentMX = $scope.recordContentMX;
|
||||
data.priority = $scope.priority;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if($scope.recordType=="A"){
|
||||
recordContentA = $scope.recordContentA;
|
||||
else if(type === "A"){
|
||||
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentA = $scope.recordContentA;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
|
||||
}
|
||||
else if($scope.recordType=="AAAA"){
|
||||
recordContentAAAA = $scope.recordContentAAAA;
|
||||
else if(type === "AAAA"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentAAAA = $scope.recordContentAAAA;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if($scope.recordType=="CNAME"){
|
||||
recordContentCNAME = $scope.recordContentCNAME;
|
||||
else if(type === "CNAME"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentCNAME = $scope.recordContentCNAME;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if($scope.recordType=="SPF"){
|
||||
recordContentSPF = $scope.recordContentSPF;
|
||||
else if(type === "SPF"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentSPF = $scope.recordContentSPF;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if($scope.recordType=="TXT"){
|
||||
recordContentTXT = $scope.recordContentTXT;
|
||||
else if(type === "SOA"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.selectedZone;
|
||||
data.recordContentSOA = $scope.recordContentSOA;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "TXT"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentTXT = $scope.recordContentTXT;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "NS"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.selectedZone;
|
||||
data.recordContentNS = $scope.recordContentNS;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
else if(type === "SRV"){
|
||||
data.selectedZone = $scope.selectedZone;
|
||||
data.recordName = $scope.recordName;
|
||||
data.recordContentSRV = $scope.recordContentSRV;
|
||||
data.priority = $scope.priority;
|
||||
data.ttl = $scope.ttl;
|
||||
data.recordType = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var data = {
|
||||
selectedZone:selectedZone,
|
||||
recordName:recordName,
|
||||
recordType:recordType,
|
||||
recordContentA:recordContentA,
|
||||
recordContentMX:recordContentMX,
|
||||
recordContentAAAA:recordContentAAAA,
|
||||
recordContentCNAME:recordContentCNAME,
|
||||
recordContentSPF:recordContentSPF,
|
||||
recordContentTXT:recordContentTXT,
|
||||
};
|
||||
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
@@ -258,7 +307,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.add_status == 1){
|
||||
if(response.data.add_status === 1){
|
||||
|
||||
|
||||
populateCurrentRecords();
|
||||
@@ -313,6 +362,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
|
||||
var data = {
|
||||
selectedZone:selectedZone,
|
||||
currentSelection:currentSelection
|
||||
};
|
||||
|
||||
var config = {
|
||||
@@ -327,9 +377,7 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.fetchStatus == 1){
|
||||
if(response.data.fetchStatus === 1){
|
||||
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
|
||||
@@ -378,7 +426,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.deleteRecord = function(id){
|
||||
|
||||
|
||||
@@ -469,66 +516,6 @@ app.controller('addModifyDNSRecords', function($scope,$http) {
|
||||
|
||||
|
||||
|
||||
// MX Record Settings
|
||||
|
||||
$scope.detectType = function(){
|
||||
|
||||
|
||||
if($scope.recordType=="MX")
|
||||
{
|
||||
$scope.recordValueDefault = true;
|
||||
$scope.recordValueMX = false;
|
||||
$scope.recordValueAAAA = true;
|
||||
$scope.recordValueCNAME = true;
|
||||
$scope.recordValueSPF = true;
|
||||
$scope.recordValueTXT = true;
|
||||
}
|
||||
else if($scope.recordType=="A"){
|
||||
$scope.recordValueDefault = false;
|
||||
$scope.recordValueMX = true;
|
||||
$scope.recordValueAAAA = true;
|
||||
$scope.recordValueCNAME = true;
|
||||
$scope.recordValueSPF = true;
|
||||
$scope.recordValueTXT = true;
|
||||
}
|
||||
else if($scope.recordType=="AAAA"){
|
||||
$scope.recordValueDefault = true;
|
||||
$scope.recordValueMX = true;
|
||||
$scope.recordValueAAAA = false;
|
||||
$scope.recordValueCNAME = true;
|
||||
$scope.recordValueSPF = true;
|
||||
$scope.recordValueTXT = true;
|
||||
}
|
||||
else if($scope.recordType=="CNAME"){
|
||||
$scope.recordValueDefault = true;
|
||||
$scope.recordValueMX = true;
|
||||
$scope.recordValueAAAA = true;
|
||||
$scope.recordValueCNAME = false;
|
||||
$scope.recordValueSPF = true;
|
||||
$scope.recordValueTXT = true;
|
||||
}
|
||||
else if($scope.recordType=="SPF"){
|
||||
$scope.recordValueDefault = true;
|
||||
$scope.recordValueMX = true;
|
||||
$scope.recordValueAAAA = true;
|
||||
$scope.recordValueCNAME = true;
|
||||
$scope.recordValueSPF = false;
|
||||
$scope.recordValueTXT = true;
|
||||
}
|
||||
else if($scope.recordType=="TXT"){
|
||||
$scope.recordValueDefault = true;
|
||||
$scope.recordValueMX = true;
|
||||
$scope.recordValueAAAA = true;
|
||||
$scope.recordValueCNAME = true;
|
||||
$scope.recordValueSPF = true;
|
||||
$scope.recordValueTXT = false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
/* Java script code to delete DNS Zone */
|
||||
@@ -549,7 +536,7 @@ app.controller('deleteDNSZone', function($scope,$http) {
|
||||
$scope.deleteZoneButton = false;
|
||||
$scope.deleteFailure = true;
|
||||
$scope.deleteSuccess = true;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.deleteZoneFinal = function(){
|
||||
|
||||
|
||||
@@ -38,78 +38,243 @@
|
||||
|
||||
<div ng-hide="addRecordsBox" class="form-group">
|
||||
|
||||
<div class="col-sm-3">
|
||||
<select ng-change="detectType()" ng-model="recordType" class="form-control">
|
||||
<option>A</option>
|
||||
<option>AAAA</option>
|
||||
<option>MX</option>
|
||||
<option>CNAME</option>
|
||||
<option>SPF</option>
|
||||
<option>TXT</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="example-box-wrapper">
|
||||
<ul class="nav nav-tabs">
|
||||
<li ng-click="fetchRecordsTabs('aRecord')" id="aRecord" ><a href="">A</a></li>
|
||||
<li ng-click="fetchRecordsTabs('aaaaRecord')" id="aaaaRecord" ><a href="">AAAA</a></li>
|
||||
<li ng-click="fetchRecordsTabs('cNameRecord')" id="cNameRecord"><a href="">CNAME</a></li>
|
||||
<li ng-click="fetchRecordsTabs('mxRecord')" id="mxRecord"><a href="">MX</a></li>
|
||||
<li ng-click="fetchRecordsTabs('txtRecord')" id="txtRecord"><a href="">TXT</a></li>
|
||||
<li ng-click="fetchRecordsTabs('spfRecord')" id="spfRecord"><a href="">SPF</a></li>
|
||||
<li ng-click="fetchRecordsTabs('nsRecord')" id="nsRecord"><a href="">NS</a></li>
|
||||
<li ng-click="fetchRecordsTabs('soaRecord')" id="soaRecord" ><a href="">SOA</a></li>
|
||||
<li ng-click="fetchRecordsTabs('srvRecord')" id="soaRecord" ><a href="">SRV</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3">
|
||||
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
<!------------- A Record box ------------->
|
||||
|
||||
|
||||
<!------------- A Record box ------------->
|
||||
<div class="col-sm-3 aRecord">
|
||||
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
|
||||
<div ng-hide="recordValueDefault" class="col-sm-3">
|
||||
<input placeholder="{% trans 'IP Address' %}" name="dom" type="text" class="form-control" ng-model="recordContentA" required>
|
||||
</div>
|
||||
<div class="col-sm-3 aRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
<!------------- A Record box ------------->
|
||||
|
||||
|
||||
<!------------- AAAA Record box ------------->
|
||||
|
||||
<div ng-hide="recordValueAAAA" class="col-sm-3">
|
||||
<input placeholder="{% trans 'IPV6' %}" name="dom" type="text" class="form-control" ng-model="recordContentAAAA" required>
|
||||
</div>
|
||||
|
||||
<!------------- AAAA Record box ------------->
|
||||
|
||||
|
||||
<!------------- MX Record box ------------->
|
||||
|
||||
<div ng-hide="recordValueMX" class="col-sm-3">
|
||||
<input placeholder="{% trans 'Priority' %}" name="priority" type="number" class="form-control" ng-model="recordContentMX" required>
|
||||
</div>
|
||||
|
||||
<!------------- MX Record box ------------->
|
||||
|
||||
|
||||
<!------------- CNAME Record box ------------->
|
||||
|
||||
<div ng-hide="recordValueCNAME" class="col-sm-3">
|
||||
<input placeholder="{% trans 'Domain Name' %}" name="priority" type="text" class="form-control" ng-model="recordContentCNAME" required>
|
||||
</div>
|
||||
|
||||
<!------------- CNAME Record box ------------->
|
||||
|
||||
<!------------- SPF Record box ------------->
|
||||
|
||||
<div ng-hide="recordValueSPF" class="col-sm-3">
|
||||
<input placeholder="{% trans 'Policy' %}" name="priority" type="text" class="form-control" ng-model="recordContentSPF" required>
|
||||
</div>
|
||||
|
||||
<!------------- SPF Record box ------------->
|
||||
|
||||
<!------------- TXT Record box ------------->
|
||||
|
||||
<div ng-hide="recordValueTXT" class="col-sm-3">
|
||||
<input placeholder="{% trans 'Text' %}" name="priority" type="text" class="form-control" ng-model="recordContentTXT" required>
|
||||
</div>
|
||||
|
||||
<!------------- TXT Record box ------------->
|
||||
<div class="col-sm-3 aRecord">
|
||||
<input placeholder="{% trans 'IP Address' %}" name="dom" type="text" class="form-control" ng-model="recordContentA" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord()" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
<div class="col-sm-3 aRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('A')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- A Record box ------------->
|
||||
|
||||
<!------------- AAAA Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 aaaaRecord">
|
||||
<input placeholder="{% trans 'Name' %}" name="dom" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 aaaaRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 aaaaRecord">
|
||||
<input placeholder="{% trans 'IPV6 Address' %}" name="dom" type="text" class="form-control" ng-model="recordContentAAAA" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3 aaaaRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('AAAA')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- AAAA Record box ------------->
|
||||
|
||||
|
||||
<!------------- CNAME Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 cNameRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 cNameRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 cNameRecord">
|
||||
<input placeholder="{% trans 'Domain Name' %}" type="text" class="form-control" ng-model="recordContentCNAME" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3 cNameRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('CNAME')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- CNAME Record box ------------->
|
||||
|
||||
<!------------- MX Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 mxRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 mxRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 mxRecord">
|
||||
<input placeholder="{% trans 'Priority' %}" type="number" class="form-control" ng-model="priority" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 mxRecord">
|
||||
<input placeholder="{% trans 'Domain Name' %}" type="text" class="form-control" ng-model="recordContentMX" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-2 mxRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('MX')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- CNAME Record box ------------->
|
||||
|
||||
|
||||
<!------------- SPF Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 spfRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 spfRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-3 spfRecord">
|
||||
<input placeholder="{% trans 'Policy' %}" type="text" class="form-control" ng-model="recordContentSPF" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3 spfRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SPF')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- SPF Record box ------------->
|
||||
|
||||
<!------------- TXT Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 txtRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 txtRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-3 txtRecord">
|
||||
<input placeholder="{% trans 'Text' %}" type="text" class="form-control" ng-model="recordContentTXT" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3 txtRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('TXT')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- TXT Record box ------------->
|
||||
|
||||
<!------------- SOA Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 soaRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="selectedZone" disabled>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 soaRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-3 soaRecord">
|
||||
<input placeholder="{% trans 'SOA Value' %}" type="text" class="form-control" ng-model="recordContentSOA" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3 soaRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SOA')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- SOA Record box ------------->
|
||||
|
||||
<!------------- NS Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 nsRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="selectedZone" disabled>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 nsRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-3 nsRecord">
|
||||
<input placeholder="{% trans 'Name server' %}" type="text" class="form-control" ng-model="recordContentNS" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-3 nsRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('NS')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- NS Record box ------------->
|
||||
|
||||
<!------------- SRV Record box ------------->
|
||||
|
||||
|
||||
<div class="col-sm-3 srvRecord">
|
||||
<input placeholder="{% trans 'Name' %}" type="text" class="form-control" ng-model="recordName">
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 srvRecord">
|
||||
<input placeholder="{% trans 'TTL' %}" type="number" class="form-control" ng-model="ttl" required>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 srvRecord">
|
||||
<input placeholder="{% trans 'Prioirty' %}" type="number" class="form-control" ng-model="priority" required>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-3 srvRecord">
|
||||
<input placeholder="{% trans 'Content' %}" type="text" class="form-control" ng-model="recordContentSRV" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-sm-2 srvRecord">
|
||||
<button style="width: 100%;" type="button" ng-click="addDNSRecord('SRV')" class="btn btn-primary">{% trans "Add" %}</button>
|
||||
</div>
|
||||
|
||||
<!------------- SRV Record box ------------->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -129,6 +294,7 @@
|
||||
<th>{% trans "ID" %}</th>
|
||||
<th>{% trans "Type" %}</th>
|
||||
<th>{% trans "Name" %}</th>
|
||||
<th>{% trans "TTL" %}</th>
|
||||
<th>{% trans "Value" %}</th>
|
||||
<th>{% trans "Priority" %}</th>
|
||||
<th>{% trans "Delete" %}</th>
|
||||
@@ -139,6 +305,7 @@
|
||||
<td ng-bind="record.id"></td>
|
||||
<td ng-bind="record.type"></td>
|
||||
<td ng-bind="record.name"></td>
|
||||
<td ng-bind="record.ttl"></td>
|
||||
<td ng-bind="record.content"></td>
|
||||
<td ng-bind="record.priority"></td>
|
||||
<td ng-click="deleteRecord(record.id)"><img src="{% static 'images/delete.png' %}"></td>
|
||||
|
||||
137
dns/views.py
137
dns/views.py
@@ -289,6 +289,7 @@ def getCurrentRecordsForDomain(request):
|
||||
|
||||
data = json.loads(request.body)
|
||||
zoneDomain = data['selectedZone']
|
||||
currentSelection = data['currentSelection']
|
||||
|
||||
domain = Domains.objects.get(name=zoneDomain)
|
||||
|
||||
@@ -297,21 +298,46 @@ def getCurrentRecordsForDomain(request):
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
for items in records:
|
||||
if items.type == "SOA":
|
||||
continue
|
||||
dic = {'id': items.id,
|
||||
'type': items.type,
|
||||
'name': items.name,
|
||||
'content': items.content,
|
||||
'priority': items.prio
|
||||
}
|
||||
fetchType = ""
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
if currentSelection == 'aRecord':
|
||||
fetchType = 'A'
|
||||
elif currentSelection == 'aaaaRecord':
|
||||
fetchType = 'AAAA'
|
||||
elif currentSelection == 'cNameRecord':
|
||||
fetchType = 'CNAME'
|
||||
elif currentSelection == 'mxRecord':
|
||||
fetchType = 'MX'
|
||||
elif currentSelection == 'txtRecord':
|
||||
fetchType = 'TXT'
|
||||
elif currentSelection == 'spfRecord':
|
||||
fetchType = 'SPF'
|
||||
elif currentSelection == 'nsRecord':
|
||||
fetchType = 'NS'
|
||||
elif currentSelection == 'soaRecord':
|
||||
fetchType = 'SOA'
|
||||
elif currentSelection == 'srvRecord':
|
||||
fetchType = 'SRV'
|
||||
|
||||
|
||||
for items in records:
|
||||
if items.type == fetchType:
|
||||
dic = {'id': items.id,
|
||||
'type': items.type,
|
||||
'name': items.name,
|
||||
'content': items.content,
|
||||
'priority': items.prio,
|
||||
'ttl':items.ttl
|
||||
}
|
||||
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
continue
|
||||
|
||||
|
||||
json_data = json_data + ']'
|
||||
@@ -339,6 +365,7 @@ def addDNSRecord(request):
|
||||
zoneDomain = data['selectedZone']
|
||||
recordType = data['recordType']
|
||||
recordName = data['recordName']
|
||||
ttl = int(data['ttl'])
|
||||
|
||||
#admin = Administrator.objects.get(pk=val)
|
||||
|
||||
@@ -363,7 +390,7 @@ def addDNSRecord(request):
|
||||
name=value,
|
||||
type="A",
|
||||
content=recordContentA,
|
||||
ttl=3600,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1 )
|
||||
@@ -379,13 +406,14 @@ def addDNSRecord(request):
|
||||
value = recordName + "." + zoneDomain
|
||||
|
||||
recordContentMX = data['recordContentMX']
|
||||
priority = data['priority']
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=zoneDomain,
|
||||
name=value,
|
||||
type="MX",
|
||||
content=value,
|
||||
ttl=3600,
|
||||
prio=recordContentMX,
|
||||
content=recordContentMX,
|
||||
ttl=ttl,
|
||||
prio=priority,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
@@ -407,12 +435,11 @@ def addDNSRecord(request):
|
||||
name=value,
|
||||
type="AAAA",
|
||||
content=recordContentAAAA,
|
||||
ttl=3600,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1 )
|
||||
record.save()
|
||||
|
||||
elif recordType == "CNAME":
|
||||
|
||||
if recordName == "@":
|
||||
@@ -429,13 +456,11 @@ def addDNSRecord(request):
|
||||
name=value,
|
||||
type="CNAME",
|
||||
content=recordContentCNAME,
|
||||
ttl=3600,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1 )
|
||||
record.save()
|
||||
|
||||
|
||||
elif recordType == "SPF":
|
||||
|
||||
if recordName == "@":
|
||||
@@ -452,13 +477,11 @@ def addDNSRecord(request):
|
||||
name=value,
|
||||
type="SPF",
|
||||
content=recordContentSPF,
|
||||
ttl=3600,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1 )
|
||||
record.save()
|
||||
|
||||
|
||||
elif recordType == "TXT":
|
||||
|
||||
if recordName == "@":
|
||||
@@ -475,11 +498,70 @@ def addDNSRecord(request):
|
||||
name=value,
|
||||
type="TXT",
|
||||
content=recordContentTXT,
|
||||
ttl=3600,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1 )
|
||||
record.save()
|
||||
elif recordType == "SOA":
|
||||
|
||||
recordContentSOA = data['recordContentSOA']
|
||||
|
||||
records = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=zoneDomain,
|
||||
type="SOA",
|
||||
content=recordContentSOA,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
records.save()
|
||||
elif recordType == "NS":
|
||||
|
||||
recordContentNS = data['recordContentNS']
|
||||
|
||||
if recordContentNS == "@":
|
||||
recordContentNS = "ns1." + zoneDomain
|
||||
## re.match
|
||||
elif match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', recordContentNS, M | I):
|
||||
recordContentNS = recordContentNS
|
||||
else:
|
||||
recordContentNS = recordContentNS + "." + zoneDomain
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=zoneDomain,
|
||||
type="NS",
|
||||
content=recordContentNS,
|
||||
ttl=ttl,
|
||||
prio=0,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
elif recordType == "SRV":
|
||||
|
||||
if recordName == "@":
|
||||
value = zoneDomain
|
||||
## re.match
|
||||
elif match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', recordName, M | I):
|
||||
value = recordName
|
||||
else:
|
||||
value = recordName + "." + zoneDomain
|
||||
|
||||
recordContentSRV = data['recordContentSRV']
|
||||
priority = data['priority']
|
||||
|
||||
record = Records(domainOwner=zone,
|
||||
domain_id=zone.id,
|
||||
name=value,
|
||||
type="SRV",
|
||||
content=recordContentSRV,
|
||||
ttl=ttl,
|
||||
prio=priority,
|
||||
disabled=0,
|
||||
auth=1)
|
||||
record.save()
|
||||
|
||||
|
||||
final_dic = {'add_status': 1, 'error_message': "None"}
|
||||
@@ -487,7 +569,6 @@ def addDNSRecord(request):
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
|
||||
except BaseException,msg:
|
||||
final_dic = {'add_status': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
|
||||
59
install/FileManager/.idea/workspace.xml
generated
59
install/FileManager/.idea/workspace.xml
generated
@@ -14,8 +14,8 @@
|
||||
<file leaf-file-name="fileManager.php" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="329">
|
||||
<caret line="19" column="0" lean-forward="true" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
|
||||
<state relative-caret-position="18">
|
||||
<caret line="19" column="0" lean-forward="false" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
@@ -37,7 +37,7 @@
|
||||
<file leaf-file-name="caller.php" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/php/caller.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="450">
|
||||
<state relative-caret-position="558">
|
||||
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
|
||||
<folding />
|
||||
</state>
|
||||
@@ -164,25 +164,26 @@
|
||||
<workItem from="1512401006678" duration="9000" />
|
||||
<workItem from="1512401100852" duration="2365000" />
|
||||
<workItem from="1523948661253" duration="7874000" />
|
||||
<workItem from="1524303326266" duration="7000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="36367000" />
|
||||
<option name="totallyTimeSpent" value="36374000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="1431" y="-4" width="1301" height="772" extended-state="6" />
|
||||
<frame x="1466" y="-4" width="1303" height="780" extended-state="6" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23443505" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
@@ -205,6 +206,35 @@
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/php/caller.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="558">
|
||||
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
@@ -258,24 +288,17 @@
|
||||
<entry file="file://$PROJECT_DIR$/index.html" />
|
||||
<entry file="file://$PROJECT_DIR$/php/caller.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="450">
|
||||
<state relative-caret-position="558">
|
||||
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.cache/.fr-Tsiwv1/CyberCP/install/FileManager/php/fileManager.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.cache/.fr-Tsiwv1/CyberCP/install/FileManager/php/fileManager.php" />
|
||||
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="329">
|
||||
<caret line="19" column="0" lean-forward="true" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
|
||||
<state relative-caret-position="18">
|
||||
<caret line="19" column="0" lean-forward="false" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
|
||||
|
||||
@@ -12,14 +12,22 @@ from backupUtilities import backupUtilities
|
||||
|
||||
class backupSchedule:
|
||||
|
||||
@staticmethod
|
||||
def remoteBackupLogging(fileName, message):
|
||||
try:
|
||||
file = open(fileName,'a')
|
||||
file.writelines("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] "+ message + "\n")
|
||||
file.close()
|
||||
except IOError,msg:
|
||||
return "Can not write to error file."
|
||||
|
||||
|
||||
@staticmethod
|
||||
def createBackup(virtualHost, ipAddress,writeToFile,port):
|
||||
def createBackup(virtualHost, ipAddress, backupLogPath , port):
|
||||
try:
|
||||
|
||||
writeToFile.writelines("["+time.strftime("%I-%M-%S-%a-%b-%Y")+"]"+" Preparing to create backup for: "+virtualHost+"\n")
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Backup started for: " + virtualHost + "\n")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to create backup for: "+virtualHost)
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup started for: " + virtualHost)
|
||||
|
||||
finalData = json.dumps({'websiteToBeBacked': virtualHost})
|
||||
r = requests.post("http://localhost:5003/backup/submitBackupCreation", data=finalData)
|
||||
@@ -37,33 +45,45 @@ class backupSchedule:
|
||||
elif data['abort'] == 1:
|
||||
break
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Backup created for:" + virtualHost + "\n")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup created for: " + virtualHost)
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Preparing to send backup for: " + virtualHost +" to "+ipAddress+ "\n")
|
||||
writeToFile.flush()
|
||||
## Prepping to send backup.
|
||||
|
||||
backupSchedule.sendBackup(backupPath+".tar.gz", ipAddress,writeToFile,port)
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Preparing to send backup for: " + virtualHost +" to " + ipAddress)
|
||||
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Backup for: " + virtualHost + " is sent to " + ipAddress + "\n")
|
||||
backupSchedule.sendBackup(backupPath+".tar.gz", ipAddress, backupLogPath, port)
|
||||
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.writelines("\n")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Backup for: " + virtualHost + " is sent to " + ipAddress)
|
||||
|
||||
writeToFile.writelines("#####################################")
|
||||
## Backup sent.
|
||||
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.writelines("\n")
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "#################################################")
|
||||
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createBackup]")
|
||||
|
||||
@staticmethod
|
||||
def sendBackup(backupPath, IPAddress, writeToFile,port):
|
||||
def sendBackup(backupPath, IPAddress, backupLogPath , port):
|
||||
try:
|
||||
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " root@"+IPAddress+":/home/backup/"+ time.strftime("%a-%b") + "/"
|
||||
|
||||
## IPAddress of local server
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddressLocal = ipData.split('\n', 1)[0]
|
||||
|
||||
##
|
||||
|
||||
writeToFile = open(backupLogPath, "a")
|
||||
command = "sudo scp -o StrictHostKeyChecking=no -P "+port+" -i /root/.ssh/cyberpanel " + backupPath + " root@"+IPAddress+":/home/backup/" + ipAddressLocal + "/" + time.strftime("%a-%b") + "/"
|
||||
subprocess.call(shlex.split(command), stdout=writeToFile)
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]")
|
||||
@@ -75,43 +95,46 @@ class backupSchedule:
|
||||
|
||||
backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%I-%M-%S-%a-%b-%Y")
|
||||
|
||||
writeToFile = open(backupLogPath,"a")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath," Backup log for: " +time.strftime("%I-%M-%S-%a-%b-%Y"))
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,"#################################################\n")
|
||||
|
||||
writeToFile.writelines("#################################################\n")
|
||||
writeToFile.writelines(" Backup log for: " +time.strftime("%I-%M-%S-%a-%b-%Y")+"\n")
|
||||
writeToFile.writelines("#################################################\n")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "")
|
||||
|
||||
writeToFile.writelines("\n")
|
||||
writeToFile.writelines("\n")
|
||||
## IP of Remote server.
|
||||
|
||||
data = open(destinations,'r').readlines()
|
||||
ipAddress = data[0].strip("\n")
|
||||
port = data[1].strip("\n")
|
||||
|
||||
## IPAddress of local server
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddressLocal = ipData.split('\n', 1)[0]
|
||||
|
||||
|
||||
if backupUtilities.checkIfHostIsUp(ipAddress) == 1:
|
||||
checkConn = backupUtilities.checkConnection(ipAddress)
|
||||
if checkConn[0] == 0:
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Connection to:" + ipAddress+" Failed, please resetup this destination from CyberPanel, aborting." + "\n")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Connection to: " + ipAddress+ " Failed, please resetup this destination from CyberPanel, aborting.")
|
||||
return 0
|
||||
else:
|
||||
## Create backup dir on remote server
|
||||
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir /home/backup/" + time.strftime("%a-%b")
|
||||
command = "sudo ssh -o StrictHostKeyChecking=no -p " + port + " -i /root/.ssh/cyberpanel root@" + ipAddress + " mkdir -p /home/backup/"+ ipAddressLocal + "/" + time.strftime("%a-%b")
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
pass
|
||||
else:
|
||||
writeToFile.writelines("[" + time.strftime(
|
||||
"%I-%M-%S-%a-%b-%Y") + "]" + " Host: " + ipAddress + " is down, aborting." + "\n")
|
||||
backupSchedule.remoteBackupLogging(backupLogPath, "Host: " + ipAddress + " is down, aborting.")
|
||||
return 0
|
||||
|
||||
for virtualHost in os.listdir("/home"):
|
||||
if virtualHost == "vmail" or virtualHost == "cyberpanel" or virtualHost =="backup":
|
||||
if virtualHost == "vmail" or virtualHost == "cyberpanel" or virtualHost == "backup":
|
||||
continue
|
||||
backupSchedule.createBackup(virtualHost,ipAddress,writeToFile,port)
|
||||
backupSchedule.createBackup(virtualHost, ipAddress, backupLogPath, port)
|
||||
|
||||
except BaseException,msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [prepare]")
|
||||
|
||||
@@ -1,111 +1,93 @@
|
||||
import time
|
||||
import thread
|
||||
import tarfile
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
from shutil import rmtree
|
||||
import shutil
|
||||
import requests
|
||||
import json
|
||||
|
||||
class Upgrade:
|
||||
logPath = "/usr/local/lscp/logs/upgradeLog"
|
||||
|
||||
@staticmethod
|
||||
def downloadLink():
|
||||
url = "https://cyberpanel.net/version.txt"
|
||||
r = requests.get(url, verify=True)
|
||||
data = json.loads(r.text)
|
||||
version_number = str(data['version'])
|
||||
version_build = str(data['build'])
|
||||
return (version_number + "." + version_build + ".tar.gz")
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def upgrade(currentVersion,currentBuild):
|
||||
def upgrade():
|
||||
|
||||
upgradeLog = open(Upgrade.logPath,"w")
|
||||
os.chdir("/usr/local")
|
||||
|
||||
if os.path.exists("/usr/local/CyberCP.tar.gz"):
|
||||
path = "/usr/local/CyberCP.tar.gz"
|
||||
command = 'wget http://cyberpanel.net/CyberCP.tar.gz'
|
||||
tarOpen = "CyberCP.tar.gz"
|
||||
else:
|
||||
path = "/usr/local/CyberPanel.1.4.tar.gz"
|
||||
command = 'wget http://cyberpanel.net/CyberPanel.1.4.tar.gz'
|
||||
tarOpen = "CyberPanel.1.4.tar.gz"
|
||||
versionNumbring = Upgrade.downloadLink()
|
||||
|
||||
## Download latest version.
|
||||
|
||||
command = "wget https://cyberpanel.net/CyberPanel." + versionNumbring
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Backup settings file.
|
||||
|
||||
shutil.copy("/usr/local/CyberCP/CyberCP/settings.py","/usr/local/settings.py")
|
||||
|
||||
## Remove Core Files
|
||||
|
||||
command = "rm -rf /usr/local/CyberCP"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Extract Latest files
|
||||
|
||||
command = "tar zxf CyberPanel." + versionNumbring
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Copy settings file
|
||||
|
||||
shutil.copy("/usr/local/settings.py", "/usr/local/CyberCP/CyberCP/")
|
||||
|
||||
## Move static files
|
||||
|
||||
command = "rm -rf /usr/local/lscp/cyberpanel/static"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "mv /usr/local/CyberCP/static /usr/local/lscp/cyberpanel"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Copy File manager files
|
||||
|
||||
command = "rm -rf /usr/local/lsws/Example/html/FileManager"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws/Example/html"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
## Install TLDExtract
|
||||
|
||||
settings = "/usr/local/CyberCP/CyberCP/settings.py"
|
||||
command = "pip install tldextract"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
try:
|
||||
data = open(settings,'r').readlines()
|
||||
except:
|
||||
pass
|
||||
## Change File manager permissions
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
command = "chmod -R 777 /usr/local/lsws/Example/html/FileManager"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
if os.path.exists("/usr/local/CyberCP"):
|
||||
rmtree("/usr/local/CyberCP")
|
||||
## Restart Gunicorn
|
||||
|
||||
## Downloading CyberCP
|
||||
|
||||
upgradeLog.writelines("Started download for latest Version.. \n")
|
||||
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
## Extracting latest version
|
||||
|
||||
|
||||
upgradeLog.writelines("Extracting Latest version.. \n")
|
||||
|
||||
tar = tarfile.open(tarOpen)
|
||||
tar.extractall("/usr/local")
|
||||
tar.close()
|
||||
|
||||
if os.path.exists("/usr/local/lscp/cyberpanel/static"):
|
||||
rmtree("/usr/local/lscp/cyberpanel/static")
|
||||
|
||||
command = 'mv /usr/local/CyberCP/static /usr/local/lscp/cyberpanel'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
## Adjusting settings
|
||||
|
||||
try:
|
||||
upgradeLog.writelines("Fixing Settings.. \n")
|
||||
|
||||
writeToFile = open(settings,'w')
|
||||
|
||||
for items in data:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
writeToFile.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
command = 'systemctl restart gunicorn.socket'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
upgradeLog.writelines("Upgrade Completed")
|
||||
command = "systemctl restart gunicorn.socket"
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
## Upgrade version
|
||||
|
||||
r = requests.post("http://localhost:5003/base/upgradeVersion")
|
||||
|
||||
upgradeLog.writelines(r.text+"\n")
|
||||
|
||||
upgradeLog.close()
|
||||
|
||||
|
||||
|
||||
|
||||
print("Upgrade Completed.")
|
||||
|
||||
@staticmethod
|
||||
def initiateUpgrade(currentVersion,currentBuild):
|
||||
thread.start_new_thread(Upgrade.upgrade, (currentVersion, currentBuild))
|
||||
|
||||
Upgrade.upgrade("1","1")
|
||||
Upgrade.upgrade()
|
||||
Reference in New Issue
Block a user