shell脚本一键安装redis
支持识别离线包和联网安装,自动修改使用后台运行模式,离线安装的方法是,将离线包和脚本放在同一个文件夹, 它会先识别有没有离线包, 有离线包就先安装离线包, 没有离线包就安装进行判断机器是否能联网, 能联网的情况下自动请求源安装,一切自动化。下面演示一下
#!/bin/bash
#------------------------------------------------------------------------------------------------------------------#
#| Some people die at the age of 25 and don't bury themselves in the earth until they are 75 |#
#------------------------------------------------------------------------------------------------------------------#
#| $$$$ $$ $$ $$$$$$ $$ $$ $$$$$$ $$ $$$$$$ $$$$$$ |#
#| $$ $$ $$ $$ $$ $$ $$ $$ $$ $$ $$ |#
#| $$ $$$$$$$ $$$$$ $$ $$ $ $$ $$$$$$ $$ $$$$$ $$$$$ |#
#| $$ $$ $$ $$ $$ $ $ $$ $$ $$ $$ $$ |#
#| $$$$ $$ $$ $$$$$$ $$ $$ $$$$$ $$ $$$$$$ $$$$$$ $$$$$$ |#
#------------------------------------------------------------------------------------------------------------------#
onversion="4.0.3"
offversion=`basename redis-*.tar.gz .tar.gz | awk -F '-' '{print$2}'`
installdir=$(cd `dirname $0`; pwd) function initize(){
installdir=$(cd `dirname $0`; pwd)
} function checkroot(){
if [ $UID -ne 0 ]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|------------------------------------------[权限不足...请切换至root用户]-----------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
exit;
fi
} function judge(){
echo
offfile=`ls | grep redis-*.tar.gz`
if [[ "$offfile" != "" ]]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[发现离线包]---------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
offinstall
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[未发现离线包]-------------------------------------------------|"
echo "|--------------------------------------------[开始判断是否连接外网安装]------------------------------------------|"
/usr/bin/sleep 3
network
fi
} function offinstall(){
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|------------------------------------------------[离线包安装中]--------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
tar -zxvf redis-${offversion}.tar.gz >/dev/null 2>&1
redis="redis-${offversion}"
cd ${redis}/src && make >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "编译出错"
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|---------------------------------------------------[编译完成]---------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
intend
fi
} function network(){
httpcode=`curl -I -m 10 -o /dev/null -s -w %{http_code}'\n' http://www.baidu.com`
net1=$(echo $httpcode | grep "200")
if [[ "$net1" != "" ]]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-----------------------------------------------------[联网]-----------------------------------------------------|"
echo "|-------------------------------------------------[准备联网安装]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
online
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------[未联网,无离线安装包,准备退出]---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
exit;
fi
}
function online(){
wget_v=`which wget`
wget_vv=$(echo $wget_v | grep wget)
if [[ "$wget_vv" != "" ]]
then
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|--------------------------------------`wget -V |head -n 1`---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
wget http://download.redis.io/releases/redis-${onversion}.tar.gz
installon
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|----------------------------------------[检测到wget没有安装, 准备安装wget]---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
yum install wget -y
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|--------------------------------------`wget -V |head -n 1`---------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
wget http://download.redis.io/releases/redis-${onversion}.tar.gz
installon
fi
} function installon(){
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|------------------------------------------------[在线包安装中]--------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
tar -zxvf redis-${onversion}.tar.gz >/dev/null 2>&1
redis="redis-${onversion}"
cd ${redis}/src && make >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "编译出错"
else
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|--------------------------------------------------[编译完成]----------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 3
intend
fi
} function intend(){
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[开始迁移文件]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
mkdir -p ${installdir}/redis/{logs,nodes,conf,bin}
cp redis-cli redis-server ${installdir}/redis/bin
cp redis-trib.rb ${installdir}/redis
cp ../redis.conf ${installdir}/redis/conf
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[数据迁移完成]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
/usr/bin/sleep 2
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[清理多余文件]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
finish
/usr/bin/sleep 2
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[配置快捷启动]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
service
/usr/bin/sleep 2
echo "|----------------------------------------------------------------------------------------------------------------|"
echo "|-------------------------------------------------[修改配置文件]-------------------------------------------------|"
echo "|----------------------------------------------------------------------------------------------------------------|"
configfile
/usr/bin/sleep 2
echo "|****************************************************************************************************************|"
echo "| WW WW EEEEEEE LL CCCCC OOOOOO MM MM EEEEEEE |"
echo "| WW WWWW WW EE LL CC OO OO MMMM MMMM EE |"
echo "| WW WW WW WW EEEEE LL CC OO OO MM MM MM MM EEEEE |"
echo "| WW W W WW EE LL CC OO OO MM M M MM EE |"
echo "| WW WW EEEEEEE LLLLLL CCCCC OOOOOO MM MMM MM EEEEEEE |"
echo "|****************************************************************************************************************|"
}
function finish(){
echo
rm -rf ${installdir}/redis-*
}
function service(){
cd ${installdir}/redis && echo "./bin/redis-server conf/redis.conf" > start.sh
chmod +x start.sh
}
function configfile(){
cd ${installdir}/redis/conf
#后台
sed -i 's/daemonize no/daemonize yes/' redis.conf
#端口
sed -i 's/port 6379/port 7000/' redis.conf
#日志输出文件
sed -i 's/logfile ""/logfile "\/usr\/local\/src\/redis\/logs\/redis.logs"/' redis.conf
}
function main(){
checkroot
judge
}
main
离线安装的效果
在线安装的效果
shell脚本一键安装redis的更多相关文章
- shell脚本一键安装redis集群[最终版]
直接上shell了. #!/bin/bash #---------------------------------------------------------------------------- ...
- shell脚本一键安装redis集群
简介: 明天再写,上脚本 #!/bin/bash #-------------------------------------------------------------------------- ...
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15 #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...
- 安装完Ubuntu后通过shell脚本一键安装软件
安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...
- shell脚本一键安装mysql5.7.x
使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...
- shell脚本一键安装mysql5.7.x(免安装版)
使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- shell脚本一键安装jdk
直接上shell #!/bin/bash #offline jdk install ipath="/usr/local" installpath=$(cd `dirname $0` ...
随机推荐
- securecrt配置经验总结(home.key和颜色)
还是用securecrt portable方便,配好了,换个机器,打包拷贝过去就行了.不用从两个地方去打包. 参考了网上的资料,颜色参考http://www.jackxiang.com/post/58 ...
- ecshop 前台个人中心修改侧边栏 和 侧边栏显示不全 或 导航现实不全
怎么给个人中心侧边栏加项或者减项 在模板文件default/user_menu.lbi 文件里添加或者修改,一般看到页面都会知道怎么加,怎么删,这里就不啰嗦了 添加一个栏目以后,这个地址跳的页面怎么写 ...
- QT 添加 lib库
扒自网友文章: 一.添加第三方的头文件 首先,添加头文件 #include "ControlCAN.h" 然后,再将这个头文件放到工程的目录下 二.添加.lib文件 首先,将.l ...
- 依赖反转Ioc和unity,autofac,castle框架教程及比较
1.依赖倒置的相关概念 http://www.cnblogs.com/fuchongjundream/p/3873073.html IoC模式(依赖.依赖倒置.依赖注入.控制反转) 2.依赖倒置的方式 ...
- 为CSDN博客添加站内搜索栏目
栏目代码 <div id="panel_Search"> <img src="http://img.blog.csdn.net/201707190247 ...
- Keep On Movin (贪心)
#include<bits/stdc++.h> using namespace std; int main(){ int T, n, a;scanf("%d",& ...
- Azure Messaging-ServiceBus Messaging消息队列技术系列2-编程SDK入门
各位,上一篇基本概念和架构中,我们介绍了Window Azure ServiceBus的消息队列技术的概览.接下来,我们进入编程模式和详细功能介绍模式,一点一点把ServiceBus技术研究出来. 本 ...
- 【2017-2-26】C#String类、Math类、DateTime类
String类 黑色小扳手:属性 后面不带括号 紫色小箱子:方法 后面带小括号 1.字符串.Length; 字符串长度,返回int类型 字符串的长度 2.字符串.TrimSta ...
- Win10,Office2013出现“您的组织策略阻止我们为您完成此操作”怎么解决?
"Windows Registry Editor Version 5.00"这是Windows注册表编辑器5.00版的意思新建一个记事本文件,将以下代码直接复制到新建的文本文件中: ...
- Windows 7关闭睡眠(休眠)模式和删除休眠文件
原文地址:https://www.192ly.com/pc/win7/gb-sm.html 怎么关闭Windows 7关闭睡眠(休眠)功能?Windows 7系统中怎么删除休眠文件?Windows 7 ...