mdserver-web/plugins/sphinx/install.sh

172 lines
4.7 KiB
Bash
Raw Permalink Normal View History

2019-01-15 10:13:21 -05:00
#!/bin/bash
2023-11-08 12:32:59 -05:00
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
2019-01-15 10:13:21 -05:00
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
2019-01-21 01:10:25 -05:00
sysName=`uname`
2024-05-19 09:36:25 -04:00
sysArch=`arch`
2019-01-15 10:13:21 -05:00
2024-07-05 00:34:55 -04:00
if [ -f ${rootPath}/bin/activate ];then
source ${rootPath}/bin/activate
fi
2024-05-18 13:32:31 -04:00
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/sphinx/index.py rebuild
2024-05-19 12:34:08 -04:00
# cd /www/server/mdserver-web/plugins/sphinx && bash install.sh install 3.6.1
2024-05-20 12:07:48 -04:00
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/sphinx/index.py db_to_sphinx && /www/server/sphinx/bin/bin/indexer -c /www/server/sphinx/sphinx.conf --all --rotate
2024-05-19 11:03:59 -04:00
# /Users/midoks/Desktop/mwdev/server/sphinx/bin/bin/indexer /Users/midoks/Desktop/mwdev/server/sphinx/sphinx.conf --all --rotate
2019-01-15 10:13:21 -05:00
2024-05-20 12:07:48 -04:00
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/sphinx/index.py sphinx_cmd
2024-05-20 02:11:27 -04:00
# /Users/midoks/Desktop/mwdev/server/sphinx/bin/bin/indexer /Users/midoks/Desktop/mwdev/server/sphinx/sphinx.conf --all --rotate
2024-05-20 12:07:48 -04:00
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/sphinx/index.py start
2022-07-14 01:17:21 -04:00
bash ${rootPath}/scripts/getos.sh
2024-05-19 10:06:47 -04:00
# echo "bash ${rootPath}/scripts/getos.sh"
2024-05-19 09:36:25 -04:00
OSNAME="macos"
if [ -f ${rootPath}/data/osname.pl ];then
OSNAME=`cat ${rootPath}/data/osname.pl`
fi
if [ "${OSNAME}" == "centos" ] ||
[ "${OSNAME}" == "fedora" ] ||
[ "${OSNAME}" == "alma" ]; then
2022-06-19 23:16:13 -04:00
yum install -y postgresql-libs unixODBC
fi
2024-05-19 09:36:25 -04:00
# http://sphinxsearch.com/files/sphinx-3.7.1-da9f8a4-linux-amd64.tar.gz
VERSION=$2
# echo $VERSION
if [ "$VERSION" == "3.1.1" ];then
VERSION_NUM=${VERSION}-612d99f
elif [ "$VERSION" == "3.2.1" ]; then
VERSION_NUM=${VERSION}-f152e0b
elif [ "$VERSION" == "3.3.1" ]; then
VERSION_NUM=${VERSION}-b72d67b
elif [ "$VERSION" == "3.4.1" ]; then
VERSION_NUM=${VERSION}-efbcc65
elif [ "$VERSION" == "3.5.1" ]; then
VERSION_NUM=${VERSION}-82c60cb
elif [ "$VERSION" == "3.6.1" ]; then
VERSION_NUM=${VERSION}-c9dbeda
elif [ "$VERSION" == "3.7.1" ]; then
VERSION_NUM=${VERSION}-da9f8a4
2025-07-16 23:19:33 -04:00
elif [ "$VERSION" == "3.8.1" ]; then
VERSION_NUM=${VERSION}-d25e0bb
2024-05-19 09:36:25 -04:00
fi
# echo $VERSION_NUM
2023-10-18 11:31:50 -04:00
2019-01-15 10:13:21 -05:00
Install_sphinx()
{
2023-11-19 03:10:22 -05:00
echo '正在安装Sphinx...'
2019-01-15 10:13:21 -05:00
mkdir -p $serverPath/sphinx
2019-01-16 00:02:05 -05:00
SPHINX_DIR=${serverPath}/source/sphinx
2022-07-14 21:18:21 -04:00
mkdir -p $SPHINX_DIR
2024-05-19 09:36:25 -04:00
SPH_NAME=amd64
if [ "$sysArch" == "arm64" ];then
SPH_NAME=amd64
elif [ "$sysArch" == "x86_64" ]; then
SPH_NAME=amd64
elif [ "$sysArch" == "aarch64" ]; then
SPH_NAME=aarch64
fi
if [ "$sysName" == "Darwin" ] && [ "$VERSION" == "3.7.1" ];then
SPH_NAME=aarch64
fi
SPH_SYSNAME=linux
if [ $sysName == 'Darwin' ]; then
SPH_SYSNAME=darwin
elif [ "$sysName" == "aarch64" ]; then
SPH_NAME=aarch64
elif [ "$sysName" == "freebsd" ]; then
SPH_NAME=freebsd
fi
2024-05-19 11:48:06 -04:00
if [ "$SPH_SYSNAME" == "linux" ];then
glibc_ver=`ldd --version | grep libc | awk -F ')' '{print $2}'|awk '{gsub(/^\s+|\s+$/, "");print}'`
2024-05-19 12:34:08 -04:00
if [ "$VERSION" == "3.7.1" ] && [ `echo "2.29 > $glibc_ver " | bc` -eq 1 ];then
2024-05-19 11:48:06 -04:00
SPH_NAME=${SPH_NAME}-glibc2.17
fi
2024-05-19 12:34:08 -04:00
if [ "$VERSION" == "3.6.1" ] && [ `echo "2.29 > $glibc_ver " | bc` -eq 1 ];then
2024-05-19 11:48:06 -04:00
SPH_NAME=${SPH_NAME}-glibc2.17
fi
fi
2024-05-19 09:36:25 -04:00
FILE_NAME=sphinx-${VERSION_NUM}-${SPH_SYSNAME}-${SPH_NAME}
FILE_TGZ=${FILE_NAME}.tar.gz
2024-05-19 11:51:32 -04:00
echo $FILE_TGZ
2024-05-19 10:22:52 -04:00
# curl -sSLo ${SPHINX_DIR}/${FILE_TGZ} http://sphinxsearch.com/files/${FILE_TGZ}
2024-05-19 09:36:25 -04:00
if [ ! -f ${SPHINX_DIR}/${FILE_TGZ} ];then
2024-05-19 10:15:43 -04:00
wget --no-check-certificate -O ${SPHINX_DIR}/${FILE_TGZ} http://sphinxsearch.com/files/${FILE_TGZ}
2019-01-16 00:02:05 -05:00
fi
2024-05-19 09:36:25 -04:00
cd ${SPHINX_DIR} && tar -zxvf ${FILE_TGZ}
2022-07-14 04:03:29 -04:00
if [ "$?" == "0" ];then
mkdir -p $SPHINX_DIR
2023-10-18 11:31:50 -04:00
cp -rf ${SPHINX_DIR}/sphinx-${VERSION}/ $serverPath/sphinx/bin
2022-07-14 04:03:29 -04:00
fi
2022-06-28 20:55:06 -04:00
if [ -d $serverPath/sphinx ];then
2023-10-18 11:31:50 -04:00
echo "${VERSION}" > $serverPath/sphinx/version.pl
2023-11-19 03:10:22 -05:00
echo '安装Sphinx完成'
2022-06-28 20:55:06 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/sphinx/index.py start
2024-05-19 09:54:20 -04:00
if [ $sysName != 'Darwin' ]; then
cd ${rootPath} && python3 ${rootPath}/plugins/sphinx/index.py initd_install
fi
2022-06-28 20:55:06 -04:00
fi
2023-11-10 05:47:32 -05:00
if [ -d ${SPHINX_DIR}/sphinx-${VERSION} ];then
rm -rf ${SPHINX_DIR}/sphinx-${VERSION}
fi
2019-01-15 10:13:21 -05:00
}
Uninstall_sphinx()
{
2022-07-14 03:07:28 -04:00
if [ -f /usr/lib/systemd/system/sphinx.service ] || [ -f /lib/systemd/system/sphinx.service ];then
2022-06-28 20:55:06 -04:00
systemctl stop sphinx
systemctl disable sphinx
2024-05-19 09:36:25 -04:00
if [ -f /usr/lib/systemd/system/sphinx.service ];then
rm -rf /usr/lib/systemd/system/sphinx.service
fi
if [ -f /lib/systemd/system/sphinx.service ];then
rm -rf /lib/systemd/system/sphinx.service
fi
2022-06-28 20:55:06 -04:00
systemctl daemon-reload
fi
if [ -f $serverPath/sphinx/initd/sphinx ];then
$serverPath/sphinx/initd/sphinx stop
fi
2024-05-19 10:06:47 -04:00
if [ -d $serverPath/sphinx ];then
echo "rm -rf $serverPath/sphinx"
2024-05-19 09:36:25 -04:00
rm -rf $serverPath/sphinx
fi
echo "卸载sphinx成功"
2019-01-15 10:13:21 -05:00
}
action=$1
if [ "${1}" == 'install' ];then
Install_sphinx
else
Uninstall_sphinx
fi