#cnetos系统编译安装haproxy
#需要依赖lua库,官网:http://www.lua.org
#harpoxy 官网下载:http://www.haproxy.org/download/
DIR=pwd
file_lua=“lua-5.4.3”
file_haproxy=“haproxy-2.2.11”
suffix=".tar.gz"
lua_install_dir=/usr/local/src
haproxy_install_dir=/apps/haproxy
tar_dir=/usr/local/src
local_ip=ifconfig | grep 'netmask' | head -n1 |awk '{print $2}'
#主机的ip地址
port=9999 #定义状态页监听端口
check(){
echo “正在安装环境包,请勿退出!”
yum install -y make vim wget libtermcap-devel ncurses-devel libevent-devel readline-devel gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel net-tools iotop zip unzip zlib-devel lrzsz tree lsof tcpdump systemd-devel
[ -f D I R / {DIR}/ DIR/{file_lua}KaTeX parse error: Expected '}', got 'EOF' at end of input: …} ] || { echo "{lua_file}${suffix} is not find" ; exit 1; }
[ -f D I R / {DIR}/ DIR/{file_haproxy}KaTeX parse error: Expected '}', got 'EOF' at end of input: …} ] || { echo "{lua_haproxy}${suffix} is not find" ; exit 1; }
if ! id haproxy &>/dev/null ;then
useradd -s /sbin/nologin -r haproxy
else
echo “haproxy用户已存在,略过用户创建!”
fi
[ -d ${lua_install_dir} ] || mkdir -p ${lua_install_dir}
}
install_lua(){
tar xf D I R / {DIR}/ DIR/{file_lua}${suffix} -C ${lua_install_dir}
cd l u a i n s t a l l d i r / {lua_install_dir}/ luainstalldir/{file_lua}
make all test
if [ $? -eq 0 ];then
l u a