mirror of https://github.com/midoks/mdserver-web
parent
501012b4e6
commit
c4788c03f9
@ -1,47 +1,64 @@ |
|||||||
#!/bin/bash |
#!/bin/bash |
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin |
||||||
|
|
||||||
# for mac |
|
||||||
export PATH=$PATH:/opt/homebrew/bin |
export PATH=$PATH:/opt/homebrew/bin |
||||||
|
|
||||||
curPath=`pwd` |
curPath=`pwd` |
||||||
rootPath=$(dirname "$curPath") |
rootPath=$(dirname "$curPath") |
||||||
rootPath=$(dirname "$rootPath") |
rootPath=$(dirname "$rootPath") |
||||||
serverPath=$(dirname "$rootPath") |
serverPath=$(dirname "$rootPath") |
||||||
|
|
||||||
install_tmp=${rootPath}/tmp/mw_install.pl |
install_tmp=${rootPath}/tmp/mw_install.pl |
||||||
|
sys_os=`uname` |
||||||
|
VERSION=1.6.22 |
||||||
|
|
||||||
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/lvs && bash install.sh install 1.0 |
||||||
|
# cd /wwww/mdserver-web/plugins/lvs && bash install.sh install 1.0 |
||||||
|
|
||||||
action=$1 |
|
||||||
type=$2 |
|
||||||
|
|
||||||
echo $action $type |
Install_LVS(){ |
||||||
|
mkdir -p $serverPath/source |
||||||
|
# mkdir -p $serverPath/memcached |
||||||
|
echo '正在安装LVS...' |
||||||
|
|
||||||
|
# 检测平台命令 |
||||||
|
which apt |
||||||
|
if [ "$?" == "0" ];then |
||||||
|
apt install -y ipvsadm |
||||||
|
fi |
||||||
|
|
||||||
if [ "${2}" == "" ];then |
which yum |
||||||
echo '缺少安装脚本...' |
if [ "$?" == "0" ];then |
||||||
exit 0 |
yum install -y ipvsadm |
||||||
fi |
fi |
||||||
|
|
||||||
if [ ! -d $curPath/versions/$2 ];then |
if [ -d $serverPath/lvs ];then |
||||||
echo '缺少安装脚本2...' |
echo '1.6' > $serverPath/lvs/version.pl |
||||||
exit 0 |
echo '正在安装LVS成功!' |
||||||
fi |
|
||||||
|
|
||||||
if [ "${action}" == "uninstall" ];then |
cd ${rootPath} && python3 ${rootPath}/plugins/lvs/index.py start |
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/lvs/index.py initd_install |
||||||
if [ -f /usr/lib/systemd/system/haproxy.service ] || [ -f /lib/systemd/system/haproxy.service ];then |
|
||||||
systemctl stop haproxy |
|
||||||
systemctl disable haproxy |
|
||||||
rm -rf /usr/lib/systemd/system/haproxy.service |
|
||||||
rm -rf /lib/systemd/system/haproxy.service |
|
||||||
systemctl daemon-reload |
|
||||||
fi |
fi |
||||||
fi |
} |
||||||
|
|
||||||
|
Uninstall_LVS() |
||||||
|
{ |
||||||
|
|
||||||
sh -x $curPath/versions/$2/install.sh $1 |
# if [ -f /usr/lib/systemd/system/memcached.service ];then |
||||||
|
# systemctl stop memcached |
||||||
|
# systemctl disable memcached |
||||||
|
# rm -rf /usr/lib/systemd/system/memcached.service |
||||||
|
# systemctl daemon-reload |
||||||
|
# fi |
||||||
|
|
||||||
if [ "${action}" == "install" ] && [ -d $serverPath/haproxy ];then |
# if [ -f $serverPath/memcached/initd/memcached ];then |
||||||
#初始化 |
# $serverPath/memcached/initd/memcached stop |
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/haproxy/index.py start ${type} |
# fi |
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/haproxy/index.py initd_install ${type} |
echo "卸载LVS完成" |
||||||
|
} |
||||||
|
|
||||||
|
action=$1 |
||||||
|
if [ "${1}" == 'install' ];then |
||||||
|
Install_LVS |
||||||
|
else |
||||||
|
Uninstall_LVS |
||||||
fi |
fi |
||||||
|
@ -1,70 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
|
||||||
export PATH |
|
||||||
|
|
||||||
curPath=`pwd` |
|
||||||
rootPath=$(dirname "$curPath") |
|
||||||
rootPath=$(dirname "$rootPath") |
|
||||||
serverPath=$(dirname "$rootPath") |
|
||||||
sysName=`uname` |
|
||||||
|
|
||||||
install_tmp=${rootPath}/tmp/mw_install.pl |
|
||||||
|
|
||||||
|
|
||||||
bash ${rootPath}/scripts/getos.sh |
|
||||||
OSNAME=`cat ${rootPath}/data/osname.pl` |
|
||||||
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` |
|
||||||
|
|
||||||
|
|
||||||
VERSION=2.6.4 |
|
||||||
MIN_VERSION=2.6 |
|
||||||
Install_App() |
|
||||||
{ |
|
||||||
|
|
||||||
echo '正在安装脚本文件...' > $install_tmp |
|
||||||
mkdir -p $serverPath/haproxy |
|
||||||
|
|
||||||
APP_DIR=${serverPath}/source/haproxy |
|
||||||
mkdir -p $APP_DIR |
|
||||||
|
|
||||||
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then |
|
||||||
if [ $sysName == 'Darwin' ]; then |
|
||||||
wget --no-check-certificate -O ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz |
|
||||||
else |
|
||||||
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz |
|
||||||
fi |
|
||||||
fi |
|
||||||
|
|
||||||
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then |
|
||||||
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz |
|
||||||
fi |
|
||||||
|
|
||||||
|
|
||||||
cd ${APP_DIR} && tar -zxvf haproxy-${VERSION}.tar.gz |
|
||||||
|
|
||||||
if [ "$OSNAME" == "macos" ];then |
|
||||||
cd ${APP_DIR}/haproxy-${VERSION} && make TARGET=osx && make install PREFIX=$serverPath/haproxy |
|
||||||
else |
|
||||||
cd ${APP_DIR}/haproxy-${VERSION} && make TARGET=linux-glibc && make install PREFIX=$serverPath/haproxy |
|
||||||
fi |
|
||||||
|
|
||||||
echo $MIN_VERSION > $serverPath/haproxy/version.pl |
|
||||||
echo 'Install_HA' > $install_tmp |
|
||||||
} |
|
||||||
|
|
||||||
Uninstall_App() |
|
||||||
{ |
|
||||||
if [ -f $serverPath/haproxy/initd/haproxy ];then |
|
||||||
$serverPath/haproxy/initd/haproxy stop |
|
||||||
fi |
|
||||||
|
|
||||||
rm -rf $serverPath/haproxy |
|
||||||
echo "Uninstall_HA" > $install_tmp |
|
||||||
} |
|
||||||
|
|
||||||
action=$1 |
|
||||||
if [ "${1}" == 'install' ];then |
|
||||||
Install_App |
|
||||||
else |
|
||||||
Uninstall_App |
|
||||||
fi |
|
Loading…
Reference in new issue