From ac285d8829e77ec92c7b5404974a610488fa1eff Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Thu, 11 Jul 2019 18:39:32 +0200 Subject: [PATCH] Properly revert Netdata changes --- wo/cli/plugins/stack.py | 71 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 83cfcf5..40b1b0f 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -1170,6 +1170,40 @@ class WOStackController(CementBaseController): "update -n --no-dev -d " "/var/www/22222/htdocs/db/pma/") + # netdata install + if any('/var/lib/wo/tmp/kickstart.sh' == x[1] + for x in packages): + if ((not os.path.exists('/opt/netdata')) and + (not os.path.exists('/etc/netdata'))): + Log.info(self, "Installing Netdata, please wait...") + WOShellExec.cmd_exec(self, "bash /var/lib/wo/tmp/" + "kickstart.sh " + "--dont-wait") + # disable mail notifications + WOFileUtils.searchreplace(self, "/opt/netdata/usr/" + "lib/netdata/conf.d/" + "health_alarm_notify.conf", + 'SEND_EMAIL="YES"', + 'SEND_EMAIL="NO"') + # check if mysql credentials are available + if os.path.isfile('/etc/mysql/conf.d/my.cnf'): + try: + WOMysql.execute(self, + "create user " + "'netdata'@'localhost';", + log=False) + WOMysql.execute(self, + "grant usage on *.* to " + "'netdata'@'localhost';", + log=False) + WOMysql.execute(self, + "flush privileges;", + log=False) + except CommandExecutionError as e: + Log.info( + self, "fail to setup mysql user for netdata") + WOService.restart_service(self, 'netdata') + # WordOps Dashboard if any('/var/lib/wo/tmp/wo-dashboard.tar.gz' == x[1] for x in packages): @@ -1695,43 +1729,6 @@ class WOStackController(CementBaseController): "allkeys-lru/' " "/etc/redis/redis.conf") WOService.restart_service(self, 'redis-server') - - if 'Netdata' in packages: - if ((not os.path.exists('/opt/netdata')) and - (not os.path.exists('/etc/netdata'))): - if os.path.isfile("/var/lib/wo/tmp/kickstart.sh"): - Log.info(self, "Installing Netdata, please wait...") - WOShellExec.cmd_exec(self, "bash /var/lib/wo/tmp/" - "kickstart.sh " - "--dont-wait") - - # disable mail notifications - WOFileUtils.searchreplace(self, "/opt/netdata/usr/" - "lib/netdata/conf.d/" - "health_alarm_notify.conf", - 'SEND_EMAIL="YES"', - 'SEND_EMAIL="NO"') - - # check if mysql credentials are available - if os.path.isfile('/etc/mysql/conf.d/my.cnf'): - try: - WOMysql.execute(self, - "create user " - "'netdata'@'localhost';", - log=False) - WOMysql.execute(self, - "grant usage on *.* to " - "'netdata'@'localhost';", - log=False) - WOMysql.execute(self, - "flush privileges;", - log=False) - except CommandExecutionError as e: - Log.info( - self, "fail to setup mysql user " - "for netdata") - WOService.restart_service(self, 'netdata') - if disp_msg: if (self.msg): for msg in self.msg: