From 3e9b47cbf34614d3d31a8a65cf13dcef7c51f0bd Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 29 Nov 2024 18:23:25 +0800 Subject: [PATCH] Update index.py --- plugins/swap/index.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/swap/index.py b/plugins/swap/index.py index 3fb07947c..db79fa596 100755 --- a/plugins/swap/index.py +++ b/plugins/swap/index.py @@ -79,7 +79,7 @@ def getInitDTpl(): def initDreplace(): file_tpl = getInitDTpl() - service_path = os.path.dirname(os.getcwd()) + service_path = mw.getServerDir() initD_path = getServerDir() + '/init.d' if not os.path.exists(initD_path): @@ -101,12 +101,11 @@ def initDreplace(): if os.path.exists(systemDir) and not os.path.exists(systemService): swapon_bin = mw.execShell('which swapon')[0].strip() swapoff_bin = mw.execShell('which swapoff')[0].strip() - service_path = mw.getServerDir() - se_content = mw.readFile(systemServiceTpl) - se_content = se_content.replace('{$SERVER_PATH}', service_path) - se_content = se_content.replace('{$SWAPON_BIN}', swapon_bin) - se_content = se_content.replace('{$SWAPOFF_BIN}', swapoff_bin) - mw.writeFile(systemService, se_content) + content = mw.readFile(systemServiceTpl) + content = content.replace('{$SERVER_PATH}', service_path) + content = content.replace('{$SWAPON_BIN}', swapon_bin) + content = content.replace('{$SWAPOFF_BIN}', swapoff_bin) + mw.writeFile(systemService, content) mw.execShell('systemctl daemon-reload') return file_bin