keepalived一键安装脚本

#!/bin/bash
#author:wengshiqiang
#date:2022-05-04
DIR="`pwd`"
PACKAGE="keepalived-2.2.4.tar.gz"
VERSION="keepalived-2.2.4"
URL="https://www.keepalived.org/software/${PACKAGE}"
DATE="/apps/keepalived"
function install_system_package(){
  grep "Ubuntu" /etc/issue &> /dev/null
  if [ $? -eq 0 ];then
    apt update
    apt  install iproute2  ntpdate make  tcpdump telnet traceroute nfs-kernel-server nfs-common  lrzsz tree  openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute  gcc openssh-server lrzsz tree  openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip  libreadline-dev libsystemd-dev -y
  fi

  grep "Kernel" /etc/issue &> /dev/null
  if [ $? -eq 0 ];then 
    yum install  vim iotop bc gcc gcc-c++ glibc glibc-devel pcre  pcre-devel openssl  openssl-devel zip unzip zlib-devel  net-tools lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel bc  systemd-devel bash-completion traceroute psmisc -y
  fi
}
function install_keepalived(){
  if -d /etc/keepalived;then
    echo "keepalived 已经安装,即将退出安装过程!"
  else
    mkdir -p /etc/keepalived
    if [ -f ${PACKAGE} ];then
      echo "${PACKAG} 安装包已存在"
    else
      cd ${DIR}
      wget --no-check-certificate  ${URL}
    fi 
    tar xvf ${PACKAGE}
    cd  ${VERSION} && ./configure --prefix=/apps/keepalived && make && make install
    mkdir -p /etc/keepalived
    cp -a /apps/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
    systemctl start keepalived.service  
    systemctl enable keepalived.service
    if [ $? -eq 0 ];then
      echo " ${VERSION} 安装成功!" && echo "即将退出安装过程!" && sleep 1
    else 
      echo " ${VERSION} 安装失败!" && echo "即将退出安装过程!" && sleep 1
    fi
  fi
}
main (){
   install_system_package
   install_keepalived
}
main
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值