mdserver-web/plugins/sphinx/install.sh

85 lines
2.2 KiB
Bash
Raw Normal View History

2019-01-15 10:13:21 -05:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
2019-01-21 01:10:25 -05:00
sysName=`uname`
2019-01-15 10:13:21 -05:00
2019-03-12 04:28:48 -04:00
install_tmp=${rootPath}/tmp/mw_install.pl
2019-01-15 10:13:21 -05:00
2022-07-14 01:17:21 -04:00
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
2022-06-19 23:16:13 -04:00
2022-07-14 01:17:21 -04:00
if [ ${OSNAME} == "centos" ] ||
[ ${OSNAME} == "fedora" ] ||
[ ${OSNAME} == "alma" ]; then
2022-06-19 23:16:13 -04:00
yum install -y postgresql-libs unixODBC
fi
2019-01-15 10:13:21 -05:00
Install_sphinx()
{
echo '正在安装脚本文件...' > $install_tmp
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
2019-01-16 00:02:05 -05:00
if [ ! -f ${SPHINX_DIR}/sphinx-3.1.1.tar.gz ];then
if [ $sysName == 'Darwin' ]; then
wget -O ${SPHINX_DIR}/sphinx-3.1.1.tar.gz http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-darwin-amd64.tar.gz
else
2022-07-14 01:17:21 -04:00
curl -sSLo ${SPHINX_DIR}/sphinx-3.1.1.tar.gz http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-linux-amd64.tar.gz
2019-01-16 00:02:05 -05:00
fi
fi
2022-07-14 07:53:54 -04:00
if [ ! -f ${SPHINX_DIR}/sphinx-3.1.1.tar.gz ];then
curl -sSLo ${SPHINX_DIR}/sphinx-3.1.1.tar.gz https://github.com/midoks/mdserver-web/releases/download/init/sphinx-3.1.1.tar.gz
fi
2019-01-17 22:22:23 -05:00
cd ${SPHINX_DIR} && tar -zxvf sphinx-3.1.1.tar.gz
2022-07-14 04:03:29 -04:00
if [ "$?" == "0" ];then
mkdir -p $SPHINX_DIR
cp -rf ${SPHINX_DIR}/sphinx-3.1.1/ $serverPath/sphinx/bin
fi
2022-06-28 20:55:06 -04:00
if [ -d $serverPath/sphinx ];then
echo '3.1.1' > $serverPath/sphinx/version.pl
echo '安装完成' > $install_tmp
cd ${rootPath} && python3 ${rootPath}/plugins/sphinx/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/sphinx/index.py initd_install
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
2022-07-03 10:23:25 -04:00
rm -rf /usr/lib/systemd/system/sphinx.service
2022-07-14 03:07:28 -04:00
rm -rf /lib/systemd/system/sphinx.service
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
2019-01-15 10:13:21 -05:00
rm -rf $serverPath/sphinx
echo "Uninstall_sphinx" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_sphinx
else
Uninstall_sphinx
fi