mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
made changes in updatemysql
This commit is contained in:
@@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||||||
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,14 @@ class DatabaseManager:
|
|||||||
proc = httpProc(request, template, data, 'admin')
|
proc = httpProc(request, template, data, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
def Upgardemysql(self, request = None, userID = None):
|
||||||
|
data={}
|
||||||
|
data['mysqlversions']=['10.6','10.11']
|
||||||
|
template = 'databases/Updatemysql.html'
|
||||||
|
proc = httpProc(request, template, data, 'admin')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def fetchDatabases(self, userID = None, data = None):
|
def fetchDatabases(self, userID = None, data = None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|||||||
@@ -836,4 +836,61 @@ app.controller('OptimizeMysql', function ($scope, $http) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
app.controller('mysqlupdate', function ($scope, $http, $timeout) {
|
||||||
|
$scope.cyberPanelLoading = true;
|
||||||
|
$scope.dbLoading = true;
|
||||||
|
$scope.installlogs = true;
|
||||||
|
|
||||||
|
$scope.Upgardemysql = function () {
|
||||||
|
$scope.dbLoading = false;
|
||||||
|
$scope.installform = true;
|
||||||
|
|
||||||
|
|
||||||
|
url = "/dataBases/upgrademysqlnow";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
mysqlversion: $scope.version
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialData(response) {
|
||||||
|
$scope.cyberhosting = true;
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
$scope.installlogs = false;
|
||||||
|
|
||||||
|
$timeout(getRequestStatus, 1000);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Error!',
|
||||||
|
text: response.data.error_message,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialData(response) {
|
||||||
|
$scope.cyberhosting = true;
|
||||||
|
new PNotify({
|
||||||
|
title: 'Error!',
|
||||||
|
text: 'Could not connect to server, please refresh this page.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$scope.getRequestStatus
|
||||||
|
});
|
||||||
63
databases/templates/databases/Updatemysql.html
Normal file
63
databases/templates/databases/Updatemysql.html
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
{% extends "baseTemplate/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "List Databases - CyberPanel" %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% load static %}
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div id="page-title">
|
||||||
|
<h2>{% trans "Upgrade Mysql" %}
|
||||||
|
|
||||||
|
</h2>
|
||||||
|
<p>{% trans "On this page you can update mysql." %}</p>
|
||||||
|
</div>
|
||||||
|
<div ng-controller="mysqlupdate" class="panel">
|
||||||
|
<div class="panel-body">
|
||||||
|
<h3 class="content-box-header">
|
||||||
|
{% trans "Update Mysql" %} <img ng-hide="dbLoading"
|
||||||
|
src="{% static 'images/loading.gif' %}">
|
||||||
|
</h3>
|
||||||
|
<div class="example-box-wrapper">
|
||||||
|
|
||||||
|
<form name="websiteCreationForm" action="/"
|
||||||
|
class="form-horizontal bordered-row panel-body">
|
||||||
|
|
||||||
|
<div ng-hide="installform" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{% trans "Mysql version" %} </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select ng-model="version" class="form-control" required>
|
||||||
|
{% for version in mysqlversions %}
|
||||||
|
<option>{{ version }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-hide="installform" class="form-group">
|
||||||
|
<label class="col-sm-3 control-label"></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<button type="button" ng-click="Upgardemysql()"
|
||||||
|
class="btn btn-primary btn-lg">{% trans "Update Mysql" %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-hide="installlogs" class="form-group">
|
||||||
|
<textarea rows="30" style="width: 100%"></textarea>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
<a style="display: inline-block;" href="{% url 'OptimizeMySQL' %}" class="btn btn-primary">
|
<a style="display: inline-block;" href="{% url 'OptimizeMySQL' %}" class="btn btn-primary">
|
||||||
<i class="glyph-icon icon-database"></i> Optimize MySQL
|
<i class="glyph-icon icon-database"></i> Optimize MySQL
|
||||||
</a>
|
</a>
|
||||||
|
<a style="display: inline-block;" href="{% url 'UpgradeMySQL' %}" class="btn btn-primary">
|
||||||
|
<i class="glyph-icon icon-database"></i> Upgrade MySQL
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-box-header">
|
<div class="content-box-header">
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ urlpatterns = [
|
|||||||
url(r'^fetchDatabases', views.fetchDatabases, name='fetchDatabases'),
|
url(r'^fetchDatabases', views.fetchDatabases, name='fetchDatabases'),
|
||||||
url(r'^MysqlManager', views.MySQLManager, name='MysqlManager'),
|
url(r'^MysqlManager', views.MySQLManager, name='MysqlManager'),
|
||||||
url(r'^OptimizeMySQL', views.OptimizeMySQL, name='OptimizeMySQL'),
|
url(r'^OptimizeMySQL', views.OptimizeMySQL, name='OptimizeMySQL'),
|
||||||
|
url(r'^upgrademysqlnow', views.upgrademysqlnow, name='upgrademysqlnow'),
|
||||||
|
url(r'^UpgradeMySQL', views.UpgradeMySQL, name='UpgradeMySQL'),
|
||||||
url(r'^getMysqlstatus', views.getMysqlstatus, name='getMysqlstatus'),
|
url(r'^getMysqlstatus', views.getMysqlstatus, name='getMysqlstatus'),
|
||||||
url(r'^restartMySQL', views.restartMySQL, name='restartMySQL'),
|
url(r'^restartMySQL', views.restartMySQL, name='restartMySQL'),
|
||||||
url(r'^generateRecommendations', views.generateRecommendations, name='generateRecommendations'),
|
url(r'^generateRecommendations', views.generateRecommendations, name='generateRecommendations'),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import time
|
||||||
|
from random import randint
|
||||||
|
|
||||||
from django.shortcuts import redirect, HttpResponse
|
from django.shortcuts import redirect, HttpResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
@@ -252,6 +253,7 @@ def generateAccess(request):
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def fetchDetailsPHPMYAdmin(request):
|
def fetchDetailsPHPMYAdmin(request):
|
||||||
try:
|
try:
|
||||||
@@ -260,15 +262,13 @@ def fetchDetailsPHPMYAdmin(request):
|
|||||||
admin = Administrator.objects.get(id=userID)
|
admin = Administrator.objects.get(id=userID)
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
token = request.POST.get('token')
|
token = request.POST.get('token')
|
||||||
username = request.POST.get('username')
|
username = request.POST.get('username')
|
||||||
|
|
||||||
from plogical.httpProc import httpProc
|
from plogical.httpProc import httpProc
|
||||||
proc = httpProc(request, None,
|
proc = httpProc(request, None,
|
||||||
)
|
)
|
||||||
#return proc.ajax(0, str(request.POST.get('token')))
|
# return proc.ajax(0, str(request.POST.get('token')))
|
||||||
|
|
||||||
if username != admin.userName:
|
if username != admin.userName:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
@@ -295,7 +295,6 @@ def fetchDetailsPHPMYAdmin(request):
|
|||||||
data['userName'] = mysqluser
|
data['userName'] = mysqluser
|
||||||
data['password'] = password
|
data['password'] = password
|
||||||
|
|
||||||
|
|
||||||
proc = httpProc(request, 'databases/AutoLogin.html',
|
proc = httpProc(request, 'databases/AutoLogin.html',
|
||||||
data, 'admin')
|
data, 'admin')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
@@ -370,6 +369,15 @@ def OptimizeMySQL(request):
|
|||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
|
def UpgradeMySQL(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
dm = DatabaseManager()
|
||||||
|
return dm.Upgardemysql(request, userID)
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
def getMysqlstatus(request):
|
def getMysqlstatus(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
@@ -461,3 +469,34 @@ def applyMySQLChanges(request):
|
|||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
|
||||||
|
def upgrademysqlnow(request):
|
||||||
|
try:
|
||||||
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||||
|
logging.writeToFile("----------------------habbi")
|
||||||
|
userID = request.session['userID']
|
||||||
|
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
|
||||||
|
if currentACL['admin'] == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson('FilemanagerAdmin', 0)
|
||||||
|
|
||||||
|
data = json.loads(request.body)
|
||||||
|
version =data['mysqlversion']
|
||||||
|
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
execPath = f"/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/mysqlUtilities.py UpgradeMariaDB --version {version} --tempStatusPath {tempStatusPath}"
|
||||||
|
ProcessUtilities.popenExecutioner(execPath)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'error_message': "None",
|
||||||
|
'tempStatusPath': tempStatusPath}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
|
|||||||
Reference in New Issue
Block a user