From 4873b5487815ea84510de89d6496bc885c883caf Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 19 Aug 2020 15:40:39 -0400 Subject: [PATCH] Moved post_install to after install, and created pre-remove script --- pluginInstaller/pluginInstaller.py | 43 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/pluginInstaller/pluginInstaller.py b/pluginInstaller/pluginInstaller.py index 67d0891e6..3093aa21c 100755 --- a/pluginInstaller/pluginInstaller.py +++ b/pluginInstaller/pluginInstaller.py @@ -104,7 +104,7 @@ class pluginInstaller: os.chdir(currentDir) @staticmethod - def preScript(pluginName): + def preInstallScript(pluginName): pluginHome = '/usr/local/CyberCP/' + pluginName if os.path.exists(pluginHome + '/pre_install'): @@ -115,7 +115,7 @@ class pluginInstaller: subprocess.call(shlex.split(command)) @staticmethod - def postScript(pluginName): + def postInstallScript(pluginName): pluginHome = '/usr/local/CyberCP/' + pluginName if os.path.exists(pluginHome + '/post_install'): @@ -125,6 +125,17 @@ class pluginInstaller: command = pluginHome + '/post_install' subprocess.call(shlex.split(command)) + @staticmethod + def preRemoveScript(pluginName): + pluginHome = '/usr/local/CyberCP/' + pluginName + + if os.path.exists(pluginHome + '/pre_remove'): + command = 'chmod +x ' + pluginHome + '/pre_remove' + subprocess.call(shlex.split(command)) + + command = pluginHome + '/pre_remove' + subprocess.call(shlex.split(command)) + @staticmethod def installPlugin(pluginName): @@ -138,22 +149,16 @@ class pluginInstaller: ## pluginInstaller.stdOut('Executing pre_install script..') - pluginInstaller.preScript(pluginName) + pluginInstaller.preInstallScript(pluginName) pluginInstaller.stdOut('pre_install executed.') ## - pluginInstaller.stdOut('Executing post_install script..') - pluginInstaller.postScript(pluginName) - pluginInstaller.stdOut('post_install executed.') - - ## - pluginInstaller.stdOut('Restoring settings file.') pluginInstaller.upgradingSettingsFile(pluginName) pluginInstaller.stdOut('Settings file restored.') - ### + ## pluginInstaller.stdOut('Upgrading URLs') pluginInstaller.upgradingURLs(pluginName) @@ -167,16 +172,12 @@ class pluginInstaller: ## - ## - pluginInstaller.stdOut('Adding interface link..') pluginInstaller.addInterfaceLink(pluginName) pluginInstaller.stdOut('Interface link added.') ## - ## - pluginInstaller.stdOut('Upgrading static content..') pluginInstaller.staticContent() pluginInstaller.stdOut('Static content upgraded.') @@ -185,6 +186,14 @@ class pluginInstaller: pluginInstaller.restartGunicorn() + ## + + pluginInstaller.stdOut('Executing post_install script..') + pluginInstaller.postInstallScript(pluginName) + pluginInstaller.stdOut('post_install executed.') + + ## + pluginInstaller.stdOut('Plugin successfully installed.') except BaseException as msg: @@ -247,6 +256,12 @@ class pluginInstaller: try: ## + pluginInstaller.stdOut('Executing pre_remove script..') + pluginInstaller.preRemoveScript(pluginName) + pluginInstaller.stdOut('pre_remove executed.') + + ## + pluginInstaller.stdOut('Removing files..') pluginInstaller.removeFiles(pluginName) pluginInstaller.stdOut('Files removed..')