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
原文地址:http://yujianglei.blog.51cto.com/7215578/1725586