65 lines
1.5 KiB
Bash
65 lines
1.5 KiB
Bash
#!/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"
|
|
|
|
# 预检查
|
|
systemctl is-active --quiet memcached
|
|
if [ "$?" != "0" ]; then
|
|
error "Application is not running properly"
|
|
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
|
|
|
|
# 停止已有服务
|
|
systemctl stop memcached
|
|
|
|
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}
|
|
|
|
systemctl daemon-reload
|
|
systemctl start memcached
|
|
|
|
acepanel app write memcached ${channel} ${version}
|
|
|
|
echo -e $HR
|
|
echo "Upgrade successful"
|
|
echo -e $HR
|