From efc4fb9cb2608817c8de318a51e2686f8a499cef Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 7 Jun 2024 13:49:59 +0800 Subject: [PATCH] =?UTF-8?q?docker=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/mw.py | 13 +++++++++++++ plugins/mysql/index.py | 19 +++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/class/core/mw.py b/class/core/mw.py index ef0bc89bd..351a2c916 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -199,6 +199,7 @@ def getFileSuffix(file): return ext + def isAppleSystem(): if getOs() == 'darwin': return True @@ -208,6 +209,18 @@ def isDocker(): return os.path.exists('/.dockerenv') +def isSupportSystemctl(): + if isAppleSystem(): + return False + if isDocker(): + return False + + current_os = getOs() + if current_os.startswith("freebsd"): + return False + return True + + def isDebugMode(): if isAppleSystem(): return True diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 31e28988d..a5ebf154c 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -589,23 +589,22 @@ def myOp(version, method): isInited = initMysqlData() if not isInited: - if current_os.startswith("freebsd"): + if not mw.isSupportSystemctl(): mw.execShell('service ' + getPluginName() + ' start') else: mw.execShell('systemctl start mysql') initMysqlPwd() - if current_os.startswith("freebsd"): + if not mw.isSupportSystemctl(): mw.execShell('service ' + getPluginName() + ' stop') else: mw.execShell('systemctl stop mysql') - if current_os.startswith("freebsd"): - data = mw.execShell('service ' + getPluginName() + ' ' + method) - return 'ok' - - mw.execShell('systemctl ' + method + ' mysql') + if not mw.isSupportSystemctl(): + mw.execShell('service ' + getPluginName() + ' ' + method) + else: + mw.execShell('systemctl ' + method + ' mysql') return 'ok' except Exception as e: return str(e) @@ -627,7 +626,7 @@ def my8cmd(version, method): if not isInited: - if mw.isAppleSystem(): + if not mw.isSupportSystemctl(): cmd_init_start = init_file + ' start' subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, bufsize=4096, stderr=subprocess.PIPE) @@ -643,7 +642,7 @@ def my8cmd(version, method): break time.sleep(1) - if mw.isAppleSystem(): + if not mw.isSupportSystemctl(): cmd_init_stop = init_file + ' stop' subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True, bufsize=4096, stderr=subprocess.PIPE) @@ -651,7 +650,7 @@ def my8cmd(version, method): else: mw.execShell('systemctl stop mysql') - if mw.isAppleSystem(): + if not mw.isSupportSystemctl(): sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, bufsize=4096, stderr=subprocess.PIPE) sub.wait(5)