#!/bin/bash export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh) if [ $? -ne 0 ]; then echo "Download public.sh failed, please check the network or try again later." exit 1 fi channel=${1} version=${2} memcached_path="${setup_path}/server/memcached" if ! id -u "memcached" >/dev/null 2>&1; then groupadd memcached useradd -s /sbin/nologin -g memcached memcached fi # 安装依赖 if [ ${OS} == "rhel" ]; then dnf makecache -y dnf groupinstall "Development Tools" -y dnf install openssl-devel cyrus-sasl cyrus-sasl-devel libevent-devel -y elif [ ${OS} == "debian" ] || [ ${OS} == "ubuntu" ]; then apt-get update apt-get install build-essential libssl-dev libsasl2-2 libsasl2-dev libevent-dev -y else error "Unsupported operating system" fi if [ "$?" != "0" ]; then error "Failed to install dependencies" fi # 准备目录 rm -rf ${memcached_path} mkdir -p ${memcached_path} cd ${memcached_path} # 下载源码 dl "${memcached_path}" "/memcached/memcached-${version}.tar.gz" tar -zxvf memcached-${version}.tar.gz rm -f memcached-${version}.tar.gz mv memcached-${version} src cd src chmod +x configure ./configure --prefix=${memcached_path} --enable-tls --enable-sasl --enable-sasl-pwdb --enable-64bit if [ "$?" != "0" ]; then rm -rf ${memcached_path} error "Configuration failed" fi make -j${CORES} if [ "$?" != "0" ]; then rm -rf ${memcached_path} error "Compilation failed" fi make install if [ ! -f "${memcached_path}/bin/memcached" ]; then rm -rf ${memcached_path} error "Installation failed" fi chown -R memcached:memcached ${memcached_path} chmod -R 700 ${memcached_path} # 设置服务 cat >/etc/systemd/system/memcached.service <