mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
enable pluginInstaller to run migrations
This commit is contained in:
@@ -22,6 +22,11 @@ class pluginInstaller:
|
|||||||
print(("[" + time.strftime(
|
print(("[" + time.strftime(
|
||||||
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n"))
|
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def migrationsEnabled(pluginName: str) -> bool:
|
||||||
|
pluginHome = '/usr/local/CyberCP/' + pluginName
|
||||||
|
return os.path.exists(pluginHome + '/enable_migrations')
|
||||||
|
|
||||||
### Functions Related to plugin installation.
|
### Functions Related to plugin installation.
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -103,6 +108,17 @@ class pluginInstaller:
|
|||||||
|
|
||||||
os.chdir(currentDir)
|
os.chdir(currentDir)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def installMigrations(pluginName):
|
||||||
|
currentDir = os.getcwd()
|
||||||
|
os.chdir('/usr/local/CyberCP')
|
||||||
|
command = "/usr/local/CyberCP/bin/python manage.py makemigrations %s" % pluginName
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
command = "/usr/local/CyberCP/bin/python manage.py migrate %s" % pluginName
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
os.chdir(currentDir)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def preInstallScript(pluginName):
|
def preInstallScript(pluginName):
|
||||||
pluginHome = '/usr/local/CyberCP/' + pluginName
|
pluginHome = '/usr/local/CyberCP/' + pluginName
|
||||||
@@ -184,6 +200,15 @@ class pluginInstaller:
|
|||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
|
if pluginInstaller.migrationsEnabled(pluginName):
|
||||||
|
pluginInstaller.stdOut('Running Migrations..')
|
||||||
|
pluginInstaller.installMigrations(pluginName)
|
||||||
|
pluginInstaller.stdOut('Migrations Completed..')
|
||||||
|
else:
|
||||||
|
pluginInstaller.stdOut('Migrations not enabled, add file \'enable_migrations\' to plugin to enable')
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
pluginInstaller.restartGunicorn()
|
pluginInstaller.restartGunicorn()
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -251,6 +276,14 @@ class pluginInstaller:
|
|||||||
writeToFile.writelines(items)
|
writeToFile.writelines(items)
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def removeMigrations(pluginName):
|
||||||
|
currentDir = os.getcwd()
|
||||||
|
os.chdir('/usr/local/CyberCP')
|
||||||
|
command = "/usr/local/CyberCP/bin/python manage.py migrate %s zero" % pluginName
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
os.chdir(currentDir)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def removePlugin(pluginName):
|
def removePlugin(pluginName):
|
||||||
try:
|
try:
|
||||||
@@ -262,6 +295,15 @@ class pluginInstaller:
|
|||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
|
if pluginInstaller.migrationsEnabled(pluginName):
|
||||||
|
pluginInstaller.stdOut('Removing migrations..')
|
||||||
|
pluginInstaller.removeMigrations(pluginName)
|
||||||
|
pluginInstaller.stdOut('Migrations removed..')
|
||||||
|
else:
|
||||||
|
pluginInstaller.stdOut('Migrations not enabled, add file \'enable_migrations\' to plugin to enable')
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
pluginInstaller.stdOut('Removing files..')
|
pluginInstaller.stdOut('Removing files..')
|
||||||
pluginInstaller.removeFiles(pluginName)
|
pluginInstaller.removeFiles(pluginName)
|
||||||
pluginInstaller.stdOut('Files removed..')
|
pluginInstaller.stdOut('Files removed..')
|
||||||
|
|||||||
Reference in New Issue
Block a user