diff --git a/plugins/manticoresearch/install.sh b/plugins/manticoresearch/install.sh index 2ee66a254..804ec448e 100755 --- a/plugins/manticoresearch/install.sh +++ b/plugins/manticoresearch/install.sh @@ -11,6 +11,7 @@ sysArch=`arch` # cd /www/server/mdserver-web/plugins/manticoresearch && bash install.sh install 7.4.6 # cd /www/server/mdserver-web && python3 plugins/manticoresearch/index.py run_status_test +# cd /www/server/mdserver-web && python3 plugins/manticoresearch/index.py start # systemctl status manticore # systemctl restart manticore diff --git a/plugins/manticoresearch/tool_cron.py b/plugins/manticoresearch/tool_cron.py index 9234560cd..46a012559 100644 --- a/plugins/manticoresearch/tool_cron.py +++ b/plugins/manticoresearch/tool_cron.py @@ -181,7 +181,7 @@ def removeBgTask(): "id=?", (cfg["task_id"],)).find() if res and res["id"] == cfg["task_id"]: data = MwCrontab.instance().delete(cfg["task_id"]) - if data[0]: + if data['status']: cfg["task_id"] = -1 mw.writeFile(getTaskConf(), json.dumps(cfg)) return True @@ -194,7 +194,7 @@ def removeDeltaBgTask(): "id=?", (cfg["task_id"],)).find() if res and res["id"] == cfg["task_id"]: data = MwCrontab.instance().delete(cfg["task_id"]) - if data[0]: + if data['status']: cfg["task_id"] = -1 mw.writeFile(getTaskDeltaConf(), json.dumps(cfg)) return True diff --git a/plugins/mariadb/info.json b/plugins/mariadb/info.json index 48a8e5b09..6951e77a8 100755 --- a/plugins/mariadb/info.json +++ b/plugins/mariadb/info.json @@ -9,7 +9,7 @@ "uninstall_pre_inspection":true, "checks": "server/mariadb", "path": "server/mariadb", - "versions":["10.6","10.7","10.8","10.9","10.11","11.0","11.1","11.2","11.3","11.4","11.5","11.6","11.7","11.8"], + "versions":["10.6","10.7","10.8","10.9","10.11","11.0","11.1","11.2","11.3","11.4","11.5","11.6","11.7","11.8","12.0"], "shell":"install.sh", "checks":"server/mariadb", "path":"server/mariadb", diff --git a/plugins/mariadb/versions/11.8/install.sh b/plugins/mariadb/versions/11.8/install.sh index 5f8c7b4b6..c4b07ce6d 100755 --- a/plugins/mariadb/versions/11.8/install.sh +++ b/plugins/mariadb/versions/11.8/install.sh @@ -13,7 +13,7 @@ sysName=`uname` mariadbDir=${serverPath}/source/mariadb -MY_VER=11.8.2 +MY_VER=11.8.3 Install_app() { @@ -91,7 +91,7 @@ Install_app() make -j${cpuCore} && make install && make clean if [ -d $serverPath/mariadb ];then - echo '11.7' > $serverPath/mariadb/version.pl + echo '11.8' > $serverPath/mariadb/version.pl echo '安装完成' else echo '安装失败' diff --git a/plugins/mariadb/versions/12.0/install.sh b/plugins/mariadb/versions/12.0/install.sh new file mode 100755 index 000000000..68603ec4e --- /dev/null +++ b/plugins/mariadb/versions/12.0/install.sh @@ -0,0 +1,120 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +#https://dev.mysql.com/downloads/mysql/5.5.html#downloads +#https://dev.mysql.com/downloads/file/?id=480541 + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` + +mariadbDir=${serverPath}/source/mariadb + +MY_VER=12.0.3 + +Install_app() +{ + mkdir -p ${mariadbDir} + echo '正在安装脚本文件...' + + if [ "$sysName" != "Darwin" ];then + mkdir -p /var/log/mariadb + touch /var/log/mariadb/mariadb.log + fi + + # ----- cpu start ------ + if [ -z "${cpuCore}" ]; then + cpuCore="1" + fi + + if [ -f /proc/cpuinfo ];then + cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l` + fi + + MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}') + if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then + if [ "${cpuCore}" -gt "${MEM_INFO}" ];then + cpuCore="${MEM_INFO}" + fi + else + cpuCore="1" + fi + + if [ "$cpuCore" -gt "2" ];then + cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'` + else + cpuCore="1" + fi + # ----- cpu end ------ + + # if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then + # wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz + # fi + + # https://downloads.mariadb.org/interstitial/mariadb-10.9.1/source/mariadb-10.9.1.tar.gz + if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then + wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://archive.mariadb.org/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz + fi + + if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then + cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz + fi + + INSTALL_CMD=cmake + # check cmake version + CMAKE_VERSION=`cmake -version | grep version | awk '{print $3}' | awk -F '.' '{print $1}'` + if [ "$CMAKE_VERSION" -eq "2" ];then + mkdir -p /var/log/mariadb + touch /var/log/mariadb/mariadb.log + INSTALL_CMD=cmake3 + fi + + if [ ! -d $serverPath/mariadb ];then + cd ${mariadbDir}/mariadb-${MY_VER} && ${INSTALL_CMD} \ + -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ + -DMYSQL_DATADIR=$serverPath/mariadb/data/ \ + -DMYSQL_USER=mysql \ + -DMYSQL_UNIX_ADDR=$serverPath/mariadb/mysql.sock \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_MEMORY_STORAGE_ENGINE=1 \ + -DENABLED_LOCAL_INFILE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DEXTRA_CHARSETS=all \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ + make -j${cpuCore} && make install && make clean + + if [ -d $serverPath/mariadb ];then + echo '12.0' > $serverPath/mariadb/version.pl + echo '安装完成' + else + echo '安装失败' + echo 'install fail'>&2 + exit 1 + fi + fi + + if [ -d ${mariadbDir}/mariadb-${MY_VER} ];then + rm -rf ${mariadbDir}/mariadb-${MY_VER} + fi + +} + +Uninstall_app() +{ + rm -rf $serverPath/mariadb + echo '卸载完成' +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_app +else + Uninstall_app +fi diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index ee4e752c4..4480ba02b 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -1527,8 +1527,8 @@ def runLog(): def installPreInspectionDebainCheck(sysId,version): if version == '8.0': - if sysId != '12': - return "[%s]需要debain[12]" % (version,) + if int(sysId) < 12: + return "[%s]需要至少debain[12]" % (version,) return '' def installPreInspection(version): diff --git a/plugins/mysql-community/install.sh b/plugins/mysql-community/install.sh index 5ac112ee8..656a8f837 100755 --- a/plugins/mysql-community/install.sh +++ b/plugins/mysql-community/install.sh @@ -22,7 +22,7 @@ fi # /www/server/mysql-community/bin/mysqld --basedir=/www/server/mysql-community --datadir=/www/server/mysql-community/data --initialize-insecure --explicit_defaults_for_timestamp # source bin/activate -# cd /www/server/mdserver-web/plugins/mysql-community && bash install.sh install 9.0 +# cd /www/server/mdserver-web/plugins/mysql-community && bash install.sh install 5.7 # cd /www/server/mdserver-web/plugins/mysql-community && bash install.sh uninstall 9.0 # cd /www/server/mdserver-web && python3 plugins/mysql-community/index.py start 8.0 # cd /www/server/mdserver-web && python3 plugins/mysql-community/index.py fix_db_access @@ -82,6 +82,15 @@ if [[ "$OSNAME" == "ubuntu" ]] && [[ "$VERSION_ID" =~ "24" ]]; then cd $cur_dir fi +if [[ "$OSNAME" == "debian" ]] && [[ "$VERSION_ID" =~ "13" ]]; then + cur_dir=`pwd` + cd /usr/lib/x86_64-linux-gnu + if [ ! -f libaio.so.1 ];then + ln -s libaio.so.1t64.0.2 libaio.so.1 + fi + cd $cur_dir +fi + if [ "${2}" == "" ];then echo '缺少安装脚本...' exit 0 diff --git a/plugins/mysql/install.sh b/plugins/mysql/install.sh index 630a0bc8c..e8b294356 100755 --- a/plugins/mysql/install.sh +++ b/plugins/mysql/install.sh @@ -5,7 +5,7 @@ export PATH # 手动主从设置 # https://www.cnblogs.com/whiteY/p/17331882.html -# cd /www/server/mdserver-web/plugins/mysql && bash install.sh install 8.2 +# cd /www/server/mdserver-web/plugins/mysql && bash install.sh install 5.5 # cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py try_slave_sync_bugfix {} # cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py do_full_sync {"db":"xxx","sign":"","begin":1} # cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py sync_database_repair {"db":"xxx","sign":""} diff --git a/plugins/mysql/versions/5.5/install.sh b/plugins/mysql/versions/5.5/install.sh index 829de8864..e6ce62bab 100755 --- a/plugins/mysql/versions/5.5/install.sh +++ b/plugins/mysql/versions/5.5/install.sh @@ -56,6 +56,42 @@ fi VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +Install_common(){ + apt install -y libudev-dev + apt install -y libtirpc-dev + apt install -y libssl-dev + apt install -y libgssglue-dev + apt install -y software-properties-common + + apt install -y build-essential + apt install -y cmake + apt install -y pkg-config + apt install -y libncurses5-dev + apt install -y libsystemd-dev + apt install -y libsasl2-dev + apt install -y libldap2-dev +} + +# 安装依赖 +Install_dep(){ + Install_common + add-apt-repository -y ppa:ubuntu-toolchain-r/test + + export PKG_CONFIG_PATH=/usr/lib/pkgconfig + apt install -y gcc-10 g++-10 + WHERE_DIR_GCC=/usr/bin/gcc-10 + WHERE_DIR_GPP=/usr/bin/g++-10 +} + +Install_dep_debain13(){ + Install_common + # add-apt-repository -y ppa:ubuntu-toolchain-r/test + export PKG_CONFIG_PATH=/usr/lib/pkgconfig + apt install -y gcc-12 g++-12 + WHERE_DIR_GCC=/usr/bin/gcc-12 + WHERE_DIR_GPP=/usr/bin/g++-12 +} + Install_mysql() { mkdir -p ${mysqlDir} @@ -117,17 +153,25 @@ Install_mysql() fi if [ "$OSNAME" == "ubuntu" ];then - apt install -y libudev-dev - apt install -y libtirpc-dev - apt install -y libssl-dev - apt install -y libgssglue-dev - apt install -y software-properties-common - add-apt-repository -y ppa:ubuntu-toolchain-r/test + Install_dep + fi - export PKG_CONFIG_PATH=/usr/lib/pkgconfig - apt install -y gcc-10 g++-10 - WHERE_DIR_GCC=/usr/bin/gcc-10 - WHERE_DIR_GPP=/usr/bin/g++-10 + OPTIONS='' + + if [ "$OSNAME" == "debian" ] && [ "$VERSION_ID" == "13" ];then + Install_dep_debain13 + # export CFLAGS="-D__s64=long long -D__u64='unsigned long long' -D__s32=int -D__u32='unsigned int' -D__u16='unsigned short'" + # export CXXFLAGS="$CFLAGS" + # OPTIONS="${OPTIONS} -DCMAKE_C_FLAGS=${CFLAGS}" + # OPTIONS="${OPTIONS} -DCMAKE_CXX_FLAGS=${CXXFLAGS}" + + cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh + export PKG_CONFIG_PATH=${serverPath}/lib/openssl10/lib/pkgconfig + OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl10" + + # 经过测试,无法安装 + echo "debain13不支持5.5低版本编译" + exit 0 fi if [ ! -d $serverPath/mysql ];then @@ -141,6 +185,7 @@ Install_mysql() -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ + $OPTIONS \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 90d7bc303..97b6ddc0e 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -56,6 +56,44 @@ fi VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +Install_common(){ + apt install -y libudev-dev + apt install -y libtirpc-dev + apt install -y libssl-dev + apt install -y libgssglue-dev + apt install -y software-properties-common + + apt install -y build-essential + apt install -y cmake + apt install -y pkg-config + apt install -y libncurses5-dev + apt install -y libsystemd-dev + apt install -y libsasl2-dev + apt install -y libldap2-dev +} + +# 安装依赖 +Install_dep(){ + Install_common + + add-apt-repository -y ppa:ubuntu-toolchain-r/test + + export PKG_CONFIG_PATH=/usr/lib/pkgconfig + apt install -y gcc-11 g++-11 + WHERE_DIR_GCC=/usr/bin/gcc-11 + WHERE_DIR_GPP=/usr/bin/g++-11 +} + +Install_dep_debain13(){ + Install_common + + # add-apt-repository -y ppa:ubuntu-toolchain-r/test + export PKG_CONFIG_PATH=/usr/lib/pkgconfig + apt install -y gcc-12 g++-12 + WHERE_DIR_GCC=/usr/bin/gcc-12 + WHERE_DIR_GPP=/usr/bin/g++-12 +} + Install_mysql() { mkdir -p ${mysqlDir} @@ -125,17 +163,11 @@ Install_mysql() fi if [ "$OSNAME" == "ubuntu" ];then - apt install -y libudev-dev - apt install -y libtirpc-dev - apt install -y libssl-dev - apt install -y libgssglue-dev - apt install -y software-properties-common - add-apt-repository -y ppa:ubuntu-toolchain-r/test + Install_dep + fi - export PKG_CONFIG_PATH=/usr/lib/pkgconfig - apt install -y gcc-11 g++-11 - WHERE_DIR_GCC=/usr/bin/gcc-11 - WHERE_DIR_GPP=/usr/bin/g++-11 + if [ "$OSNAME" == "debian" ] && [ "$VERSION_ID" == "13" ];then + Install_dep_debain13 fi OPTIONS='' diff --git a/plugins/php-apt/install.sh b/plugins/php-apt/install.sh index a66cd5448..ac4eefb2b 100755 --- a/plugins/php-apt/install.sh +++ b/plugins/php-apt/install.sh @@ -7,6 +7,7 @@ rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +# cd /www/server/mdserver-web/plugins/php-apt && bash install.sh install 56 if id www &> /dev/null ;then echo "www uid is `id -u www`" diff --git a/plugins/php/lib/openssl.sh b/plugins/php/lib/openssl.sh index ba4802dec..b5d635d01 100644 --- a/plugins/php/lib/openssl.sh +++ b/plugins/php/lib/openssl.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") -opensslVersion="3.0.10" +opensslVersion="3.5.2" # echo $rootPath SERVER_ROOT=$rootPath/lib diff --git a/plugins/php/lib/openssl_35.sh b/plugins/php/lib/openssl_35.sh new file mode 100644 index 000000000..7e8344c16 --- /dev/null +++ b/plugins/php/lib/openssl_35.sh @@ -0,0 +1,41 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") + +opensslVersion="3.5.2" +# echo $rootPath + +SERVER_ROOT=$rootPath/lib +SOURCE_ROOT=$rootPath/source/lib +mkdir -p $SOURCE_ROOT + +if [ ! -d ${SERVER_ROOT}/openssl35 ];then + cd ${SOURCE_ROOT} + if [ ! -f ${SOURCE_ROOT}/openssl-${opensslVersion}.tar.gz ];then + wget --no-check-certificate -O ${SOURCE_ROOT}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz + fi + tar -zxvf openssl-${opensslVersion}.tar.gz + cd openssl-${opensslVersion} + ./config --prefix=${SERVER_ROOT}/openssl35 zlib-dynamic shared + make && make install + + + # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/www/server/lib/openssl35/lib + if [ -d /etc/ld.so.conf.d ];then + echo "/www/server/lib/openssl35/lib64" > /etc/ld.so.conf.d/openssl35.conf + elif [ -f /etc/ld.so.conf ]; then + echo "/www/server/lib/openssl35/lib64" >> /etc/ld.so.conf + fi + + ldconfig + # ldconfig -p | grep openssl + + cd $SOURCE_ROOT && rm -rf $SOURCE_ROOT/openssl-${opensslVersion} +fi + diff --git a/plugins/phpmyadmin/install.sh b/plugins/phpmyadmin/install.sh index 7846f042b..9d7f1790a 100755 --- a/plugins/phpmyadmin/install.sh +++ b/plugins/phpmyadmin/install.sh @@ -7,6 +7,7 @@ rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +# cd /www/server/mdserver-web/plugins/phpmyadmin && bash install.sh install 4.4.15 # cd /www/server/mdserver-web && python3 plugins/phpmyadmin/index.py start if [ -f ${rootPath}/bin/activate ];then diff --git a/web/core/mw.py b/web/core/mw.py index dbb01ada5..1a2358e6f 100644 --- a/web/core/mw.py +++ b/web/core/mw.py @@ -423,9 +423,18 @@ def md5(content): return False def hasPwd(password): - # 加密密码字符 - import crypt - return crypt.crypt(password, password) + ''' + 加密密码字符 + ''' + # python3 -c "import crypt" + # python3 -c 'import crypt; print(crypt.crypt(""))' + # import crypt + # return crypt.crypt(password, password) + import bcrypt + salt = bcrypt.gensalt() + hpw = bcrypt.hashpw(password.encode('utf-8'), salt) + return hpw.decode('utf-8') + def getFileMd5(filename): # 文件的MD5值 @@ -553,6 +562,7 @@ def getSslCrt(): def getOs(): + # python3 -c 'import sys; print(sys.platform)' return sys.platform def getOsName(): diff --git a/web/utils/crontab.py b/web/utils/crontab.py index 86d8c15a8..b0d14a86b 100644 --- a/web/utils/crontab.py +++ b/web/utils/crontab.py @@ -519,22 +519,27 @@ echo "-------------------------------------------------------------------------- def writeShell(self, bash_script): if mw.isAppleSystem(): return mw.returnData(True, 'ok') + + if not os.path.exists("/var/spool/cron/crontabs"): + mw.execShell("mkdir -p /var/spool/cron/crontabs") + file = '/var/spool/cron/crontabs/root' sys_os = mw.getOs() + sys_name = mw.getOsName() if sys_os == 'darwin': file = '/etc/crontab' - elif sys_os.startswith("freebsd"): + elif sys_name.startswith("freebsd"): file = '/var/cron/tabs/root' - - if not os.path.exists(file): - file = '/var/spool/cron/root' + # elif sys_name.startswith("ubuntu"): + # file = '/var/spool/cron/root' if not os.path.exists(file): mw.writeFile(file, '') - content = mw.readFile(file) if not content: - return mw.returnData(False, '计划任务配置文件不存在?') + content = '' + # if not content: + # return mw.returnData(False, '计划任务配置文件不存在?') content += str(bash_script) + "\n" if mw.writeFile(file, content): if not os.path.exists(file):