代码拉取完成,页面将自动刷新
同步操作将从 K./ubuntu-server-deploy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env bash
source ./init.sh
mc_install() {
apt-get install memcached -y
mc_mk_config
}
mc_mk_config() {
local savefile=/etc/memcached.conf
if [ -f ${savefile} ]; then
rm ${savefile} -f
fi
local tpl=${CUR_DIR}/memcached/memcached.conf.tpl
IFS=""
local data=$(read_file ${tpl})
data=${data//\#LOG_FILE\#/${MC_LOG_FILE}}
data=${data//\#MEM_SIZE\#/${MC_SIZE}}
data=${data//\#PORT\#/${MC_PORT}}
data=${data//\#HOST\#/${MC_HOST}}
data=${data//\#USER\#/${MC_USER}}
echo ${data} > ${savefile}
if [ -f ${savefile} ]; then
echo "Create ${savefile} success!"
return 0
else
echo "Create ${savefile} lost!"
return 1
fi
}
mcr_double_conv_install() {
## first double conv
local workdir=${PREFIX_HOME}
cd ${workdir}
if [ ! -d /usr/include/double-conversion ]; then
git clone ${MCR_DOUBLE_CONV_SOURCE}
cd "${workdir}/double-conversion"
scons prefix="${MCR_DOUBLE_CONV_INSTALL_DIR}" install
# Folly looks for double-conversion/double-conversion.h
ln -sf src double-conversion
export LDFLAGS="-L${MCR_DOUBLE_CONV_INSTALL_DIR}/lib -L${workdir}/double-conversion -ldl"
export CPPFLAGS="-I${MCR_DOUBLE_CONV_INSTALL_DIR}/include -I${workdir}/double-conversion"
fi
}
folly_build() {
local rebuild=0
local workdir=${PREFIX_HOME}/facebook
local PKG_DIR=${workdir}
local INSTALL_DIR=${PREFIX_HOME}/double-conversion
local needclean=0
if [ ! -d ${workdir} ]; then
mkdir ${workdir}
fi
cd ${workdir}
if [ -n "${1}" ]; then
rebuild=1
fi
if [[ ${rebuild} -gt 0 || ! -d /usr/local/include/folly ]]; then
apt-get install -y ${MCR_FOLLY_REQ_PKGS}
fi
if [ -d "${workdir}/folly" ]; then
needclean=1
else
git clone ${MCR_FOLLY_SOURCE}
fi
if [ ! -d /usr/include/double-conversion ]; then
git clone ${MCR_DOUBLE_CONV_SOURCE}
cd "$PKG_DIR/double-conversion/"
scons prefix="$INSTALL_DIR" install
# Folly looks for double-conversion/double-conversion.h
ln -sf src double-conversion
export LDFLAGS="-L$INSTALL_DIR/lib -L$PKG_DIR/double-conversion -ldl"
export CPPFLAGS="-I$INSTALL_DIR/include -I$PKG_DIR/double-conversion"
fi
if [[ ${rebuild} -gt 0 || ! -d /usr/local/include/folly ]]; then
cd "$PKG_DIR/folly/folly/"
if [ ${needclean} -gt 0 ]; then
make clean
fi
autoreconf -ivf
./configure
make
make install
fi
}
mcr_fb_install() {
if [ ! -n "${MCR_POOL_SERVERS}" ]; then
echo "Undefined MCR_POOL_SERVERS!"
return 1
fi
local rebuild=0
local workdir=${PREFIX_HOME}/facebook
local installdir=${PREFIX_HOME}/mcrouter
if [ ! -d ${workdir} ]; then
mkdir ${workdir}
fi
cd ${workdir}
if [ -n "${1}" ]; then
rebuild=1
fi
if [ ! -d "${workdir}/mcrouter" ]; then
git clone ${MCR_SOURCE}
fi
if [[ ${rebuild} -gt 0 || ! -f /usr/local/bin/mcrouter ]]; then
cd "${workdir}/mcrouter/mcrouter"
./scripts/install_ubuntu_14.04.sh ${installdir}
fi
if [ ! -f /usr/local/bin/mcrouter ]; then
echo "facebook/msrouter install fail! Please check!"
else
mcr_mk_config
mcr_mk_script
fi
}
mcr_install() {
if [ ! -n "${MCR_POOL_SERVERS}" ]; then
echo "Undefined MCR_POOL_SERVERS!"
return 1
fi
local rebuild=0
local workdir=${PREFIX_HOME}/facebook
local PKG_DIR=${workdir}
local INSTALL_DIR=${PREFIX_HOME}/double-conversion
if [ ! -d ${workdir} ]; then
mkdir ${workdir}
fi
cd ${workdir}
if [ -n "${1}" ]; then
rebuild=1
fi
folly_build $1
if [[ ${rebuild} -gt 0 || ! -f /usr/local/bin/mcrouter ]]; then
apt-get install -y ${MCR_REQ_PKGS}
cd "$PKG_DIR/mcrouter/mcrouter/"
autoreconf --install
./configure
make
make install
fi
if [ ! -f /usr/local/bin/mcrouter ]; then
echo "facebook/msrouter install fail! Please check!"
else
mcr_mk_config
mcr_mk_script
fi
}
mcr_mk_config() {
if [ ! -n "${MCR_POOL_SERVERS}" ]; then
echo "Undefined MCR_POOL_SERVERS!"
return 1
fi
local savefile=${MCR_CONF_FILE}
local tpl=${CUR_DIR}/memcached/mcrouter.json.tpl
IFS=""
local data=$(read_file ${tpl})
data=${data//\#SERVERS\#/${MCR_POOL_SERVERS}}
echo ${data} > ${savefile}
if [ -f ${savefile} ]; then
echo "Create ${savefile} success!"
return 0
else
echo "Create ${savefile} lost!"
return 1
fi
}
mcr_mk_script() {
local savefile=/etc/init.d/mcrouter
local tpl=${CUR_DIR}/memcached/mcrouter.sh.tpl
IFS=""
local data=$(read_file ${tpl})
data=${data//\#PORT\#/${MCR_PORT}}
data=${data//\#CONF_FILE\#/${MCR_CONF_FILE}}
data=${data//\#LOG_FILE\#/${MCR_LOG_FILE}}
data=${data//\#PID_FILE\#/${MCR_PID_FILE}}
echo ${data} > ${savefile}
chmod +x ${savefile}
if [ -f ${savefile} ]; then
echo "Create ${savefile} success!"
return 0
else
echo "Create ${savefile} lost!"
return 1
fi
}
case "$1" in
install)
mc_install
;;
conf)
mc_mk_config
;;
mcr-install)
mcr_install
;;
mcr-fb-build)
mcr_fb_install $2
;;
mcr-build)
mcr_install $2
;;
mcr-conf)
mcr_mk_config
;;
mcr-script|mcr-sh)
mcr_mk_script
;;
*)
echo "./mc.sh {install|conf|mcr-install|mcr-fb-build|mcr-build|mcr-conf|mcr-script|mcr-sh}"
;;
esac
on_tail
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。