#!/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
keepalived一键安装脚本
最新推荐文章于 2023-04-26 21:30:00 发布