From a34bea53de2620ec3283c59729c37712b783897c Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 15:37:14 +0800 Subject: [PATCH 01/69] Update install.sh --- plugins/php/versions/74/install.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 00bb529ed..53f103872 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -22,6 +22,7 @@ mkdir -p $serverPath/php cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then @@ -61,6 +62,13 @@ fi echo "$sourcePath/php/php${PHP_VER}" +ZIP_OPTION='--with-zip' +libzip_version=`pkg-config libzip --modversion` +if [ "$libzip_version" -lt "0.10.1" ];then + ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" +fi + + if [ ! -d $serverPath/php/${PHP_VER} ];then cd $sourcePath/php/php${PHP_VER} && make clean ./buildconf --force @@ -72,7 +80,7 @@ if [ ! -d $serverPath/php/${PHP_VER} ];then --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir=$serverPath/lib/zlib \ - --with-zip \ + $ZIP_OPTION \ --enable-ftp \ --enable-mbstring \ --enable-sockets \ From 6a14554ee9177daff28998cec0763d2ffed9af5b Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 15:38:12 +0800 Subject: [PATCH 02/69] Update install.sh --- plugins/php/versions/74/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 53f103872..50457749f 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -64,7 +64,7 @@ echo "$sourcePath/php/php${PHP_VER}" ZIP_OPTION='--with-zip' libzip_version=`pkg-config libzip --modversion` -if [ "$libzip_version" -lt "0.10.1" ];then +if [ "$libzip_version" -le "0.10.1" ];then ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" fi From 9d20ed1c3e1dcfb7563dd8dd003d4e79760dcc1a Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 15:38:55 +0800 Subject: [PATCH 03/69] Update install.sh --- plugins/php/versions/74/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 50457749f..13c7863fb 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -64,7 +64,7 @@ echo "$sourcePath/php/php${PHP_VER}" ZIP_OPTION='--with-zip' libzip_version=`pkg-config libzip --modversion` -if [ "$libzip_version" -le "0.10.1" ];then +if [ "$libzip_version" -lt "0.11" ];then ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" fi From ac547e4b88e449728263f25f19230af0089e2df9 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 15:50:20 +0800 Subject: [PATCH 04/69] Update install.sh --- plugins/php/versions/74/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 13c7863fb..755a47670 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -64,7 +64,9 @@ echo "$sourcePath/php/php${PHP_VER}" ZIP_OPTION='--with-zip' libzip_version=`pkg-config libzip --modversion` -if [ "$libzip_version" -lt "0.11" ];then + + +if [ `echo "$libzip_version < 0.11"|bc` -eq 1 ];then ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" fi From d73ebac7583db78fbf619e924175085d169f0a96 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 15:56:52 +0800 Subject: [PATCH 05/69] Update install.sh --- plugins/php/versions/74/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 755a47670..932a2d965 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -66,7 +66,7 @@ ZIP_OPTION='--with-zip' libzip_version=`pkg-config libzip --modversion` -if [ `echo "$libzip_version < 0.11"|bc` -eq 1 ];then +if [ `echo "$libzip_version >= 0.11"|bc` -eq 1 ];then ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" fi From d71f9b11ba14980671b8d66f90005211a11e3c66 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 16:15:16 +0800 Subject: [PATCH 06/69] Update install.sh --- plugins/php/versions/74/install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 932a2d965..da851c24a 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -64,9 +64,8 @@ echo "$sourcePath/php/php${PHP_VER}" ZIP_OPTION='--with-zip' libzip_version=`pkg-config libzip --modversion` - - -if [ `echo "$libzip_version >= 0.11"|bc` -eq 1 ];then +compare_ver=`echo "${libzip_version} >= 0.11"|bc` +if [ "$compare_ver" -eq "1" ];then ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" fi From 8698c1d49e6bd3e4b1990178fd4c76facdf2116b Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 17:24:36 +0800 Subject: [PATCH 07/69] =?UTF-8?q?=E5=85=B3=E9=97=ADssl=E5=92=8C=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/templates/default/config.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/route/templates/default/config.html b/route/templates/default/config.html index 5f7e5d7aa..8ada07c7a 100755 --- a/route/templates/default/config.html +++ b/route/templates/default/config.html @@ -26,6 +26,7 @@ +
@@ -60,11 +62,14 @@ 修改 面板管理入口,设置后只能通过指定安全入口登录面板,如: /abc

+ +

