码迷,mamicode.com
首页 > 其他好文 > 详细

自动化安装keepalived-1.2.4

时间:2015-12-17 14:28:45      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:keepalived install

keepalived-1.2.4_auto_install.sh
#!/bin/bash
Install_dir="/usr/local/keepalived"
Download_dir="/home/tools"
Keepalived_Major_Version="1.2"
Keepalived_Minor_Version="7"
kernels_Vserion=`uname  -r`
keepalived_conf="/etc/keepalived"
check_result(){
    if [ $1 != 0 ];then
        echo -e "\e[1,44m  <==== Error,Exit install keepalived ====> \e[0m"
        exit 1
    fi
}
install_or_not(){
    read -p "Install nginx, Input Y ; Do not install  nginx,Input N:" INSTALL_OR_NOT
    case $INSTALL_OR_NOT in
    Y|y)
        install
    ;;
    N|n)
        echo -e "\e[0;44m <====Stop  install  keepalived====> \e[0m"
        exit 1
    ;;
    *)
        echo -e "\e[1;44m  Only Input  Y or N  \e[0m"
        install_or_not
    ;;
    esac
}
root_or_not(){
if [ `id -u` != 0 ] ; then
    echo -e "\e[1;44m  <====You are not root,Please login in root!====> \e[0m"
    exit 1
fi
}
install_develop_tools(){
    yum  install gcc  gcc-c++   openssl openssl-devel  wget  unzip man -y
    check_result $?
}
install_popt(){
    [ ! -d ${Download_dir} ] && mkdir ${Download_dir}
    wget  http://rpm5.org/files/popt/popt-1.14.tar.gz  -P   ${Download_dir}
    cd   ${Download_dir}  &&  tar xf  popt-1.14.tar.gz 
    check_result  $?
    cd  ${Download_dir}/popt-1.14  &&  ./configure
    check_result  $?
    cd  ${Download_dir}/popt-1.14  &&  make  
    check_result  $?
    cd  ${Download_dir}/popt-1.14  &&  make  install
    check_result  $?
    ln -s /usr/src/kernels/$(uname -r) /usr/src/kernels/linux
}
install_keepalived(){
    [ ! -d ${Download_dir} ] && mkdir ${Download_dir}
    wget http://www.keepalived.org/software/keepalived-${Keepalived_Major_Version}.${Keepalived_Minor_Version}.tar.gz  -P ${Download_dir}
    check_result  $?
    cd ${Download_dir}  && tar xf keepalived-${Keepalived_Major_Version}.${Keepalived_Minor_Version}.tar.gz 
    check_result  $?
    cd ${Download_dir}/keepalived-${Keepalived_Major_Version}.${Keepalived_Minor_Version}  
    ./configure --prefix=${Install_dir}     --with-kernel-dir=/usr/src/kernels/${kernels_Vserion}
    check_result  $?
    make
    check_result  $?
    make  install
    check_result  $?
    cp  ${Install_dir}/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
    check_result  $?
    cp  ${Install_dir}/etc/sysconfig/keepalived /etc/sysconfig/
    check_result  $?
    [ ! -d ${keepalived_conf} ] &&  mkdir ${keepalived_conf}
    cp  ${Install_dir}/etc/keepalived/keepalived.conf ${keepalived_conf}
    check_result  $?
    cp  ${Install_dir}/sbin/keepalived /usr/sbin/
    check_result  $?
    chkconfig  --add  keepalived
    check_result  $?
    chkconfig  --level 345  keepalived  on
}
install(){
    install_develop_tools
    install_popt
    install_keepalived
}
root_or_not
install_or_not

本文出自 “不求最好,只求更好” 博客,请务必保留此出处http://yujianglei.blog.51cto.com/7215578/1725586

自动化安装keepalived-1.2.4

标签:keepalived install

原文地址:http://yujianglei.blog.51cto.com/7215578/1725586

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!