mdserver-web/plugins/memcached/install.sh

76 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2018-11-25 03:46:23 -05:00
#!/bin/bash
2023-11-08 12:32:59 -05:00
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
2023-11-09 16:01:06 -05:00
export PATH=$PATH:/opt/homebrew/bin
2018-11-25 03:46:23 -05:00
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
2023-11-08 12:32:59 -05:00
sys_os=`uname`
2025-08-18 12:57:06 -04:00
VERSION=1.6.39
2018-11-25 03:46:23 -05:00
2023-11-08 12:32:59 -05:00
echo $sys_os
2019-03-15 04:45:15 -04:00
Install_mem(){
2018-12-07 02:55:12 -05:00
mkdir -p $serverPath/source
2024-07-28 23:49:33 -04:00
mkdir -p $serverPath/source/memcached
2024-11-30 08:44:09 -05:00
echo '正在安装脚本文件...'
2018-11-25 03:46:23 -05:00
2018-12-08 22:42:11 -05:00
if [ ! -f $serverPath/source/memcached.tar.gz ];then
2025-08-18 12:57:06 -04:00
wget --no-check-certificate -O $serverPath/source/memcached/memcached.tar.gz https://www.memcached.org/files/memcached-${VERSION}.tar.gz
2019-03-15 04:45:15 -04:00
fi
2018-12-08 22:42:11 -05:00
2024-07-28 23:48:15 -04:00
cd $serverPath/source/memcached && tar -zxvf memcached.tar.gz
2018-11-25 03:46:23 -05:00
2023-11-08 12:32:59 -05:00
OPTIONS=''
if [ ${sys_os} == "Darwin" ]; then
LIB_DEPEND_DIR=`brew info libevent | grep /opt/homebrew/Cellar/libevent | cut -d \ -f 1 | awk 'END {print}'`
OPTIONS="${OPTIONS} --with-libevent=${LIB_DEPEND_DIR}"
fi
2022-06-12 22:29:15 -04:00
echo "./configure --prefix=${serverPath}/memcached && make && make install"
2024-07-28 23:48:15 -04:00
cd $serverPath/source/memcached/memcached-${VERSION}
2023-11-08 12:32:59 -05:00
./configure --prefix=$serverPath/memcached \
$OPTIONS
make && make install
2018-11-25 03:46:23 -05:00
2022-06-28 21:05:41 -04:00
if [ -d $serverPath/memcached ];then
echo '1.6' > $serverPath/memcached/version.pl
2024-07-28 23:52:15 -04:00
echo '安装memcached成功'
2022-06-28 21:05:41 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/memcached/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/memcached/index.py initd_install
2023-10-30 12:53:35 -04:00
2024-07-28 23:48:15 -04:00
rm -rf $serverPath/source/memcached/memcached-${VERSION}
2022-06-28 21:05:41 -04:00
fi
2018-11-25 03:46:23 -05:00
}
Uninstall_mem()
{
2022-06-28 21:05:41 -04:00
2022-07-03 10:22:03 -04:00
if [ -f /usr/lib/systemd/system/memcached.service ];then
2022-06-28 21:05:41 -04:00
systemctl stop memcached
systemctl disable memcached
2022-07-03 10:22:03 -04:00
rm -rf /usr/lib/systemd/system/memcached.service
2022-06-28 21:05:41 -04:00
systemctl daemon-reload
fi
if [ -f $serverPath/memcached/initd/memcached ];then
$serverPath/memcached/initd/memcached stop
fi
2019-03-15 04:45:15 -04:00
rm -rf $serverPath/memcached
2024-07-28 23:52:15 -04:00
echo '卸载memcached成功'
2018-11-25 03:46:23 -05:00
}
2022-07-03 10:42:29 -04:00
# /www/server/memcached/bin/memcached -d -p 11211 -u root -m 100 -c 100
2018-11-25 03:46:23 -05:00
action=$1
if [ "${1}" == 'install' ];then
Install_mem
else
Uninstall_mem
fi