默认建站目录 From 9fa5b312a8b01f6720e5d12d68462e8f294faf58 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 17:50:11 +0800 Subject: [PATCH 08/69] =?UTF-8?q?libzip=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/php/versions/73/install.sh | 10 ++++++++++ plugins/php/versions/74/install.sh | 13 ++++++++----- plugins/php/versions/80/install.sh | 14 +++++++++++++- plugins/php/versions/81/install.sh | 14 +++++++++++++- plugins/php/versions/82/install.sh | 15 ++++++++++++++- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/plugins/php/versions/73/install.sh b/plugins/php/versions/73/install.sh index d330efe35..ac95a3175 100755 --- a/plugins/php/versions/73/install.sh +++ b/plugins/php/versions/73/install.sh @@ -10,6 +10,10 @@ sourcePath=${serverPath}/source sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl +function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; } +function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } version=7.3.33 PHP_VER=73 @@ -49,6 +53,12 @@ if [ "$IS_64BIT" == "64" ];then OPTIONS="${OPTIONS} --with-libdir=lib64" fi +ZIP_OPTION='--enable-zip' +libzip_version=`pkg-config libzip --modversion` +if version_lt "$libzip_version" "0.11.0" ;then + export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig + ZIP_OPTION="--with-libzip=$serverPath/lib/libzip" +fi if [ ! -d $serverPath/php/73 ];then cd $sourcePath/php/php${PHP_VER} && ./configure \ diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index da851c24a..9e93d2370 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -11,6 +11,11 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl +function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; } +function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } + version=7.4.26 PHP_VER=74 Install_php() @@ -50,9 +55,7 @@ if [ $sysName == 'Darwin' ]; then export LDFLAGS="-L/usr/local/opt/libxml2/lib" else OPTIONS='--without-iconv' - # OPTIONS="--with-iconv=${serverPath}/lib/libiconv" OPTIONS="${OPTIONS} --with-curl" - # OPTIONS="${OPTIONS} --with-zip=${serverPath}/lib/libzip" fi IS_64BIT=`getconf LONG_BIT` @@ -64,9 +67,9 @@ echo "$sourcePath/php/php${PHP_VER}" ZIP_OPTION='--with-zip' libzip_version=`pkg-config libzip --modversion` -compare_ver=`echo "${libzip_version} >= 0.11"|bc` -if [ "$compare_ver" -eq "1" ];then - ZIP_OPTION="--with-zip=${serverPath}/lib/libzip" +if version_lt "$libzip_version" "0.11.0" ;then + export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig + ZIP_OPTION="--with-zip=$serverPath/lib/libzip" fi diff --git a/plugins/php/versions/80/install.sh b/plugins/php/versions/80/install.sh index 300b3654a..3d075717b 100755 --- a/plugins/php/versions/80/install.sh +++ b/plugins/php/versions/80/install.sh @@ -10,6 +10,11 @@ sourcePath=${serverPath}/source sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl +function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; } +function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } + version=8.0.21 PHP_VER=80 @@ -55,6 +60,13 @@ if [ "$IS_64BIT" == "64" ];then OPTIONS="${OPTIONS} --with-libdir=lib64" fi +ZIP_OPTION='--with-zip' +libzip_version=`pkg-config libzip --modversion` +if version_lt "$libzip_version" "0.11.0" ;then + export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig + ZIP_OPTION="--with-zip=$serverPath/lib/libzip" +fi + echo "$sourcePath/php/php${PHP_VER}" if [ ! -d $serverPath/php/${PHP_VER} ];then @@ -68,7 +80,7 @@ if [ ! -d $serverPath/php/${PHP_VER} ];then --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir=$serverPath/lib/zlib \ - --with-zip \ + $ZIP_OPTION \ --enable-ftp \ --enable-mbstring \ --enable-sockets \ diff --git a/plugins/php/versions/81/install.sh b/plugins/php/versions/81/install.sh index f677d84f0..0316cc29b 100755 --- a/plugins/php/versions/81/install.sh +++ b/plugins/php/versions/81/install.sh @@ -10,6 +10,11 @@ sourcePath=${serverPath}/source sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl +function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; } +function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } + version=8.1.8 PHP_VER=81 @@ -49,6 +54,13 @@ else OPTIONS="${OPTIONS} --with-curl" fi +ZIP_OPTION='--with-zip' +libzip_version=`pkg-config libzip --modversion` +if version_lt "$libzip_version" "0.11.0" ;then + export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig + ZIP_OPTION="--with-zip=$serverPath/lib/libzip" +fi + echo "$sourcePath/php/php${PHP_VER}" @@ -63,7 +75,7 @@ if [ ! -d $serverPath/php/${PHP_VER} ];then --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir=$serverPath/lib/zlib \ - --with-zip \ + $ZIP_OPTION \ --enable-ftp \ --enable-mbstring \ --enable-sockets \ diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index 33d3c6fad..c18779c45 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -10,6 +10,11 @@ sourcePath=${serverPath}/source sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl +function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; } +function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } + version=8.2.0alpha2 PHP_VER=82 @@ -50,6 +55,14 @@ if [ "$IS_64BIT" == "64" ];then OPTIONS="${OPTIONS} --with-libdir=lib64" fi +ZIP_OPTION='--with-zip' +libzip_version=`pkg-config libzip --modversion` +if version_lt "$libzip_version" "0.11.0" ;then + export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig + ZIP_OPTION="--with-zip=$serverPath/lib/libzip" +fi + + echo "$sourcePath/php/php${PHP_VER}" if [ ! -d $serverPath/php/${PHP_VER} ];then @@ -63,7 +76,7 @@ if [ ! -d $serverPath/php/${PHP_VER} ];then --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir=$serverPath/lib/zlib \ - --with-zip \ + $ZIP_OPTION \ --enable-mbstring \ --enable-ftp \ --enable-sockets \ From 229a7e1fc4f9c610d5649f15f0fc54905fdebf8b Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 17:51:47 +0800 Subject: [PATCH 09/69] Update install.sh --- plugins/php/versions/73/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/73/install.sh b/plugins/php/versions/73/install.sh index ac95a3175..b213717e0 100755 --- a/plugins/php/versions/73/install.sh +++ b/plugins/php/versions/73/install.sh @@ -70,7 +70,7 @@ if [ ! -d $serverPath/php/73 ];then --with-pdo-mysql=mysqlnd \ --with-zlib-dir=$serverPath/lib/zlib \ --enable-ftp \ - --enable-zip \ + $ZIP_OPTION\ --enable-sockets \ --enable-simplexml \ --enable-mbstring \ From 6d8ecc2e7b0b042bea33499059f4c8b84e63d926 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 17:56:58 +0800 Subject: [PATCH 10/69] =?UTF-8?q?=E6=98=BE=E7=A4=BAphp82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/site_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 8bb906b9a..b7e4bc48d 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2023,7 +2023,7 @@ location ^~ {from} { def getPhpVersion(self): phpVersions = ('00', '52', '53', '54', '55', - '56', '70', '71', '72', '73', '74', '80', '81') + '56', '70', '71', '72', '73', '74', '80', '81', '82') data = [] for val in phpVersions: tmp = {} From 5b5bceaa5443242d9126116da6e1f86973edd476 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 19:14:46 +0800 Subject: [PATCH 11/69] Update site_api.py --- class/core/site_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index b7e4bc48d..7cb37793a 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -390,6 +390,14 @@ class site_api: mpath = vpath + '/' + d + '/info.json' if not os.path.exists(mpath): continue + + # keyPath = self.sslDir + siteName + '/privkey.pem' + # certPath = self.sslDir + siteName + '/fullchain.pem' + + keyPath = vpath + '/' + d + '/privkey.pem' + certPath = vpath + '/' + d + '/fullchain.pem' + self.saveCert(keyPath, certPath) + tmp = mw.readFile(mpath) if not tmp: continue @@ -479,8 +487,8 @@ class site_api: mw.execShell('\\cp -a /tmp/backup2.conf ' + csrpath) return mw.returnJson(False, 'ERROR:
' + isError.replace("\n", '
') + '
') - mw.restartWeb() mw.writeLog('网站管理', '证书已保存!') + mw.restartWeb() return mw.returnJson(True, '证书已保存!') def setCertToSiteApi(self): From 257acb96edf534633cc8006d8883277f97c2a7e9 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 19:23:59 +0800 Subject: [PATCH 12/69] Update xhprof.conf --- plugins/xhprof/conf/xhprof.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/xhprof/conf/xhprof.conf b/plugins/xhprof/conf/xhprof.conf index bdc8095d5..92df8fb24 100755 --- a/plugins/xhprof/conf/xhprof.conf +++ b/plugins/xhprof/conf/xhprof.conf @@ -6,7 +6,7 @@ server root {$SERVER_PATH}/xhprof/xhprof_html; #error_page 404 /404.html; - include enable-php-{$PHP_VER}.conf; + include {$SERVER_PATH}/web_conf/php/conf/enable-php-{$PHP_VER}.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { From 9d8f253d8c7eb1a3eb6f956c403e7201e8389dff Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 19:34:16 +0800 Subject: [PATCH 13/69] Update site_api.py --- class/core/site_api.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 7cb37793a..4447ff656 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -387,16 +387,18 @@ class site_api: os.system('mkdir -p ' + vpath) data = [] for d in os.listdir(vpath): - mpath = vpath + '/' + d + '/info.json' - if not os.path.exists(mpath): - continue # keyPath = self.sslDir + siteName + '/privkey.pem' # certPath = self.sslDir + siteName + '/fullchain.pem' keyPath = vpath + '/' + d + '/privkey.pem' certPath = vpath + '/' + d + '/fullchain.pem' - self.saveCert(keyPath, certPath) + if os.path.exists(keyPath) and os.path.exists(certPath): + self.saveCert(keyPath, certPath) + + mpath = vpath + '/' + d + '/info.json' + if not os.path.exists(mpath): + continue tmp = mw.readFile(mpath) if not tmp: From 79ade86232fdd34aac28a4b76e883d1434e2954d Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 19:57:10 +0800 Subject: [PATCH 14/69] Update site_api.py --- class/core/site_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 4447ff656..0593284d6 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2290,7 +2290,7 @@ location /{ certInfo = self.getCertName(certPath) if not certInfo: return mw.returnData(False, '证书解析失败!') - vpath = self.sslDir + certInfo['subject'] + vpath = self.sslDir + certInfo['subject'].strip() if not os.path.exists(vpath): os.system('mkdir -p ' + vpath) mw.writeFile(vpath + '/privkey.pem', From dd00a99172e52f81a011243ab4e5c5fb92cbe13f Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 20:21:55 +0800 Subject: [PATCH 15/69] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/webstats/js/stats.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/webstats/js/stats.js b/plugins/webstats/js/stats.js index 33b8c71e8..8dcb67931 100644 --- a/plugins/webstats/js/stats.js +++ b/plugins/webstats/js/stats.js @@ -1996,8 +1996,8 @@ function wsTableErrorLogRequest(page){ list += '' + data[i]['ip'] +''; list += '' + toSize(data[i]['body_length']) +''; list += '' + toSecond(data[i]['request_time']) +''; - list += '' + data[i]['uri'] +''; - list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; + list += '' + data[i]['uri'] +''; + list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; list += '详情'; list += ''; } @@ -2205,8 +2205,8 @@ function wsTableLogRequest(page){ list += '' + data[i]['ip'] +''; list += '' + toSize(data[i]['body_length']) +''; list += '' + toSecond(data[i]['request_time']) +''; - list += '' + data[i]['uri'] +''; - list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; + list += '' + data[i]['uri'] +''; + list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; list += '详情'; list += ''; } From d5e992af534de0680fa888b6471f109453726277 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 20:23:06 +0800 Subject: [PATCH 16/69] Update index.py --- plugins/webstats/index.py | 41 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py index fea2ca39d..fd9d4c44a 100755 --- a/plugins/webstats/index.py +++ b/plugins/webstats/index.py @@ -988,29 +988,32 @@ def getIpStatList(): if ip == "127.0.0.1": clist[i]['area'] = "本地" elif geoip_exists: - response = reader.city(ip) - country = response.country.names["zh-CN"] - - # print(ip, response.subdivisions) - _subdivisions = response.subdivisions try: - if len(_subdivisions) < 1: + response = reader.city(ip) + country = response.country.names["zh-CN"] + + # print(ip, response.subdivisions) + _subdivisions = response.subdivisions + try: + if len(_subdivisions) < 1: + subdivisions = "" + else: + subdivisions = "," + response.subdivisions.most_specific.names[ + "zh-CN"] + except Exception as e: subdivisions = "" - else: - subdivisions = "," + response.subdivisions.most_specific.names[ - "zh-CN"] - except Exception as e: - subdivisions = "" - try: - if 'zh-CN' in response.city.names: - city = "," + response.city.names["zh-CN"] - else: - city = "," + response.city.names["en"] - except Exception as e: - city = "" + try: + if 'zh-CN' in response.city.names: + city = "," + response.city.names["zh-CN"] + else: + city = "," + response.city.names["en"] + except Exception as e: + city = "" - clist[i]['area'] = country + subdivisions + city + clist[i]['area'] = country + subdivisions + city + except Exception as e: + clist[i]['area'] = "内网?" return mw.returnJson(True, 'ok', clist) From 760db6672650bf11263a587a669c5465cd9771a9 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 21:28:24 +0800 Subject: [PATCH 17/69] Update orm.py --- class/plugin/orm.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/class/plugin/orm.py b/class/plugin/orm.py index b38e8683a..ab1951bbe 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -18,6 +18,8 @@ class ORM: __DB_CNF = '/etc/my.cnf' __DB_SOCKET = '/www/server/mysql/mysql.sock' + __DB_CHARSET = "utf8" + def __Conn(self): '''连接MYSQL数据库''' try: @@ -25,19 +27,19 @@ class ORM: if os.path.exists(self.__DB_SOCKET): try: self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) + port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET) except Exception as e: self.__DB_HOST = '127.0.0.1' self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) + port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET) else: try: self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1) + port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1) except Exception as e: self.__DB_HOST = '127.0.0.1' self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1) + port=self.__DB_PORT, charset=self.__DB_CHARSET, connect_timeout=1) self.__DB_CUR = self.__DB_CONN.cursor() return True @@ -51,6 +53,9 @@ class ORM: def setSocket(self, sock): self.__DB_SOCKET = sock + def setCharset(self, charset): + self.__DB_CHARSET = charset + def setPort(self, port): self.__DB_PORT = port From 45b755e8d97c842541dc55bfb9117aa76cecefec Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 21:29:47 +0800 Subject: [PATCH 18/69] Update index.py --- plugins/mysql/index.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index d157d5db3..952353b0b 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -137,6 +137,7 @@ def pMysqlDb(): db = mw.getMyORM() db.setPort(getDbPort()) db.setSocket(getSocketFile()) + # db.setCharset("utf8") db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From e8d109b457c8ea4e787e4c34097f2eb6bf349d35 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 21:29:56 +0800 Subject: [PATCH 19/69] up --- plugins/rsyncd/info.json | 2 +- plugins/rsyncd/install.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/rsyncd/info.json b/plugins/rsyncd/info.json index c23d4247b..3ab33843a 100755 --- a/plugins/rsyncd/info.json +++ b/plugins/rsyncd/info.json @@ -5,7 +5,7 @@ "name":"rsyncd", "type":"软件", "ps":"rsyncd同步助手", - "versions":"1.0", + "versions":"2.0", "shell":"install.sh", "checks":"server/rsyncd", "path": "server/rsyncd", diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh index bf574b182..156bd0e84 100755 --- a/plugins/rsyncd/install.sh +++ b/plugins/rsyncd/install.sh @@ -25,14 +25,20 @@ Install_rsyncd() if [ "$OSNAME" == "debian'" ] || [ "$OSNAME" == "ubuntu'" ];then apt install -y rsync + apt install -y lsyncd elif [[ "$OSNAME" == "arch" ]]; then echo y | pacman -Sy rsync + echo y | pacman -Sy lsyncd + elif [[ "$OSNAME" == "macos" ]]; then + brew install rsync + brew install lsyncd else yum install -y rsync + yum install -y lsyncd fi - echo '1.0' > $serverPath/rsyncd/version.pl + echo '2.0' > $serverPath/rsyncd/version.pl echo '安装完成' > $install_tmp cd ${rootPath} && python3 ${rootPath}/plugins/rsyncd/index.py start cd ${rootPath} && python3 ${rootPath}/plugins/rsyncd/index.py initd_install @@ -51,6 +57,7 @@ Uninstall_rsyncd() if [ -f $serverPath/rsyncd/initd/rsyncd ];then $serverPath/rsyncd/initd/rsyncd stop fi + rm -rf $serverPath/rsyncd echo "卸载完成" > $install_tmp } From 1152fdb08fedecbf78e4851c43fb7e6293a7d9fe Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 21:33:58 +0800 Subject: [PATCH 20/69] Update orm.py --- class/plugin/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/plugin/orm.py b/class/plugin/orm.py index ab1951bbe..37088a663 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -18,7 +18,7 @@ class ORM: __DB_CNF = '/etc/my.cnf' __DB_SOCKET = '/www/server/mysql/mysql.sock' - __DB_CHARSET = "utf8" + __DB_CHARSET = "utf-8" def __Conn(self): '''连接MYSQL数据库''' From 4c3aa3b91d55c6a12d2ded0beb57af7e2aa52323 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 21:54:48 +0800 Subject: [PATCH 21/69] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mysql/versions/5.5/install.sh | 4 ++-- plugins/mysql/versions/5.6/install.sh | 4 ++-- plugins/mysql/versions/5.7/install.sh | 4 ++-- plugins/mysql/versions/8.0/install.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/mysql/versions/5.5/install.sh b/plugins/mysql/versions/5.5/install.sh index 83d2fa7bb..34db9a680 100755 --- a/plugins/mysql/versions/5.5/install.sh +++ b/plugins/mysql/versions/5.5/install.sh @@ -54,8 +54,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8mb4 \ - -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DDEFAULT_CHARSET=utf8 \ + -DDEFAULT_COLLATION=utf8_general_ci \ -DCMAKE_C_COMPILER=/usr/bin/gcc \ -DCMAKE_CXX_COMPILER=/usr/bin/g++ make && make install && make clean diff --git a/plugins/mysql/versions/5.6/install.sh b/plugins/mysql/versions/5.6/install.sh index cd3cdd9d3..2a3f3ba66 100755 --- a/plugins/mysql/versions/5.6/install.sh +++ b/plugins/mysql/versions/5.6/install.sh @@ -68,8 +68,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8mb4 \ - -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DDEFAULT_CHARSET=utf8 \ + -DDEFAULT_COLLATION=utf8_general_ci \ $OPTIONS \ -DCMAKE_C_COMPILER=/usr/bin/gcc \ -DCMAKE_CXX_COMPILER=/usr/bin/g++ diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 85629889e..9d87b30de 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -83,8 +83,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8mb4 \ - -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DDEFAULT_CHARSET=utf8 \ + -DDEFAULT_COLLATION=utf8_general_ci \ -DDOWNLOAD_BOOST=1 \ $OPTIONS \ -DCMAKE_C_COMPILER=/usr/bin/gcc \ diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index acd58a003..a1d26f366 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -142,8 +142,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8mb4 \ - -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DDEFAULT_CHARSET=utf8 \ + -DDEFAULT_COLLATION=utf8_general_ci \ -DDOWNLOAD_BOOST=1 \ -DFORCE_INSOURCE_BUILD=1 \ $OPTIONS \ From 9d374a72d8b6a54d6ee6d06b7f034e7390aebec9 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 21:59:35 +0800 Subject: [PATCH 22/69] Update orm.py --- class/plugin/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/plugin/orm.py b/class/plugin/orm.py index 37088a663..ab1951bbe 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -18,7 +18,7 @@ class ORM: __DB_CNF = '/etc/my.cnf' __DB_SOCKET = '/www/server/mysql/mysql.sock' - __DB_CHARSET = "utf-8" + __DB_CHARSET = "utf8" def __Conn(self): '''连接MYSQL数据库''' From c7c8ac4347cdfa774ee0458a2c46c7d810f34a5f Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 22:32:26 +0800 Subject: [PATCH 23/69] up --- .gitignore | 2 ++ plugins/mysql/conf/my.cnf | 1 + plugins/mysql/conf/my5.7.cnf | 1 + plugins/mysql/conf/my8.0.cnf | 2 ++ 4 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 777de65c3..145ee9cdf 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,7 @@ data/ipv6.pl data/restart.pl data/ssl.pl data/edate.pl +data/osname.pl plugins/l2tp plugins/openlitespeed @@ -146,3 +147,4 @@ plugins/mtproxy debug.out + diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my.cnf index c699ed3e3..369e55b28 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my.cnf @@ -35,6 +35,7 @@ open_files_limit = 65535 #skip-external-locking #loose-skip-innodb #skip-grant-tables +skip-ssl log-bin=mysql-bin diff --git a/plugins/mysql/conf/my5.7.cnf b/plugins/mysql/conf/my5.7.cnf index b0a71d37f..5053013b6 100644 --- a/plugins/mysql/conf/my5.7.cnf +++ b/plugins/mysql/conf/my5.7.cnf @@ -37,6 +37,7 @@ max_allowed_packet = 128M #loose-skip-innodb #skip-networking #skip-name-resolve +skip-ssl log-bin=mysql-bin binlog_format=mixed diff --git a/plugins/mysql/conf/my8.0.cnf b/plugins/mysql/conf/my8.0.cnf index 7e390ce92..e1e82a44a 100644 --- a/plugins/mysql/conf/my8.0.cnf +++ b/plugins/mysql/conf/my8.0.cnf @@ -38,6 +38,8 @@ max_allowed_packet = 128M #loose-skip-innodb #skip-networking #skip-name-resolve +skip-ssl + log-bin=mysql-bin binlog_format=mixed From 10386170288289638cd01152bbd595b4df31fe58 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 22:32:33 +0800 Subject: [PATCH 24/69] Update install.sh --- plugins/mysql/versions/5.6/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/versions/5.6/install.sh b/plugins/mysql/versions/5.6/install.sh index 2a3f3ba66..cd3cdd9d3 100755 --- a/plugins/mysql/versions/5.6/install.sh +++ b/plugins/mysql/versions/5.6/install.sh @@ -68,8 +68,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ $OPTIONS \ -DCMAKE_C_COMPILER=/usr/bin/gcc \ -DCMAKE_CXX_COMPILER=/usr/bin/g++ From 999a6113438c868661a77ca8307a291128379380 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 22:37:13 +0800 Subject: [PATCH 25/69] up --- plugins/rsyncd/init.d/lsyncd.service.tpl | 70 +++++++++++++++ plugins/rsyncd/init.d/lsyncd.tpl | 108 +++++++++++++++++++++++ plugins/rsyncd/install.sh | 2 +- 3 files changed, 179 insertions(+), 1 deletion(-) create mode 100755 plugins/rsyncd/init.d/lsyncd.service.tpl create mode 100755 plugins/rsyncd/init.d/lsyncd.tpl diff --git a/plugins/rsyncd/init.d/lsyncd.service.tpl b/plugins/rsyncd/init.d/lsyncd.service.tpl new file mode 100755 index 000000000..2ee441060 --- /dev/null +++ b/plugins/rsyncd/init.d/lsyncd.service.tpl @@ -0,0 +1,70 @@ +#!/bin/sh +# chkconfig: 2345 55 25 +# description: rsyncd Service + +### BEGIN INIT INFO +# Provides: rsyncd +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts rsyncd +# Description: starts the rsyncd +### END INIT INFO + +ROOT_PATH={$SERVER_PATH} + +p_start(){ + isStart=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}') + if [ "$isStart" == '' ];then + echo -e "Starting rsync... \c" + if [ -f /var/run/rsyncd.pid ]; then + rm -rf /var/run/rsyncd.pid + fi + /usr/bin/rsync --daemon --config=/etc/rsyncd.conf + sleep 0.3 + isStart=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}') + if [ "$isStart" == '' ];then + echo -e "\033[31mError: rsyncd service startup failed.\033[0m" + return; + fi + echo -e "\033[32mdone\033[0m" + else + echo "Starting rsyncd(pid $isStart) already running" + fi +} + +p_stop(){ + echo -e "Stopping rsyncd... \c"; + pids=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}') + arr=($pids) + + for p in ${arr[@]} + do + kill -9 $p + done + + if [ -f /var/run/rsyncd.pid ]; then + rm -rf /var/run/rsyncd.pid + fi + echo -e "\033[32mdone\033[0m" +} + + +case "$1" in + start) + p_start + ;; + stop) + p_stop + ;; + restart|reload) + p_stop + sleep 0.3 + p_start + ;; + *) + echo "Please use start or stop as first argument" + ;; +esac + diff --git a/plugins/rsyncd/init.d/lsyncd.tpl b/plugins/rsyncd/init.d/lsyncd.tpl new file mode 100755 index 000000000..b7d9e2880 --- /dev/null +++ b/plugins/rsyncd/init.d/lsyncd.tpl @@ -0,0 +1,108 @@ +#!/bin/bash +# +# chkconfig: - 85 15 +# description: Lightweight inotify based sync daemon +# +# processname: lsyncd +# config: /etc/lsyncd.conf +# config: /etc/sysconfig/lsyncd +# pidfile: /var/run/lsyncd.pid +# Source function library + +if [ -f /etc/init.d/functions ];then + . /etc/init.d/functions +fi + +if [ -f /lib/lsb/init-functions ];then + . /lib/lsb/init-functions +fi + +# Source networking configuration. +if [ -f /etc/sysconfig/network ];then + . /etc/sysconfig/network +fi + +LSYNCD_OPTIONS="-pidfile /var/run/lsyncd.pid /etc/lsyncd.conf" +if [ -e /etc/sysconfig/lsyncd ]; then + . /etc/sysconfig/lsyncd +fi +RETVAL=0 +prog="lsyncd" +thelock=/var/lock/subsys/lsyncd +LSYNCD_USER=root + +start() { + [ -f /etc/lsyncd.conf ] || exit 6 + echo -n $"Starting $prog: " + if [ $UID -ne 0 ]; then + RETVAL=1 + failure + else + nohup /usr/bin/lsyncd $LSYNCD_OPTIONS > /dev/null & + RETVAL=$? + [ $RETVAL -eq 0 ] && touch $thelock + fi; + echo + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + if [ $UID -ne 0 ]; then + RETVAL=1 + failure + else + killproc lsyncd + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $thelock + fi; + echo + return $RETVAL +} + +reload(){ + echo -n $"Reloading $prog: " + killproc lsyncd -HUP + RETVAL=$? + echo + return $RETVAL +} + +restart(){ + stop + start +} + +condrestart(){ + [ -e $thelock ] && restart + return 0 +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + + restart) + restart + ;; + reload) + reload + ;; + condrestart) + condrestart + ;; + + status) + status lsyncd + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" + RETVAL=1 +esac + +exit $RETVAL diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh index 156bd0e84..561e5b714 100755 --- a/plugins/rsyncd/install.sh +++ b/plugins/rsyncd/install.sh @@ -14,9 +14,9 @@ sysName=`uname` # bash /www/server/mdsever-web/scripts/getos.sh bash ${rootPath}/scripts/getos.sh OSNAME=`cat ${rootPath}/data/osname.pl` -VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +echo $OSNAME install_tmp=${rootPath}/tmp/mw_install.pl Install_rsyncd() { From 27a9c9cef058e8e8dbf422974ef682cbe6fbfacb Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 22:58:12 +0800 Subject: [PATCH 26/69] try mysqlclient --- class/core/mw.py | 10 ++++ class/plugin/ormDb.py | 109 +++++++++++++++++++++++++++++++++++++++++ plugins/mysql/index.py | 6 ++- 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100755 class/plugin/ormDb.py diff --git a/class/core/mw.py b/class/core/mw.py index 6a0aa9413..a6f7fb857 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -1022,3 +1022,13 @@ def getMyORM(): import orm o = orm.ORM() return o + + +def getMyORMDb(): + ''' + 获取MySQL资源的ORM pip install mysqlclient==2.0.3 | pip install mysql-python + ''' + sys.path.append(os.getcwd() + "/class/plugin") + import ormDb + o = ormDb.ORM() + return o diff --git a/class/plugin/ormDb.py b/class/plugin/ormDb.py new file mode 100755 index 000000000..f747c651d --- /dev/null +++ b/class/plugin/ormDb.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +import re +import os +import sys + + +class ORM: + __DB_PASS = None + __DB_USER = 'root' + __DB_PORT = 3306 + __DB_HOST = 'localhost' + __DB_CONN = None + __DB_CUR = None + __DB_ERR = None + __DB_CNF = '/etc/my.cnf' + + __DB_SOCKET = '/www/server/mysql/mysql.sock' + __DB_CHARSET = 'utf8' + + def __Conn(self): + '''连接MYSQL数据库''' + try: + + try: + import MySQLdb + except Exception as ex: + self.__DB_ERR = ex + return False + + # print(self.__DB_HOST) + # print(self.__DB_USER) + # print(self.__DB_PASS) + # print(self.__DB_PORT) + # print(self.__DB_CHARSET) + # print(self.__DB_SOCKET) + if os.path.exists(self.__DB_SOCKET): + try: + self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET) + except Exception as e: + print(e) + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1, unix_socket=self.__DB_SOCKET) + else: + try: + self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1) + + self.__DB_CUR = self.__DB_CONN.cursor() + + return True + except MySQLdb.Error as e: + self.__DB_ERR = e + return False + + def setDbConf(self, conf): + self.__DB_CNF = conf + + def setSocket(self, sock): + self.__DB_SOCKET = sock + + def setCharset(self, charset): + self.__DB_CHARSET = charset + + def setPort(self, port): + self.__DB_PORT = port + + def setPwd(self, pwd): + self.__DB_PASS = pwd + + def getPwd(self): + return self.__DB_PASS + + def execute(self, sql): + # 执行SQL语句返回受影响行 + if not self.__Conn(): + return self.__DB_ERR + try: + result = self.__DB_CUR.execute(sql) + self.__DB_CONN.commit() + self.__Close() + return result + except Exception as ex: + return ex + + def query(self, sql): + # 执行SQL语句返回数据集 + if not self.__Conn(): + return self.__DB_ERR + try: + self.__DB_CUR.execute(sql) + result = self.__DB_CUR.fetchall() + # 将元组转换成列表 + data = map(list, result) + self.__Close() + return data + except Exception as ex: + return ex + + # 关闭连接 + def __Close(self): + self.__DB_CUR.close() + self.__DB_CONN.close() diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 952353b0b..00e9f4b0c 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -134,7 +134,11 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - db = mw.getMyORM() + # mysql.connector + # db = mw.getMyORM() + # MySQLdb | + db = mw.getMyORMDb() + db.setPort(getDbPort()) db.setSocket(getSocketFile()) # db.setCharset("utf8") From 7c06dab3cbda54403117d358b031b8b1be40be20 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 23:01:54 +0800 Subject: [PATCH 27/69] =?UTF-8?q?python=20mysql.connnector=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=BF=87=E7=A8=8B=E5=87=BA=E7=8E=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E3=80=82=E8=BF=98=E6=98=AF=E5=85=88=E4=BD=BF=E7=94=A8mysqlclie?= =?UTF-8?q?nt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit python mysql connector Character set 'utf8' unsupported --- scripts/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 19e558357..6535b65aa 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -115,7 +115,7 @@ pip3 install gevent-websocket==0.10.1 pip3 install flask-caching==1.10.1 pip3 install flask-session==0.3.2 pip3 install flask-socketio==5.2.0 -# pip3 install mysqlclient +pip3 install mysqlclient if [ ! -f /www/server/mdserver-web/bin/activate ];then @@ -133,5 +133,5 @@ pip3 install gevent-websocket==0.10.1 pip3 install flask-caching==1.10.1 pip3 install flask-session==0.3.2 pip3 install flask-socketio==5.2.0 -# pip3 install mysqlclient +pip3 install mysqlclient From c757bc5eacf831627d57682a5da4645b068520fe Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 23:03:26 +0800 Subject: [PATCH 28/69] go on --- plugins/mariadb/index.py | 6 ++++-- plugins/mysql-yum/index.py | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 964519e2f..e8cba8947 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -144,10 +144,12 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - db = mw.getMyORM() + # mysql.connector + # db = mw.getMyORM() + # MySQLdb | + db = mw.getMyORMDb() db.setDbConf(getConf()) - db.setPort(getDbPort()) db.setSocket(getSocketFile()) diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index d1fc6dea1..02a970347 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -132,7 +132,12 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - db = mw.getMyORM() + # mysql.connector + # db = mw.getMyORM() + # MySQLdb | + db = mw.getMyORMDb() + + # db = mw.getMyORM() db.__DB_CNF = getConf() db.setPort(getDbPort()) db.setSocket(getSocketFile()) From f56f4dbb88ce6ac5658a34e0aec646cd513d0a66 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 27 Jul 2022 23:04:29 +0800 Subject: [PATCH 29/69] =?UTF-8?q?=E9=80=80=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mysql/versions/5.5/install.sh | 4 ++-- plugins/mysql/versions/5.7/install.sh | 4 ++-- plugins/mysql/versions/8.0/install.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/mysql/versions/5.5/install.sh b/plugins/mysql/versions/5.5/install.sh index 34db9a680..83d2fa7bb 100755 --- a/plugins/mysql/versions/5.5/install.sh +++ b/plugins/mysql/versions/5.5/install.sh @@ -54,8 +54,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DCMAKE_C_COMPILER=/usr/bin/gcc \ -DCMAKE_CXX_COMPILER=/usr/bin/g++ make && make install && make clean diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 9d87b30de..85629889e 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -83,8 +83,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DDOWNLOAD_BOOST=1 \ $OPTIONS \ -DCMAKE_C_COMPILER=/usr/bin/gcc \ diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index a1d26f366..acd58a003 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -142,8 +142,8 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DDOWNLOAD_BOOST=1 \ -DFORCE_INSOURCE_BUILD=1 \ $OPTIONS \ From 6c497734c719a3b3f5a6dc2b0b98a9c23dec7ba2 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 11:36:23 +0800 Subject: [PATCH 30/69] up --- plugins/rsyncd/conf/rsyncd.conf | 3 +-- plugins/rsyncd/index.html | 1 - plugins/rsyncd/index.py | 37 +++++++++++++++------------------ plugins/rsyncd/install.sh | 4 +++- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/plugins/rsyncd/conf/rsyncd.conf b/plugins/rsyncd/conf/rsyncd.conf index f880ee235..43d17f270 100644 --- a/plugins/rsyncd/conf/rsyncd.conf +++ b/plugins/rsyncd/conf/rsyncd.conf @@ -5,5 +5,4 @@ max connections = 100 log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid list = false -hosts allow = * -secrets file = /etc/rsyncd.passwd \ No newline at end of file +hosts allow = * \ No newline at end of file diff --git a/plugins/rsyncd/index.html b/plugins/rsyncd/index.html index be8c4a452..8c97902cb 100755 --- a/plugins/rsyncd/index.html +++ b/plugins/rsyncd/index.html @@ -4,7 +4,6 @@

服务

自启动

配置修改

-

密钥配置

接收配置

日志

说明

diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py index d5be125c5..fdbb0c033 100755 --- a/plugins/rsyncd/index.py +++ b/plugins/rsyncd/index.py @@ -81,10 +81,11 @@ def appConf(): # return '/etc/rsyncd.conf' -def appConfPwd(): - # if mw.isAppleSystem(): - return getServerDir() + '/rsyncd.passwd' - # return '/etc/rsyncd.passwd' +def appAuthPwd(name): + nameDir = getServerDir() + '/secrets/' + name + if not os.path.exists(nameDir): + mw.execShell("mkdir -p " + nameDir) + return nameDir + '/auth.db' def getLog(): @@ -106,12 +107,6 @@ def initDreplace(): content = mw.readFile(conf_tpl_path) mw.writeFile(conf_path, content) - # pwd - confpwd_path = appConfPwd() - if not os.path.exists(confpwd_path): - mw.writeFile(confpwd_path, '') - mw.execShell('chmod 0600 ' + confpwd_path) - initD_path = getServerDir() + '/init.d' if not os.path.exists(initD_path): os.mkdir(initD_path) @@ -132,7 +127,7 @@ def initDreplace(): if os.path.exists(systemDir) and not os.path.exists(systemService): rsync_bin = mw.execShell('which rsync')[0].strip() if rsync_bin == '': - print('rsync缺失!') + print('rsync missing!') exit(0) service_path = mw.getServerDir() @@ -211,6 +206,7 @@ def getRecListData(): content = mw.readFile(path) flist = re.findall("\[(.*)\]", content) + flist_len = len(flist) ret_list = [] for i in range(flist_len): @@ -226,11 +222,12 @@ def getRecListData(): t1 = re.search(reg, content, re.S) if t1: args = t1.groups()[0] - # print 'args start', args, 'args_end' - t2 = re.findall('\s*(.*)\s*=\s*(.*)', args, re.M) + # print('args start', args, 'args_end') + t2 = re.findall('\s*(.*)\s*\=\s*?(.*)?', args, re.M | re.I) for i in range(len(t2)): - tmp[t2[i][0].strip()] = t2[i][1] + tmp[t2[i][0].strip()] = t2[i][1].strip() ret_list.append(tmp) + return ret_list @@ -262,10 +259,10 @@ def addRec(): args_path = args['path'] args_ps = args['ps'] - pwd_path = appConfPwd() - pwd_content = mw.readFile(pwd_path) - pwd_content += args_name + ':' + args_pwd + "\n" - mw.writeFile(pwd_path, pwd_content) + auth_path = appAuthPwd(args_name) + pwd_content = args_name + ':' + args_pwd + "\n" + mw.writeFile(auth_path, pwd_content) + mw.execShell("chmod 600 " + auth_path) path = appConf() content = mw.readFile(path) @@ -274,6 +271,8 @@ def addRec(): con += 'path = ' + args_path + "\n" con += 'comment = ' + args_ps + "\n" con += 'auth users = ' + args_name + "\n" + con += 'ignore errors' + "\n" + con += 'secrets file = ' + auth_path + "\n" con += 'read only = false' content = content + con @@ -359,8 +358,6 @@ if __name__ == "__main__": print(initdUinstall()) elif func == 'conf': print(appConf()) - elif func == 'conf_pwd': - print(appConfPwd()) elif func == 'run_log': print(getLog()) elif func == 'rec_list': diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh index 561e5b714..f3d18b296 100755 --- a/plugins/rsyncd/install.sh +++ b/plugins/rsyncd/install.sh @@ -21,7 +21,7 @@ install_tmp=${rootPath}/tmp/mw_install.pl Install_rsyncd() { echo '正在安装脚本文件...' > $install_tmp - mkdir -p $serverPath/rsyncd + if [ "$OSNAME" == "debian'" ] || [ "$OSNAME" == "ubuntu'" ];then apt install -y rsync @@ -37,6 +37,8 @@ Install_rsyncd() yum install -y lsyncd fi + mkdir -p $serverPath/rsyncd + mkdir -p $serverPath/rsyncd/secrets echo '2.0' > $serverPath/rsyncd/version.pl echo '安装完成' > $install_tmp From e839bf4f8ade5c64bd52a2c5af45b70c27f3841e Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 12:20:12 +0800 Subject: [PATCH 31/69] up --- plugins/rsyncd/index.html | 1 - plugins/rsyncd/js/rsyncd.js | 23 +++++++++++++++++++ route/static/app/public.js | 44 +++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/plugins/rsyncd/index.html b/plugins/rsyncd/index.html index 8c97902cb..01c22f35e 100755 --- a/plugins/rsyncd/index.html +++ b/plugins/rsyncd/index.html @@ -3,7 +3,6 @@

服务

自启动

-

配置修改

接收配置

日志

说明

diff --git a/plugins/rsyncd/js/rsyncd.js b/plugins/rsyncd/js/rsyncd.js index ae8d2d9a8..b2635e42d 100755 --- a/plugins/rsyncd/js/rsyncd.js +++ b/plugins/rsyncd/js/rsyncd.js @@ -37,6 +37,23 @@ function rsPost(method,args,callback, title){ } + +function rsyncdConf(){ + rsPost('conf', {}, function(rdata){ + rpath = rdata['data']; + if (rdata['status']){ + onlineEditFile(0, rpath); + } else { + layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']}); + } + }); +} + +function rsyncdLog(){ + pluginStandAloneLogs("rsyncd","","run_log") +} + + function rsyncdReceive(){ rsPost('rec_list', '', function(data){ var rdata = $.parseJSON(data.data); @@ -47,6 +64,12 @@ function rsyncdReceive(){ // console.log(rdata); var list = rdata.data; var con = ''; + + con += '
\ + \ + \ +
'; + con += '
'; con += ''; con += ''; diff --git a/route/static/app/public.js b/route/static/app/public.js index 5e672e8c9..6063fa656 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -2031,6 +2031,50 @@ function pluginRollingLogs(_name, version, func, _args, line){ },1000); },'json'); } + + +function pluginStandAloneLogs(_name, version, func, _args, line){ + if ( typeof(version) == 'undefined' ){ + version = ''; + } + + var func_name = 'error_log'; + if ( typeof(func) != 'undefined' ){ + func_name = func; + } + + var file_line = 100; + if ( typeof(line) != 'undefined' ){ + file_line = line; + } + + + layer.open({ + type: 1, + title: _name + '日志', + area: '640px', + content:'
\ + \ +
' + }); + + $.post('/plugins/run', {name:_name, func:func_name, version:version,args:_args},function (data) { + var fileName = data.data; + $.post('/files/get_last_body', 'path=' + fileName+'&line='+file_line, function(rdata) { + if (!rdata.status){ + return; + } + + if(rdata.data == '') { + rdata.data = '当前没有日志!'; + } + var ebody = ''; + $("#plugins_stand_alone_logs").html(ebody); + var ob = document.getElementById('plugins_stand_alone_logs'); + ob.scrollTop = ob.scrollHeight; + },'json'); + },'json'); +} /*** 其中功能,针对插件通过库使用 end ***/ From 2c7d17f001b831455dbef5b286e733e99aaa6876 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 13:10:01 +0800 Subject: [PATCH 32/69] up --- plugins/rsyncd/conf/lsyncd.conf | 6 ++ plugins/rsyncd/index.html | 4 +- plugins/rsyncd/init.d/lsyncd.service.tpl | 75 +++--------------------- plugins/rsyncd/install.sh | 6 +- plugins/rsyncd/js/rsyncd.js | 51 +++++++++++++++- 5 files changed, 69 insertions(+), 73 deletions(-) create mode 100644 plugins/rsyncd/conf/lsyncd.conf diff --git a/plugins/rsyncd/conf/lsyncd.conf b/plugins/rsyncd/conf/lsyncd.conf new file mode 100644 index 000000000..b2ed2416f --- /dev/null +++ b/plugins/rsyncd/conf/lsyncd.conf @@ -0,0 +1,6 @@ +settings { + logfile = "{$SERVER_PATH}/rsyncd/lsyncd.log", + inotifyMode = "CloseWrite", + maxProcesses = 8, + statusFile = "{$SERVER_PATH}/rsyncd/lsyncd.status" +} \ No newline at end of file diff --git a/plugins/rsyncd/index.html b/plugins/rsyncd/index.html index 01c22f35e..23d878188 100755 --- a/plugins/rsyncd/index.html +++ b/plugins/rsyncd/index.html @@ -3,8 +3,8 @@

服务

自启动

+

发送配置

接收配置

-

日志

说明

@@ -15,7 +15,7 @@ \ No newline at end of file diff --git a/plugins/rsyncd/init.d/lsyncd.service.tpl b/plugins/rsyncd/init.d/lsyncd.service.tpl index 2ee441060..c7daa03d6 100755 --- a/plugins/rsyncd/init.d/lsyncd.service.tpl +++ b/plugins/rsyncd/init.d/lsyncd.service.tpl @@ -1,70 +1,9 @@ -#!/bin/sh -# chkconfig: 2345 55 25 -# description: rsyncd Service +[Unit] +Description=fast remote file copy program daemon +ConditionPathExists={$SERVER_PATH}/rsyncd/rsyncd.conf -### BEGIN INIT INFO -# Provides: rsyncd -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: starts rsyncd -# Description: starts the rsyncd -### END INIT INFO - -ROOT_PATH={$SERVER_PATH} - -p_start(){ - isStart=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}') - if [ "$isStart" == '' ];then - echo -e "Starting rsync... \c" - if [ -f /var/run/rsyncd.pid ]; then - rm -rf /var/run/rsyncd.pid - fi - /usr/bin/rsync --daemon --config=/etc/rsyncd.conf - sleep 0.3 - isStart=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}') - if [ "$isStart" == '' ];then - echo -e "\033[31mError: rsyncd service startup failed.\033[0m" - return; - fi - echo -e "\033[32mdone\033[0m" - else - echo "Starting rsyncd(pid $isStart) already running" - fi -} - -p_stop(){ - echo -e "Stopping rsyncd... \c"; - pids=$(ps -ef | grep rsync | grep 'daemon' | grep -v grep | grep -v python | awk '{print $2}') - arr=($pids) - - for p in ${arr[@]} - do - kill -9 $p - done - - if [ -f /var/run/rsyncd.pid ]; then - rm -rf /var/run/rsyncd.pid - fi - echo -e "\033[32mdone\033[0m" -} - - -case "$1" in - start) - p_start - ;; - stop) - p_stop - ;; - restart|reload) - p_stop - sleep 0.3 - p_start - ;; - *) - echo "Please use start or stop as first argument" - ;; -esac +[Service] +ExecStart={$LSYNC_BIN} --config={$SERVER_PATH}/rsyncd/lsyncd.conf --daemon --no-detach +[Install] +WantedBy=multi-user.target diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh index f3d18b296..5747e8990 100755 --- a/plugins/rsyncd/install.sh +++ b/plugins/rsyncd/install.sh @@ -30,8 +30,9 @@ Install_rsyncd() echo y | pacman -Sy rsync echo y | pacman -Sy lsyncd elif [[ "$OSNAME" == "macos" ]]; then - brew install rsync - brew install lsyncd + # brew install rsync + # brew install lsyncd + echo "ok" else yum install -y rsync yum install -y lsyncd @@ -39,6 +40,7 @@ Install_rsyncd() mkdir -p $serverPath/rsyncd mkdir -p $serverPath/rsyncd/secrets + mkdir -p $serverPath/rsyncd/send echo '2.0' > $serverPath/rsyncd/version.pl echo '安装完成' > $install_tmp diff --git a/plugins/rsyncd/js/rsyncd.js b/plugins/rsyncd/js/rsyncd.js index b2635e42d..04d86cb8d 100755 --- a/plugins/rsyncd/js/rsyncd.js +++ b/plugins/rsyncd/js/rsyncd.js @@ -36,8 +36,57 @@ function rsPost(method,args,callback, title){ },'json'); } +///////////////// ----------------- 发送配置 ---------------- ////////////// + +function rsyncdSend(){ + rsPost('rec_list', '', function(data){ + var rdata = $.parseJSON(data.data); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); + return; + } + // console.log(rdata); + var list = rdata.data; + var con = ''; + + con += '
\ + \ + \ + \ +
'; + + con += '
服务名
'; + con += ''; + con += ''; + con += ''; + con += ''; + con += ''; + con += ''; + + con += ''; + + //编辑 + for (var i = 0; i < list.length; i++) { + con += ''+ + '' + + '' + + '' + + '\ + '; + } + + con += ''; + con += '
服务名路径备注操作(添加)
' + list[i]['name']+'' + list[i]['path']+'' + list[i]['comment']+'\ + 命令\ + | 删除
'; + + $(".soft-man-con").html(con); + }); +} + +///////////////// ----------------- 接收配置 ---------------- ////////////// function rsyncdConf(){ rsPost('conf', {}, function(rdata){ rpath = rdata['data']; @@ -50,7 +99,7 @@ function rsyncdConf(){ } function rsyncdLog(){ - pluginStandAloneLogs("rsyncd","","run_log") + pluginStandAloneLogs("rsyncd","","run_log"); } From 2300efe7483a49cd48af7181cca72581a726c689 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 15:45:00 +0800 Subject: [PATCH 33/69] up --- plugins/rsyncd/index.py | 81 +++++++++++++++++++++--- plugins/rsyncd/init.d/lsyncd.service.tpl | 6 +- plugins/rsyncd/init.d/lsyncd.tpl | 4 +- plugins/rsyncd/install.sh | 2 +- 4 files changed, 79 insertions(+), 14 deletions(-) diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py index fdbb0c033..c0d4949e4 100755 --- a/plugins/rsyncd/index.py +++ b/plugins/rsyncd/index.py @@ -78,11 +78,10 @@ def status(): def appConf(): return getServerDir() + '/rsyncd.conf' - # return '/etc/rsyncd.conf' def appAuthPwd(name): - nameDir = getServerDir() + '/secrets/' + name + nameDir = getServerDir() + '/receive/' + name if not os.path.exists(nameDir): mw.execShell("mkdir -p " + nameDir) return nameDir + '/auth.db' @@ -98,8 +97,17 @@ def getLog(): return tmp.groups()[0] -def initDreplace(): +def getLsyncdLog(): + path = getServerDir() + "/lsyncd.conf" + conf = mw.readFile(path) + rep = 'logfile\s*=\s*\"(.*)\"' + tmp = re.search(rep, conf) + if not tmp: + return '' + return tmp.groups()[0] + +def initDReceive(): # conf conf_path = appConf() conf_tpl_path = getPluginDir() + '/conf/rsyncd.conf' @@ -110,9 +118,10 @@ def initDreplace(): initD_path = getServerDir() + '/init.d' if not os.path.exists(initD_path): os.mkdir(initD_path) - file_bin = initD_path + '/' + getPluginName() + file_bin = initD_path + '/' + getPluginName() file_tpl = getInitDTpl() + # print(file_bin, file_tpl) # initd replace if not os.path.exists(file_bin): content = mw.readFile(file_tpl) @@ -131,10 +140,10 @@ def initDreplace(): exit(0) service_path = mw.getServerDir() - se_content = mw.readFile(systemServiceTpl) - se_content = se_content.replace('{$SERVER_PATH}', service_path) - se_content = se_content.replace('{$RSYNC_BIN}', rsync_bin) - mw.writeFile(systemService, se_content) + se = mw.readFile(systemServiceTpl) + se = se.replace('{$SERVER_PATH}', service_path) + se = se.replace('{$RSYNC_BIN}', rsync_bin) + mw.writeFile(systemService, se) mw.execShell('systemctl daemon-reload') rlog = getLog() @@ -143,6 +152,62 @@ def initDreplace(): return file_bin +def initDSend(): + + service_path = mw.getServerDir() + + conf_path = getServerDir() + '/lsyncd.conf' + conf_tpl_path = getPluginDir() + '/conf/lsyncd.conf' + if not os.path.exists(conf_path): + content = mw.readFile(conf_tpl_path) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(conf_path, content) + + initD_path = getServerDir() + '/init.d' + if not os.path.exists(initD_path): + os.mkdir(initD_path) + + # initd replace + file_bin = initD_path + '/lsyncd' + file_tpl = getPluginDir() + "/init.d/lsyncd.tpl" + if not os.path.exists(file_bin): + content = mw.readFile(file_tpl) + content = contentReplace(content) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + # systemd + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/lsyncd.service' + systemServiceTpl = getPluginDir() + '/init.d/lsyncd.service.tpl' + if os.path.exists(systemDir) and not os.path.exists(systemService): + lsyncd_bin = mw.execShell('which lsyncd')[0].strip() + if lsyncd_bin == '': + print('lsyncd missing!') + exit(0) + + content = mw.readFile(systemServiceTpl) + content = content.replace('{$SERVER_PATH}', service_path) + content = content.replace('{$LSYNCD_BIN}', lsyncd_bin) + mw.writeFile(systemService, content) + mw.execShell('systemctl daemon-reload') + + lslog = getLsyncdLog() + if os.path.exists(lslog): + mw.writeFile(lslog, '') + + return file_bin + + +def initDreplace(): + + initDSend() + + # conf + file_bin = initDReceive() + return file_bin + + def rsyncOp(method): file = initDreplace() if not mw.isAppleSystem(): diff --git a/plugins/rsyncd/init.d/lsyncd.service.tpl b/plugins/rsyncd/init.d/lsyncd.service.tpl index c7daa03d6..680881d7e 100755 --- a/plugins/rsyncd/init.d/lsyncd.service.tpl +++ b/plugins/rsyncd/init.d/lsyncd.service.tpl @@ -1,9 +1,9 @@ [Unit] -Description=fast remote file copy program daemon -ConditionPathExists={$SERVER_PATH}/rsyncd/rsyncd.conf +Description=Lightweight inotify based sync daemon +ConditionPathExists={$SERVER_PATH}/rsyncd/lsyncd.conf [Service] -ExecStart={$LSYNC_BIN} --config={$SERVER_PATH}/rsyncd/lsyncd.conf --daemon --no-detach +ExecStart={$LSYNCD_BIN} -pidfile /var/run/lsyncd.pid {$SERVER_PATH}/rsyncd/lsyncd.conf [Install] WantedBy=multi-user.target diff --git a/plugins/rsyncd/init.d/lsyncd.tpl b/plugins/rsyncd/init.d/lsyncd.tpl index b7d9e2880..a5ccdcad6 100755 --- a/plugins/rsyncd/init.d/lsyncd.tpl +++ b/plugins/rsyncd/init.d/lsyncd.tpl @@ -22,7 +22,7 @@ if [ -f /etc/sysconfig/network ];then . /etc/sysconfig/network fi -LSYNCD_OPTIONS="-pidfile /var/run/lsyncd.pid /etc/lsyncd.conf" +LSYNCD_OPTIONS="-pidfile /var/run/lsyncd.pid {$SERVER_PATH}/rsyncd/lsyncd.conf" if [ -e /etc/sysconfig/lsyncd ]; then . /etc/sysconfig/lsyncd fi @@ -32,7 +32,7 @@ thelock=/var/lock/subsys/lsyncd LSYNCD_USER=root start() { - [ -f /etc/lsyncd.conf ] || exit 6 + [ -f {$SERVER_PATH}/rsyncd/lsyncd.conf ] || exit 6 echo -n $"Starting $prog: " if [ $UID -ne 0 ]; then RETVAL=1 diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh index 5747e8990..cd46f0902 100755 --- a/plugins/rsyncd/install.sh +++ b/plugins/rsyncd/install.sh @@ -39,7 +39,7 @@ Install_rsyncd() fi mkdir -p $serverPath/rsyncd - mkdir -p $serverPath/rsyncd/secrets + mkdir -p $serverPath/rsyncd/receive mkdir -p $serverPath/rsyncd/send echo '2.0' > $serverPath/rsyncd/version.pl From 3b503ae61c89a28fecb988358f3d1ae277b0ee1c Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 16:01:17 +0800 Subject: [PATCH 34/69] up --- plugins/rsyncd/index.py | 5 ++++- plugins/rsyncd/init.d/lsyncd.service.tpl | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py index c0d4949e4..42436a931 100755 --- a/plugins/rsyncd/index.py +++ b/plugins/rsyncd/index.py @@ -176,11 +176,12 @@ def initDSend(): mw.writeFile(file_bin, content) mw.execShell('chmod +x ' + file_bin) + lock_file = getServerDir() + "/installed.pl" # systemd systemDir = mw.systemdCfgDir() systemService = systemDir + '/lsyncd.service' systemServiceTpl = getPluginDir() + '/init.d/lsyncd.service.tpl' - if os.path.exists(systemDir) and not os.path.exists(systemService): + if not os.path.exists(lock_file): lsyncd_bin = mw.execShell('which lsyncd')[0].strip() if lsyncd_bin == '': print('lsyncd missing!') @@ -192,6 +193,8 @@ def initDSend(): mw.writeFile(systemService, content) mw.execShell('systemctl daemon-reload') + mw.writeFile(lock_file, "ok") + lslog = getLsyncdLog() if os.path.exists(lslog): mw.writeFile(lslog, '') diff --git a/plugins/rsyncd/init.d/lsyncd.service.tpl b/plugins/rsyncd/init.d/lsyncd.service.tpl index 680881d7e..7c6a03c60 100755 --- a/plugins/rsyncd/init.d/lsyncd.service.tpl +++ b/plugins/rsyncd/init.d/lsyncd.service.tpl @@ -3,7 +3,8 @@ Description=Lightweight inotify based sync daemon ConditionPathExists={$SERVER_PATH}/rsyncd/lsyncd.conf [Service] -ExecStart={$LSYNCD_BIN} -pidfile /var/run/lsyncd.pid {$SERVER_PATH}/rsyncd/lsyncd.conf +Type=simple +ExecStart={$LSYNCD_BIN} -nodaemon {$SERVER_PATH}/rsyncd/lsyncd.conf [Install] WantedBy=multi-user.target From 9d3185c6fbc875e175cebde13a24f7a2b28504bf Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 23:08:34 +0800 Subject: [PATCH 35/69] rsyncd ip xx1 --- plugins/rsyncd/conf/config.json | 26 +++ plugins/rsyncd/index.py | 204 ++++++++++++++++---- plugins/rsyncd/js/rsyncd.js | 322 +++++++++++++++++++++++++------- 3 files changed, 445 insertions(+), 107 deletions(-) create mode 100644 plugins/rsyncd/conf/config.json diff --git a/plugins/rsyncd/conf/config.json b/plugins/rsyncd/conf/config.json new file mode 100644 index 000000000..2e301d90e --- /dev/null +++ b/plugins/rsyncd/conf/config.json @@ -0,0 +1,26 @@ +{ + "receive":{ + "default":{ + "uid": "root", + "use chroot": "no", + "dont compress": "*.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 *.mp4 *.avi *.swf *.rar", + "hosts allow": "", + "max connections": 200, + "gid": "root", + "timeout": 600, + "pid file": "/var/run/rsyncd.pid", + "log file": "/var/log/rsyncd.log", + "port": 873 + }, + "list":[] + }, + "send":{ + "default":{ + "logfile": "/www/server/rsyncd/lsyncd.log", + "inotifyMode": "CloseWrite", + "maxProcesses": "8", + "statusFile": "/www/server/rsyncd/lsyncd.status" + }, + "list":[] + } +} \ No newline at end of file diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py index 42436a931..993915142 100755 --- a/plugins/rsyncd/index.py +++ b/plugins/rsyncd/index.py @@ -202,12 +202,36 @@ def initDSend(): return file_bin +def getDefaultConf(): + path = getServerDir() + "/config.json" + data = mw.readFile(path) + data = json.loads(data) + return data + + +def setDefaultConf(data): + path = getServerDir() + "/config.json" + mw.writeFile(path, json.dumps(data)) + return True + + +def initConfigJson(): + path = getServerDir() + "/config.json" + tpl = getPluginDir() + "/conf/config.json" + if not os.path.exists(path): + data = mw.readFile(tpl) + data = json.loads(data) + mw.writeFile(path, json.dumps(data)) + + def initDreplace(): initDSend() # conf file_bin = initDReceive() + initConfigJson() + return file_bin @@ -299,23 +323,18 @@ def getRecListData(): return ret_list +def getRecListDataBy(name): + l = getRecListData() + for x in range(len(l)): + if name == l[x]["name"]: + return l[x] + + def getRecList(): ret_list = getRecListData() return mw.returnJson(True, 'ok', ret_list) -def getUPwdList(): - pwd_path = appConfPwd() - pwd_content = mw.readFile(pwd_path) - plist = pwd_content.strip().split('\n') - plist_len = len(plist) - data = {} - for x in range(plist_len): - tmp = plist[x].split(':') - data[tmp[0]] = tmp[1] - return data - - def addRec(): args = getArgs() data = checkArgs(args, ['name', 'path', 'pwd', 'ps']) @@ -327,6 +346,8 @@ def addRec(): args_path = args['path'] args_ps = args['ps'] + delRecBy(args_name) + auth_path = appAuthPwd(args_name) pwd_content = args_name + ':' + args_pwd + "\n" mw.writeFile(auth_path, pwd_content) @@ -343,69 +364,168 @@ def addRec(): con += 'secrets file = ' + auth_path + "\n" con += 'read only = false' - content = content + con + content = content.strip() + "\n" + con mw.writeFile(path, content) return mw.returnJson(True, '添加成功') -def delRec(): +def getRec(): args = getArgs() data = checkArgs(args, ['name']) if not data[0]: return data[1] - args_name = args['name'] - cmd = "sed -i '_bak' '/" + args_name + "/d' " + appConfPwd() - mw.execShell(cmd) + name = args['name'] - try: + if name == "": + tmp = {} + tmp["name"] = "" + tmp["path"] = mw.getWwwDir() + tmp["pwd"] = mw.getRandomString(16) + return mw.returnJson(True, 'OK', tmp) + + data = getRecListDataBy(name) + + content = mw.readFile(data['secrets file']) + pwd = content.strip().split(":") + data['pwd'] = pwd[1] + return mw.returnJson(True, 'OK', data) + +def delRecBy(name): + try: path = appConf() content = mw.readFile(path) - ret_list = getRecListData() - ret_list_len = len(ret_list) + reclist = getRecListData() + ret_list_len = len(reclist) is_end = False next_name = '' for x in range(ret_list_len): - tmp = ret_list[x] - if tmp['name'] == args_name: + tmp = reclist[x] + if tmp['name'] == name: + + secrets_file = tmp['secrets file'] + tp = os.path.dirname(secrets_file) + if os.path.exists(tp): + mw.execShell("rm -rf " + tp) + if x + 1 == ret_list_len: is_end = True else: - next_name = ret_list[x + 1]['name'] + next_name = reclist[x + 1]['name'] reg = '' if is_end: - reg = '\[' + args_name + '\]\s*(.*)' + reg = '\[' + name + '\]\s*(.*)' else: - reg = '\[' + args_name + '\]\s*(.*)\s*\[' + next_name + '\]' + reg = '\[' + name + '\]\s*(.*)\s*\[' + next_name + '\]' conre = re.search(reg, content, re.S) content = content.replace( - "[" + args_name + "]\n" + conre.groups()[0], '') + "[" + name + "]\n" + conre.groups()[0], '') mw.writeFile(path, content) - return mw.returnJson(True, '删除成功!') except Exception as e: - return mw.returnJson(False, '删除失败!') + return False + return True -def cmdRec(): +def delRec(): args = getArgs() data = checkArgs(args, ['name']) if not data[0]: return data[1] + name = args['name'] + ok = delRecBy(name) + if ok: + return mw.returnJson(True, '删除成功!') + return mw.returnJson(False, '删除失败!') + - an = args['name'] - pwd_list = getUPwdList() +def cmdRecSecretKey(): + import base64 + + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + name = args['name'] + info = getRecListDataBy(name) + + m = json.dumps(info) + m = m.encode("utf-8") + m = base64.b64encode(m) + cmd = m.decode("utf-8") + return mw.returnJson(True, 'OK!', cmd) + + +def cmdRecCmd(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + name = args['name'] + info = getRecListDataBy(name) ip = mw.getLocalIp() - cmd = 'echo "' + pwd_list[an] + '" > /tmp/p.pass' + "
" - cmd += 'chmod 600 /tmp/p.pass' + "
" - cmd += 'rsync -arv --password-file=/tmp/p.pass --progress --delete /project ' + \ - an + '@' + ip + '::' + an + content = mw.readFile(info['secrets file']) + pwd = content.strip().split(":") + + tmp_name = '/tmp/' + name + '.pass' + + cmd = 'echo "' + pwd[1] + '" > ' + tmp_name + '
' + cmd += 'chmod 600 ' + tmp_name + '
' + cmd += 'rsync -arv --password-file=' + tmp_name + \ + ' --progress --delete /project ' + name + '@' + ip + '::' + name return mw.returnJson(True, 'OK!', cmd) -# rsyncdReceive + +# ----------------------------- rsyncdSend start ------------------------- + + +def lsyncdListFindIp(slist, ip): + for x in range(len(slist)): + if slist[x]["ip"] == ip: + return (True, x) + return (False, -1) + + +def lsyncdList(): + data = getDefaultConf() + send = data['send'] + return mw.returnJson(True, "设置成功!", send) + + +def lsyncdAdd(): + + args = getArgs() + data = checkArgs(args, ['ip', 'name']) + if not data[0]: + return data[1] + + ip = args['ip'] + path = args['path'] + + info = { + "ip": ip, + "path": path + } + + data = getDefaultConf() + slist = data['send']["list"] + res = lsyncdListFindIp(slist, ip) + if res[0]: + list_index = res[1] + slist[list_index] = info + else: + slist.append(info) + data['send']["list"] = slist + + setDefaultConf(data) + return mw.returnJson(True, "设置成功!") + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -434,7 +554,15 @@ if __name__ == "__main__": print(addRec()) elif func == 'del_rec': print(delRec()) - elif func == 'cmd_rec': - print(cmdRec()) + elif func == 'get_rec': + print(getRec()) + elif func == 'cmd_rec_secret_key': + print(cmdRecSecretKey()) + elif func == 'cmd_rec_cmd': + print(cmdRecCmd()) + elif func == 'lsyncd_list': + print(lsyncdList()) + elif func == 'lsyncd_add': + print(lsyncdAdd()) else: print('error') diff --git a/plugins/rsyncd/js/rsyncd.js b/plugins/rsyncd/js/rsyncd.js index 04d86cb8d..0f83aa026 100755 --- a/plugins/rsyncd/js/rsyncd.js +++ b/plugins/rsyncd/js/rsyncd.js @@ -38,42 +38,204 @@ function rsPost(method,args,callback, title){ ///////////////// ----------------- 发送配置 ---------------- ////////////// +function createSendTask(){ + + layer.open({ + type: 1, + area: ['600px','500px'], + title: "创建发送任务", + closeBtn: 1, + shift: 0, + shadeClose: false, + btn: ['提交','取消'], + content:"
\ +
\ + 服务器IP\ +
\ + \ +
\ +
\ +
\ + 同步目录\ +
\ + \ + ?\ +
\ +
\ +
\ + 同步方式\ +
\ + \ + ?\ + 同步周期\ + \ +
\ +
\ + \ + \ +
\ + 限速\ +
\ + KB\ + ?\ + 延迟 秒\ + ?\ +
\ +
\ +
\ + 连接方式\ +
\ + \ + 压缩传输\ + \ + ?\ +
\ +
\ +
\ + 接收密钥\ +
\ + \ +
\ +
\ +
\ + 用户名\ +
\ + \ +
\ +
\ +
\ + 密码\ +
\ + \ +
\ +
\ +
\ + 端口\ +
\ + \ +
\ +
\ +
    \ +
\ +
", + success:function(){ + $('[data-toggle="tooltip"]').tooltip(); + + $(".conn-user").hide(); + $("select[name='conn_type']").change(function(){ + if($(this).val() == 'key'){ + $(".conn-user").hide(); + $(".conn-key").show(); + }else{ + $(".conn-user").show(); + $(".conn-key").hide(); + } + }); + }, + yes:function(){ + var args = {}; + args['ip'] = $('input[name="ip"]').val(); + args['path'] = $('input[name="path"]').val(); + args['delete'] = $('input[name="delete"]').val(); + args['realtime'] = $('input[name="realtime"]').val(); + + args['bwlimit'] = $('input[name="bwlimit"]').val(); + args['conn_type'] = $('input[name="conn_type"]').val(); + args['compress'] = $('input[name="compress"]').val(); + + + console.log(args); + rsPost('lsyncd_add', args, function(rdata){ + console.log(rdata); + }); + return false; + } + }); +} + function rsyncdSend(){ - rsPost('rec_list', '', function(data){ + rsPost('lsyncd_list', '', function(data){ var rdata = $.parseJSON(data.data); + console.log(rdata); if (!rdata.status){ layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); return; } - // console.log(rdata); - var list = rdata.data; + var list = rdata.data.list; var con = ''; con += '
\ - \ + \ \ \
'; con += '
'; con += ''; - con += ''; - con += ''; - con += ''; - con += ''; + con += ''; + con += ''; + con += ''; + con += ''; + con += ''; + con += ''; con += ''; con += ''; - //编辑 for (var i = 0; i < list.length; i++) { con += ''+ - '' + - '' + - '' + + '' + + '' + + '' + + '' + + '' + '\ + 同步\ + | 日志\ + | 过滤器\ + | 编辑\ + | 删除\ + \ '; } @@ -136,7 +298,9 @@ function rsyncdReceive(){ '' + '' + '\ '; } @@ -148,61 +312,67 @@ function rsyncdReceive(){ }); } -function addReceive(){ - var loadOpen = layer.open({ - type: 1, - title: '创建接收', - area: '400px', - content:"
\ -
\ - 项目名\ -
\ - \ + +function addReceive(name = ""){ + rsPost('get_rec',{"name":name},function(rdata) { + var rdata = $.parseJSON(rdata.data); + var data = rdata.data; + + var readonly = ""; + if (name !=""){ + readonly = 'readonly="readonly"' + } + + var loadOpen = layer.open({ + type: 1, + title: '创建接收', + area: '400px', + btn:['确认','取消'], + content:"
\ +
\ + 项目名\ +
\ + \ +
\
\ -
\ -
\ - 密钥\ -
\ - \ - \ +
\ + 密钥\ +
\ + \ + \ +
\
\ -
\ -
\ - 同步到\ -
\ - \ - \ +
\ + 同步到\ +
\ + \ + \ +
\
\ -
\ -
\ - 备注\ -
\ - \ +
\ + 备注\ +
\ + \ +
\
\ -
\ -
\ - \ -
\ -
", - success:function(layero, index){ - repeatPwd(16); - } - }); - - $('#add_ok').click(function(){ - _data = {}; - _data['name'] = $('#name').val(); - _data['pwd'] = $('#MyPassword').val(); - _data['path'] = $('#inputPath').val(); - _data['ps'] = $('#ps').val(); - var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); - rsPost('add_rec', _data, function(data){ - var rdata = $.parseJSON(data.data); - layer.close(loadOpen); - layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); - setTimeout(function(){rsyncdReceive();},2000); +
", + success:function(layero, index){}, + yes:function(){ + var args = {}; + args['name'] = $('#name').val(); + args['pwd'] = $('#MyPassword').val(); + args['path'] = $('#inputPath').val(); + args['ps'] = $('#ps').val(); + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + rsPost('add_rec', args, function(data){ + var rdata = $.parseJSON(data.data); + layer.close(loadOpen); + layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); + setTimeout(function(){rsyncdReceive();},2000); + }); + } }); - }); + }) } @@ -218,20 +388,34 @@ function delReceive(name){ }); } -function cmdReceive(name){ +function cmdRecSecretKey(name){ var _data = {}; _data['name'] = name; - rsPost('cmd_rec', _data, function(data){ + rsPost('cmd_rec_secret_key', _data, function(data){ var rdata = $.parseJSON(data.data); layer.open({ type: 1, - title: '命令事例', + title: '接收密钥', area: '400px', - content:"
"+rdata.data+"
" + content:"
" }); }); } +function cmdRecCmd(name){ + var _data = {}; + _data['name'] = name; + rsPost('cmd_rec_cmd', _data, function(data){ + var rdata = $.parseJSON(data.data); + layer.open({ + type: 1, + title: '接收命令例子', + area: '400px', + content:"
"+rdata.data+"
" + }); + }); +} + function rsRead(){ var readme = '
    '; From 348c5fe795379ea385bbdbabdc0565972809164e Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 28 Jul 2022 23:11:03 +0800 Subject: [PATCH 36/69] Update index.py --- plugins/rsyncd/index.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py index 993915142..15b84fcfb 100755 --- a/plugins/rsyncd/index.py +++ b/plugins/rsyncd/index.py @@ -500,14 +500,16 @@ def lsyncdList(): def lsyncdAdd(): args = getArgs() - data = checkArgs(args, ['ip', 'name']) + data = checkArgs(args, ['ip', 'name', 'path']) if not data[0]: return data[1] ip = args['ip'] path = args['path'] + name = args['name'] info = { + "name": name, "ip": ip, "path": path } From 5ed3bbb635b45fcc60d79a7f3274b9e99cf2e98e Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 29 Jul 2022 00:32:42 +0800 Subject: [PATCH 37/69] Update webstats_log.lua --- plugins/webstats/lua/webstats_log.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/webstats/lua/webstats_log.lua b/plugins/webstats/lua/webstats_log.lua index 5ece00bf5..78732f005 100644 --- a/plugins/webstats/lua/webstats_log.lua +++ b/plugins/webstats/lua/webstats_log.lua @@ -174,6 +174,12 @@ log_by_lua_block { return count end + local function split_bylog(str,reps ) + local resultStrList = {} + string.gsub(str,'[^'..reps..']+',function(w) table.insert(resultStrList,w) end) + return resultStrList + end + local function is_ipaddr_bylog(client_ip) local cipn = split_bylog(client_ip,'.') if arrlen_bylog(cipn) < 4 then return false end @@ -186,12 +192,6 @@ log_by_lua_block { return true end - local function split_bylog(str,reps ) - local resultStrList = {} - string.gsub(str,'[^'..reps..']+',function(w) table.insert(resultStrList,w) end) - return resultStrList - end - local function get_client_ip_bylog() local client_ip = "unknown" local cdn = auto_config['cdn'] From 8d5af084dab481a37ca67d21174603a6630fd635 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 29 Jul 2022 00:41:31 +0800 Subject: [PATCH 38/69] Update tool_task.py --- plugins/webstats/tool_task.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/webstats/tool_task.py b/plugins/webstats/tool_task.py index d2ab34fdf..fe129ee31 100644 --- a/plugins/webstats/tool_task.py +++ b/plugins/webstats/tool_task.py @@ -61,7 +61,8 @@ def createBgTask(): import crontab_api api = crontab_api.crontab_api() - cmd = "nice -n 10 python3 " + getPluginDir() + "/tool_task.py execute" + cmd = "cd " + mw.getServerDir() + "/mdserver-web && nice -n 10 python3 " + \ + getPluginDir() + "/tool_task.py execute" params = { 'name': name, 'type': 'day', From 2561998e595f25dc002a79a357750565dbc46568 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 29 Jul 2022 00:50:36 +0800 Subject: [PATCH 39/69] Update tool_migrate.py --- plugins/webstats/tool_migrate.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/webstats/tool_migrate.py b/plugins/webstats/tool_migrate.py index 5d6499f29..d190cae58 100644 --- a/plugins/webstats/tool_migrate.py +++ b/plugins/webstats/tool_migrate.py @@ -66,7 +66,13 @@ def pSqliteDb(dbname='web_logs', site_name='unset', fn="logs"): conn.execute("PRAGMA page_size = 4096", ()) conn.execute("PRAGMA journal_mode = wal", ()) - conn.text_factory = lambda x: str(x, encoding="utf-8", errors='ignore') + if sys.version_info[0] == 3: + conn.__DB_CONN.text_factory = lambda x: str( + x, encoding="utf-8", errors='ignore') + else: + conn.__DB_CONN.text_factory = lambda x: unicode(x, "utf-8", "ignore") + + # conn.text_factory = lambda x: str(x, encoding="utf-8", errors='ignore') # conn.text_factory = lambda x: unicode(x, "utf-8", "ignore") return conn From c535c48831ad36c9f6f9e102d8f8966a84392286 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 29 Jul 2022 00:52:58 +0800 Subject: [PATCH 40/69] up --- class/core/db.py | 9 +++++++++ plugins/webstats/tool_migrate.py | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/class/core/db.py b/class/core/db.py index 5be95e8b9..a5052d305 100755 --- a/class/core/db.py +++ b/class/core/db.py @@ -3,6 +3,7 @@ import sqlite3 import os +import sys class Sql(): @@ -31,6 +32,14 @@ class Sql(): except Exception as ex: return "error: " + str(ex) + def autoTextFactory(): + if sys.version_info[0] == 3: + self.__DB_CONN.text_factory = lambda x: str( + x, encoding="utf-8", errors='ignore') + else: + self.__DB_CONN.text_factory = lambda x: unicode( + x, "utf-8", "ignore") + def dbfile(self, name): self.__DB_FILE = 'data/' + name + '.db' return self diff --git a/plugins/webstats/tool_migrate.py b/plugins/webstats/tool_migrate.py index d190cae58..88aede22b 100644 --- a/plugins/webstats/tool_migrate.py +++ b/plugins/webstats/tool_migrate.py @@ -66,11 +66,7 @@ def pSqliteDb(dbname='web_logs', site_name='unset', fn="logs"): conn.execute("PRAGMA page_size = 4096", ()) conn.execute("PRAGMA journal_mode = wal", ()) - if sys.version_info[0] == 3: - conn.__DB_CONN.text_factory = lambda x: str( - x, encoding="utf-8", errors='ignore') - else: - conn.__DB_CONN.text_factory = lambda x: unicode(x, "utf-8", "ignore") + conn.autoTextFactory() # conn.text_factory = lambda x: str(x, encoding="utf-8", errors='ignore') # conn.text_factory = lambda x: unicode(x, "utf-8", "ignore") From 95658a1e6d6542fc7f8a7d626dc58b9f843cce27 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 29 Jul 2022 00:55:37 +0800 Subject: [PATCH 41/69] Update db.py --- class/core/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/db.py b/class/core/db.py index a5052d305..901d0c8cd 100755 --- a/class/core/db.py +++ b/class/core/db.py @@ -32,7 +32,7 @@ class Sql(): except Exception as ex: return "error: " + str(ex) - def autoTextFactory(): + def autoTextFactory(self): if sys.version_info[0] == 3: self.__DB_CONN.text_factory = lambda x: str( x, encoding="utf-8", errors='ignore') From 8e1d226fec6f5d09574e29c5a5784bed790d23d1 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 30 Jul 2022 00:06:19 +0800 Subject: [PATCH 42/69] rsyncd xx2 --- class/core/config_api.py | 2 +- index.html | 248 ------------------ plugins/rsyncd/index.html | 15 +- plugins/rsyncd/index.py | 141 ++++++++++- plugins/rsyncd/js/base64.js | 149 +++++++++++ plugins/rsyncd/js/rsyncd.js | 485 +++++++++++++++++++++++++----------- 6 files changed, 634 insertions(+), 406 deletions(-) delete mode 100644 index.html create mode 100644 plugins/rsyncd/js/base64.js diff --git a/class/core/config_api.py b/class/core/config_api.py index 822dfd35c..ef4d50c59 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -17,7 +17,7 @@ class config_api: # 进行中. # 兼容主流Linux系统 - __version = '0.8.6.11' + __version = '0.8.6.12' def __init__(self): pass diff --git a/index.html b/index.html deleted file mode 100644 index bfb8d9505..000000000 --- a/index.html +++ /dev/null @@ -1,248 +0,0 @@ - - - - - - -debug – 又一个WordPress站点 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - -
    - - -
    • - -

      世界,您好!

      - - - - -
      -

      欢迎使用WordPress。这是您的第一篇文章。编辑或删除它,然后开始写作吧!

      - - - -
      -
      - - - - -
      - -
    - -
    - - -
    - - - - - diff --git a/plugins/rsyncd/index.html b/plugins/rsyncd/index.html index 23d878188..5f502bf5c 100755 --- a/plugins/rsyncd/index.html +++ b/plugins/rsyncd/index.html @@ -1,9 +1,18 @@ +

    服务

    自启动

    -

    发送配置

    +

    发送配置

    接收配置

    说明

    @@ -14,7 +23,11 @@
服务名路径备注操作(添加)名称(标识)源目录同步到模式周期操作
' + list[i]['name']+'' + list[i]['path']+'' + list[i]['comment']+'' + "dd"+'' + list[i]['path']+'' + list[i]['ip']+":"+"cc"+'' + "增量"+'' + "实时" +'\ - 命令\ - | 删除
' + list[i]['path']+'' + list[i]['comment']+'\ - 命令\ + 命令\ + | 密钥\ + | 编辑\ | 删除