mdserver-web/plugins/redis/install.sh

64 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2018-11-05 06:05:33 -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-03-12 04:28:48 -04:00
install_tmp=${rootPath}/tmp/mw_install.pl
2018-11-05 06:05:33 -05:00
2020-06-07 04:29:49 -04:00
VERSION=$2
2018-11-05 06:05:33 -05:00
2018-11-05 10:42:01 -05:00
Install_redis()
2018-11-05 06:05:33 -05:00
{
echo '正在安装脚本文件...' > $install_tmp
2020-06-07 04:29:49 -04:00
mkdir -p $serverPath/source
2018-11-05 06:05:33 -05:00
2020-06-07 04:29:49 -04:00
if [ ! -f $serverPath/source/redis-${VERSION}.tar.gz ];then
wget -O $serverPath/source/redis-${VERSION}.tar.gz http://download.redis.io/releases/redis-${VERSION}.tar.gz
fi
cd $serverPath/source && tar -zxvf redis-${VERSION}.tar.gz
2018-11-20 04:43:29 -05:00
mkdir -p $serverPath/redis
2022-06-20 09:56:24 -04:00
mkdir -p $serverPath/redis/data
2020-06-07 04:29:49 -04:00
cd redis-${VERSION} && make PREFIX=$serverPath/redis install
2018-11-20 04:43:29 -05:00
sed '/^ *#/d' redis.conf > $serverPath/redis/redis.conf
2022-06-28 15:03:35 -04:00
if [ -d $serverPath/redis ];then
echo "${VERSION}" > $serverPath/redis/version.pl
echo '安装完成' > $install_tmp
2018-11-20 04:43:29 -05:00
2022-06-28 15:03:35 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/redis/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/redis/index.py initd_install
fi
2018-11-05 06:05:33 -05:00
}
2018-11-05 10:42:01 -05:00
Uninstall_redis()
2018-11-05 06:05:33 -05:00
{
2022-07-03 10:22:03 -04:00
if [ -f /usr/lib/systemd/system/redis.service ];then
2022-06-28 15:03:35 -04:00
systemctl stop redis
systemctl disable redis
2022-07-03 10:22:03 -04:00
rm -rf /usr/lib/systemd/system/redis.service
2022-06-28 15:03:35 -04:00
systemctl daemon-reload
2022-06-18 03:43:50 -04:00
fi
2022-06-28 15:03:35 -04:00
if [ -f $serverPath/redis/initd/redis ];then
$serverPath/redis/initd/redis stop
fi
rm -rf $serverPath/redis
2018-12-05 01:00:31 -05:00
echo "Uninstall_redis" > $install_tmp
2018-11-05 06:05:33 -05:00
}
action=$1
if [ "${1}" == 'install' ];then
2018-11-05 10:42:01 -05:00
Install_redis
2018-11-05 06:05:33 -05:00
else
2018-11-05 10:42:01 -05:00
Uninstall_redis
2018-11-05 06:05:33 -05:00
fi