Fetch the repository succeeded.
pathFile="redis-3.2.4"
serviceFile="/etc/init.d/redisd"
installPath="/usr/local/$pathFile/"
sourceFile="$pathFile.tar.gz"
configFile=$installPath$pathFile"/redis.conf"
pidFile=/var/run/redis.pid
if [ ! -d $installPath ];then
mkdir -p $installPath
else
#rm -rf $installPath/*
printf "删除 $installPath\n"
fi
if [ -f $sourceFile ];then
tar -zxvf $sourceFile
cd $pathFile && make
if [ $? == 0 ];then
cp -Rf ./src $installPath
cp redis.conf $installPath
sed -i '128c daemonize yes' ${installPath}redis.conf
if [ $? == 0 ];then
echo "";
echo "#!/bin/sh
# chkconfig: 2345 80 90
# description: redis auto run
#
redisServer=\"${installPath}src/redis-server\"
redisCli=\"${installPath}src/redis-cli\"
configFile=\"${installPath}redis.conf\"
pidFile=\"$pidFile\"
function start(){
if [ -f \"\$configFile\" ];then
if [ -f \$redisServer ];then
\$redisServer \$configFile
if [ \$? == 0 ];then
echo -e \"\033[32;49;1m [启动成功] \033[39;49;0m\"
else
printf \"启动失败\n\"
fi
else
printf \"服务文件 \$mongodFile 不存在\n\"
fi
else
printf \"配置文件不存在\n\"
fi
}
function stop(){
if [ -f \"\$redisCli\" ]; then
\$redisCli shutdown
if [ \$? == 0 ];then
printf \"\t server stop OK \n\"
return 0
fi
else
printf \"\t server is not run\n\"
return 2
fi
}
case \$1 in
start )
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
start
;;
esac">$serviceFile
echo "servier file : $serviceFile \n"
chmod +x $serviceFile;
fi
else
printf "install fail \n"
fi
else
printf "$sourceFile 不存在\n"
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。