mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-09 23:06:16 +01:00
Internal Upgrade
Trying to add internal Upgrade of CyberPanel
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{% extends "baseTemplate/index.html" %}
|
{% extends "baseTemplate/index.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block title %}{% trans "Version Management - CyberPanel" %}"{% endblock %}
|
{% block title %}{% trans "Version Management - CyberPanel" %}*{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
@@ -16,72 +16,65 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
CyberPanel
|
CyberPanel
|
||||||
</h3>
|
</h3>
|
||||||
<div ng-controller="versionManagment" class="example-box-wrapper">
|
<div ng-controller="versionManagment" class="example-box-wrapper">
|
||||||
|
<form action="{% url 'upgrade_cyberpanel' %}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
<form action="/" class="form-horizontal bordered-row">
|
<button type="submit">Upgrade CyberPanel</button>
|
||||||
<div class="form-group">
|
</form>
|
||||||
|
<div ng-hide="upgradelogBox" class="form-group">
|
||||||
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Current Version:" %}  </label>
|
<div class="col-sm-12">
|
||||||
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ currentVersion }} </div>
|
<textarea ng-model="upgradeLog" rows="30" class="form-control">{{ logs }}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="panel">
|
||||||
|
<div class panel-body>
|
||||||
|
<h3 class="title-hero">
|
||||||
|
CyberPanel
|
||||||
|
</h3>
|
||||||
|
<div ng-controller="versionManagment" class="example-box-wrapper">
|
||||||
|
<form action="/" class="form-horizontal bordered-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Current Version:" %}  </label>
|
||||||
|
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ currentVersion }} </div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Build:" %}  </label>
|
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Build:" %}  </label>
|
||||||
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ build }} </div>
|
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ build }} </div>
|
||||||
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Current Commit:" %}  </label>
|
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Current Commit:" %}  </label>
|
||||||
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ Currentcomt }} </div>
|
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ Currentcomt }} </div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Version:" %}  </label>
|
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Version:" %}  </label>
|
||||||
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestVersion }} </div>
|
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestVersion }} </div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Build:" %}  </label>
|
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Build:" %}  </label>
|
||||||
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestBuild }} </div>
|
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestBuild }} </div>
|
||||||
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Commit:" %}  </label>
|
<label class="col-sm-3 control-label " style="margin: 0px!important; padding: 0px!important;">{% trans "Latest Commit:" %}  </label>
|
||||||
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestcomit }} </div>
|
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ latestcomit }} </div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-hide="upgradelogBox" class="form-group">
|
<div ng-hide="upgradelogBox" class="form-group">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<textarea ng-model="upgradeLog" rows="30" class="form-control">{{ logs }}</textarea>
|
<textarea ng-model="upgradeLog" rows="30" class="form-control">{{ logs }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ from django.conf.urls import url
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.renderBase, name='index'),
|
path('', views.renderBase, name='index'),
|
||||||
url(r'^getSystemStatus$',views.getSystemStatus, name='getSystemInformation'),
|
path('getSystemStatus', views.getSystemStatus, name='getSystemInformation'),
|
||||||
url(r'^getAdminStatus',views.getAdminStatus, name='getSystemInformation'),
|
path('getAdminStatus', views.getAdminStatus, name='getSystemInformation'),
|
||||||
url(r'^getLoadAverage',views.getLoadAverage, name='getLoadAverage'),
|
path('getLoadAverage', views.getLoadAverage, name='getLoadAverage'),
|
||||||
url(r'^versionManagment',views.versionManagment, name='versionManagment'),
|
path('versionManagment', views.versionManagement, name='versionManagement'),
|
||||||
url(r'^design', views.design, name='design'),
|
path('design', views.design, name='design'),
|
||||||
url(r'^getthemedata', views.getthemedata, name='getthemedata'),
|
path('getthemedata', views.getthemedata, name='getthemedata'),
|
||||||
|
|
||||||
#url(r'^upgrade',views.upgrade, name='upgrade'),
|
# Add this URL pattern for 'upgrade_cyberpanel'
|
||||||
|
path('upgrade_cyberpanel', views.upgrade_cyberpanel, name='upgrade_cyberpanel'),
|
||||||
url(r'^UpgradeStatus',views.upgradeStatus, name='UpgradeStatus'),
|
|
||||||
url(r'^upgradeVersion',views.upgradeVersion, name='upgradeVersion'),
|
|
||||||
|
|
||||||
|
path('UpgradeStatus', views.upgradeStatus, name='UpgradeStatus'),
|
||||||
|
path('upgradeVersion', views.upgradeVersion, name='upgradeVersion'),
|
||||||
]
|
]
|
||||||
@@ -1,27 +1,23 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
from plogical.getSystemInformation import SystemInformation
|
|
||||||
import json
|
|
||||||
from loginSystem.views import loadLoginPage
|
|
||||||
from .models import version
|
from .models import version
|
||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
import plogical.CyberCPLogFileWriter as logging
|
import json
|
||||||
from plogical.acl import ACLManager
|
from .plogical.getSystemInformation import SystemInformation
|
||||||
|
from .plogical.CyberCPLogFileWriter as logging
|
||||||
|
from .plogical.acl import ACLManager
|
||||||
from manageServices.models import PDNSStatus
|
from manageServices.models import PDNSStatus
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from .plogical.processUtilities import ProcessUtilities
|
||||||
from plogical.httpProc import httpProc
|
from .plogical.httpProc import httpProc
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
|
||||||
VERSION = '2.3'
|
VERSION = '2.3'
|
||||||
BUILD = 4
|
BUILD = 4
|
||||||
|
|
||||||
|
|
||||||
@ensure_csrf_cookie
|
@ensure_csrf_cookie
|
||||||
def renderBase(request):
|
def renderBase(request):
|
||||||
template = 'baseTemplate/homePage.html'
|
template = 'baseTemplate/homePage.html'
|
||||||
@@ -31,13 +27,59 @@ def renderBase(request):
|
|||||||
proc = httpProc(request, template, finaData)
|
proc = httpProc(request, template, finaData)
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
@ensure_csrf_cookie
|
||||||
|
def versionManagement(request):
|
||||||
|
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
||||||
|
latest = getVersion.json()
|
||||||
|
latestVersion = latest['version']
|
||||||
|
latestBuild = latest['build']
|
||||||
|
|
||||||
|
currentVersion = VERSION
|
||||||
|
currentBuild = str(BUILD)
|
||||||
|
|
||||||
|
u = "https://api.github.com/repos/usmannasir/cyberpanel/commits?sha=v%s.%s" % (latestVersion, latestBuild)
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(u)
|
||||||
|
r = requests.get(u)
|
||||||
|
latestcomit = r.json()[0]['sha']
|
||||||
|
|
||||||
|
command = "git -C /usr/local/CyberCP/ rev-parse HEAD"
|
||||||
|
output = ProcessUtilities.outputExecutioner(command)
|
||||||
|
|
||||||
|
Currentcomt = output.rstrip("\n")
|
||||||
|
notechk = True
|
||||||
|
|
||||||
|
if Currentcomt == latestcomit:
|
||||||
|
notechk = False
|
||||||
|
|
||||||
|
template = 'baseTemplate/versionManagment.html'
|
||||||
|
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
||||||
|
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt, "Notecheck": notechk}
|
||||||
|
|
||||||
|
proc = httpProc(request, template, finalData, 'versionManagement')
|
||||||
|
return proc.render()
|
||||||
|
|
||||||
|
@ensure_csrf_cookie
|
||||||
|
def upgrade_cyberpanel(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
try:
|
||||||
|
upgrade_command = 'sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)'
|
||||||
|
result = subprocess.run(upgrade_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
|
|
||||||
|
if result.returncode == 0:
|
||||||
|
response_data = {'success': True, 'message': 'CyberPanel upgrade completed successfully.'}
|
||||||
|
else:
|
||||||
|
response_data = {'success': False, 'message': 'CyberPanel upgrade failed. Error output: ' + result.stderr}
|
||||||
|
except Exception as e:
|
||||||
|
response_data = {'success': False, 'message': 'An error occurred during the upgrade: ' + str(e)}
|
||||||
|
|
||||||
|
return JsonResponse(response_data)
|
||||||
|
|
||||||
|
@ensure_csrf_cookie
|
||||||
def getAdminStatus(request):
|
def getAdminStatus(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
currentACL = ACLManager.loadedACL(val)
|
currentACL = ACLManager.loadedACL(val)
|
||||||
|
|
||||||
|
|
||||||
if os.path.exists('/home/cyberpanel/postfix'):
|
if os.path.exists('/home/cyberpanel/postfix'):
|
||||||
currentACL['emailAsWhole'] = 1
|
currentACL['emailAsWhole'] = 1
|
||||||
else:
|
else:
|
||||||
@@ -68,7 +110,6 @@ def getAdminStatus(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Can not get admin Status")
|
return HttpResponse("Can not get admin Status")
|
||||||
|
|
||||||
|
|
||||||
def getSystemStatus(request):
|
def getSystemStatus(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -79,7 +120,6 @@ def getSystemStatus(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Can not get admin Status")
|
return HttpResponse("Can not get admin Status")
|
||||||
|
|
||||||
|
|
||||||
def getLoadAverage(request):
|
def getLoadAverage(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -95,53 +135,7 @@ def getLoadAverage(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return HttpResponse("Not allowed.")
|
return HttpResponse("Not allowed.")
|
||||||
|
|
||||||
|
|
||||||
@ensure_csrf_cookie
|
@ensure_csrf_cookie
|
||||||
def versionManagment(request):
|
|
||||||
## Get latest version
|
|
||||||
|
|
||||||
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
|
||||||
latest = getVersion.json()
|
|
||||||
latestVersion = latest['version']
|
|
||||||
latestBuild = latest['build']
|
|
||||||
|
|
||||||
## Get local version
|
|
||||||
|
|
||||||
currentVersion = VERSION
|
|
||||||
currentBuild = str(BUILD)
|
|
||||||
|
|
||||||
u = "https://api.github.com/repos/usmannasir/cyberpanel/commits?sha=v%s.%s" % (latestVersion, latestBuild)
|
|
||||||
logging.CyberCPLogFileWriter.writeToFile(u)
|
|
||||||
r = requests.get(u)
|
|
||||||
latestcomit = r.json()[0]['sha']
|
|
||||||
|
|
||||||
command ="git -C /usr/local/CyberCP/ rev-parse HEAD"
|
|
||||||
output = ProcessUtilities.outputExecutioner(command)
|
|
||||||
|
|
||||||
Currentcomt = output.rstrip("\n")
|
|
||||||
notechk = True
|
|
||||||
|
|
||||||
# command ="git fetch -C /usr/local/CyberCP/"
|
|
||||||
# output = ProcessUtilities.outputExecutioner(command)
|
|
||||||
#
|
|
||||||
# command ="git -C /usr/local/CyberCP/ log %s..%s --pretty=oneline | wc -l" % ( Currentcomt, latestcomit)
|
|
||||||
# output = ProcessUtilities.outputExecutioner(command)
|
|
||||||
#
|
|
||||||
# numCommits = output.rstrip("\n")
|
|
||||||
|
|
||||||
if(Currentcomt == latestcomit):
|
|
||||||
notechk = False
|
|
||||||
|
|
||||||
|
|
||||||
template = 'baseTemplate/versionManagment.html'
|
|
||||||
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
|
||||||
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt, "Notecheck" : notechk }
|
|
||||||
|
|
||||||
|
|
||||||
proc = httpProc(request, template, finalData, 'versionManagement')
|
|
||||||
return proc.render()
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade(request):
|
def upgrade(request):
|
||||||
try:
|
try:
|
||||||
admin = request.session['userID']
|
admin = request.session['userID']
|
||||||
@@ -152,38 +146,28 @@ def upgrade(request):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
command = 'wget http://cyberpanel.net/upgrade.py'
|
command = 'wget http://cyberpanel.net/upgrade.py'
|
||||||
|
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
|
|
||||||
res = subprocess.call(cmd)
|
res = subprocess.call(cmd)
|
||||||
|
|
||||||
vers = version.objects.get(pk=1)
|
vers = version.objects.get(pk=1)
|
||||||
|
|
||||||
from upgrade import Upgrade
|
from upgrade import Upgrade
|
||||||
|
|
||||||
Upgrade.initiateUpgrade(vers.currentVersion, vers.build)
|
Upgrade.initiateUpgrade(vers.currentVersion, vers.build)
|
||||||
|
|
||||||
adminData = {"upgrade": 1}
|
adminData = {"upgrade": 1}
|
||||||
|
|
||||||
json_data = json.dumps(adminData)
|
json_data = json.dumps(adminData)
|
||||||
|
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
adminData = {"upgrade": 1, "error_message": "Please login or refresh this page."}
|
adminData = {"upgrade": 1, "error_message": "Please login or refresh this page."}
|
||||||
json_data = json.dumps(adminData)
|
json_data = json.dumps(adminData)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
@ensure_csrf_cookie
|
||||||
def upgradeStatus(request):
|
def upgradeStatus(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
try:
|
try:
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
||||||
path = "/usr/local/lscp/logs/upgradeLog"
|
path = "/usr/local/lscp/logs/upgradeLog"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
upgradeLog = open(path, "r").read()
|
upgradeLog = open(path, "r").read()
|
||||||
except:
|
except:
|
||||||
@@ -193,16 +177,13 @@ def upgradeStatus(request):
|
|||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
if upgradeLog.find("Upgrade Completed") > -1:
|
if upgradeLog.find("Upgrade Completed") > -1:
|
||||||
|
|
||||||
vers = version.objects.get(pk=1)
|
vers = version.objects.get(pk=1)
|
||||||
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
||||||
latest = getVersion.json()
|
latest = getVersion.json()
|
||||||
vers.currentVersion = latest['version']
|
vers.currentVersion = latest['version']
|
||||||
vers.build = latest['build']
|
vers.build = latest['build']
|
||||||
vers.save()
|
vers.save()
|
||||||
|
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
final_json = json.dumps({'finished': 1, 'upgradeStatus': 1,
|
final_json = json.dumps({'finished': 1, 'upgradeStatus': 1,
|
||||||
'error_message': "None",
|
'error_message': "None",
|
||||||
'upgradeLog': upgradeLog})
|
'upgradeLog': upgradeLog})
|
||||||
@@ -212,8 +193,6 @@ def upgradeStatus(request):
|
|||||||
'error_message': "None",
|
'error_message': "None",
|
||||||
'upgradeLog': upgradeLog})
|
'upgradeLog': upgradeLog})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
final_dic = {'upgradeStatus': 0, 'error_message': str(msg)}
|
final_dic = {'upgradeStatus': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
@@ -223,7 +202,6 @@ def upgradeStatus(request):
|
|||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
def upgradeVersion(request):
|
def upgradeVersion(request):
|
||||||
try:
|
try:
|
||||||
vers = version.objects.get(pk=1)
|
vers = version.objects.get(pk=1)
|
||||||
@@ -237,10 +215,8 @@ def upgradeVersion(request):
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
return HttpResponse(str(msg))
|
return HttpResponse(str(msg))
|
||||||
|
|
||||||
|
|
||||||
@ensure_csrf_cookie
|
@ensure_csrf_cookie
|
||||||
def design(request):
|
def design(request):
|
||||||
### Load Custom CSS
|
|
||||||
try:
|
try:
|
||||||
from baseTemplate.models import CyberPanelCosmetic
|
from baseTemplate.models import CyberPanelCosmetic
|
||||||
cosmetic = CyberPanelCosmetic.objects.get(pk=1)
|
cosmetic = CyberPanelCosmetic.objects.get(pk=1)
|
||||||
@@ -264,12 +240,8 @@ def design(request):
|
|||||||
cosmetic.save()
|
cosmetic.save()
|
||||||
finalData['saved'] = 1
|
finalData['saved'] = 1
|
||||||
|
|
||||||
####### Fetch sha...
|
|
||||||
|
|
||||||
sha_url = "https://api.github.com/repos/usmannasir/CyberPanel-Themes/commits"
|
sha_url = "https://api.github.com/repos/usmannasir/CyberPanel-Themes/commits"
|
||||||
|
|
||||||
sha_res = requests.get(sha_url)
|
sha_res = requests.get(sha_url)
|
||||||
|
|
||||||
sha = sha_res.json()[0]['sha']
|
sha = sha_res.json()[0]['sha']
|
||||||
|
|
||||||
l = "https://api.github.com/repos/usmannasir/CyberPanel-Themes/git/trees/%s" % sha
|
l = "https://api.github.com/repos/usmannasir/CyberPanel-Themes/git/trees/%s" % sha
|
||||||
@@ -286,7 +258,6 @@ def design(request):
|
|||||||
proc = httpProc(request, template, finalData, 'versionManagement')
|
proc = httpProc(request, template, finalData, 'versionManagement')
|
||||||
return proc.render()
|
return proc.render()
|
||||||
|
|
||||||
|
|
||||||
def getthemedata(request):
|
def getthemedata(request):
|
||||||
try:
|
try:
|
||||||
val = request.session['userID']
|
val = request.session['userID']
|
||||||
@@ -298,12 +269,9 @@ def getthemedata(request):
|
|||||||
else:
|
else:
|
||||||
return ACLManager.loadErrorJson('reboot', 0)
|
return ACLManager.loadErrorJson('reboot', 0)
|
||||||
|
|
||||||
#logging.CyberCPLogFileWriter.writeToFile(str(data) + " [themedata]")
|
|
||||||
|
|
||||||
url = "https://raw.githubusercontent.com/usmannasir/CyberPanel-Themes/main/%s/design.css" % data['Themename']
|
url = "https://raw.githubusercontent.com/usmannasir/CyberPanel-Themes/main/%s/design.css" % data['Themename']
|
||||||
|
|
||||||
res = requests.get(url)
|
res = requests.get(url)
|
||||||
|
|
||||||
rsult = res.text
|
rsult = res.text
|
||||||
final_dic = {'status': 1, 'csscontent': rsult}
|
final_dic = {'status': 1, 'csscontent': rsult}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
@@ -312,4 +280,3 @@ def getthemedata(request):
|
|||||||
final_dic = {'status': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user