写的比较粗糙,欢迎交流,有问题直接找我
#!/bin/bash
Soft_dir="/home/***"
Download_URL="http://download.redis.io/releases/redis-2.8.19.tar.gz"
Redis_Version="3.0.2"
root_or_not(){
if [ `id -u` != 0 ] ; then
echo -e "\e[1;44m <====no root, gun!====> \e[0m"
exit 1
fi
}
install_or_not(){
read -p "zhuang, Input Y ; bu zhuang,Input N:" INSTALL_OR_NOT
case $INSTALL_OR_NOT in
Y|y)
install_redis
;;
N|n)
echo -e "\e[0;44m <====Stop install Redis====> \e[0m"
exit 1
;;
*)
echo -e "\e[1;44m Only Input Y or N \e[0m"
install_or_not
;;
esac
}
check_result(){
if [ $1 != 0 ];then
echo -e "\e[1,44m <==== Error,Exit install redis ====> \e[0m"
exit 1
fi
}
install_redis(){
[ ! -d ${Soft_dir} ] && mkdir ${Soft_dir}
cd ${Soft_dir}
check_result $?
yum install wget - y
check_result $?
#wget $Download_URL
check_result $?
tar xf redis-stable.tar.gz
check_result $?
cd redis-stable
check_result $?
make
check_result $?
make install
check_result $?
mkdir -p /usr/local/redis/{etc,dump,logs}
check_result $?
touch /usr/local/redis/etc/redis.conf
check_result $?
echo -e "\e[1;44m <======cp conf /usr/local/redis/etc =======> \e[0m"
}
root_or_not
install_or_not