#!/bin/bash
#############
#Date 2022/6/28
#mail it-arch
#############
echo "##########################################"
echo "Auto Install memcached                  ##"
echo "Press Ctrl + C to cancel                ##"
echo "Any key to continue                     ##"
echo "##########################################"
read -n 1
/etc/init.d/iptables status >/dev/null 2>&1
if [ $? -eq 0 ]
then
iptables -I INPUT -p tcp --dport 11211 -j ACCEPT && 
iptables-save >/dev/null 2>&1
else
    echo -e "\033[32m iptables is stopd\033[0m"
fi
sed -i "s/SELINUX=enforcing/SELINUX=disabled/"  /etc/selinux/config
setenforce 0
################################
if [ -d /tools ];then
    cd /tools
else
    mkdir /tools && cd /tools
fi
yum -y install wget gcc libevent libevent-devel
yum groupinstall "Development tools" -y
wget -c -O /tools/memcached http://memcached.org/files/memcached-1.4.31.tar.gz
tar -zxvf memcached
cd  memcached-1.4.31
./configure
make
make install
/usr/local/bin/memcached -d -u root
echo -e "\033[32m Memcache install success\033[0m"
netstat -lntup | grep memcached
