Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/redis/install.sh

89 lines
2.1 KiB

7 years ago
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
7 years ago
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
2 years ago
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/redis && bash install.sh install 7.2.2
# cmd查看| info replication
# /Users/midoks/Desktop/mwdev/server/redis/bin/redis-cli -h 127.0.0.1 -p 6399
# /www/server/redis/bin/redis-cli -h 127.0.0.1 -p 6399
7 years ago
2 years ago
install_tmp=${rootPath}/tmp/mw_install.pl
5 years ago
VERSION=$2
7 years ago
2 years ago
Install_App()
7 years ago
{
echo '正在安装脚本文件...' > $install_tmp
5 years ago
mkdir -p $serverPath/source
7 years ago
5 years ago
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
7 years ago
2 years ago
CMD_MAKE=`which gmake`
if [ "$?" == "0" ];then
cd redis-${VERSION} && gmake PREFIX=$serverPath/redis install
else
cd redis-${VERSION} && make PREFIX=$serverPath/redis install
fi
7 years ago
if [ -d $serverPath/redis ];then
2 years ago
mkdir -p $serverPath/redis/data
sed '/^ *#/d' redis.conf > $serverPath/redis/redis.conf
7 years ago
2 years ago
echo "${VERSION}" > $serverPath/redis/version.pl
echo '安装完成'
cd ${rootPath} && python3 ${rootPath}/plugins/redis/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/redis/index.py initd_install
2 years ago
else
echo '安装失败!'
fi
2 years ago
if [ -d $serverPath/source/redis-${VERSION} ];then
rm -rf $serverPath/source/redis-${VERSION}
fi
7 years ago
}
2 years ago
Uninstall_App()
7 years ago
{
if [ -f /usr/lib/systemd/system/redis.service ];then
systemctl stop redis
systemctl disable redis
rm -rf /usr/lib/systemd/system/redis.service
systemctl daemon-reload
fi
if [ -f /lib/systemd/system/redis.service ];then
systemctl stop redis
systemctl disable redis
rm -rf /lib/systemd/system/redis.service
systemctl daemon-reload
fi
if [ -f $serverPath/redis/initd/redis ];then
$serverPath/redis/initd/redis stop
fi
rm -rf $serverPath/redis
7 years ago
echo "Uninstall_redis" > $install_tmp
7 years ago
}
action=$1
if [ "${1}" == 'install' ];then
2 years ago
Install_App
7 years ago
else
2 years ago
Uninstall_App
7 years ago
fi