mdserver-web/plugins/openresty/install.sh

87 lines
2.2 KiB
Bash
Raw Normal View History

2018-11-25 04:48:48 -05:00
#!/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")
2018-12-04 22:01:25 -05:00
action=$1
type=$2
2018-11-25 04:48:48 -05:00
2020-06-28 01:44:38 -04:00
VERSION=$2
install_tmp=${rootPath}/tmp/mw_install.pl
openrestyDir=${serverPath}/source/openresty
2019-02-02 09:13:51 -05:00
if id www &> /dev/null ;then
echo "www UID is `id -u www`"
echo "www Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
else
groupadd www
2020-09-28 00:52:11 -04:00
# useradd -g www -s /sbin/nologin www
useradd -g www -s /bin/bash www
2019-02-02 09:13:51 -05:00
fi
2022-06-22 08:34:02 -04:00
# cd /www/server/mdserver-web/plugins/openresty && /bin/bash install.sh install 1.21.4.1
2020-06-28 01:44:38 -04:00
Install_openresty()
{
mkdir -p ${openrestyDir}
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
wget -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz
fi
cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz
2020-07-13 20:38:10 -04:00
# --with-openssl=$serverPath/source/lib/openssl-1.0.2q
2022-06-22 12:48:52 -04:00
cd ${openrestyDir}/openresty-${VERSION} && ./configure \
--prefix=$serverPath/openresty \
2020-06-28 01:44:38 -04:00
--with-http_v2_module \
2020-07-13 20:38:10 -04:00
--with-http_ssl_module \
2021-01-12 00:13:30 -05:00
--with-http_slice_module \
2022-06-22 12:48:52 -04:00
--with-http_stub_status_module
2022-06-22 08:46:10 -04:00
2022-06-23 01:42:31 -04:00
make && make install && make clean
2022-06-22 08:46:10 -04:00
2022-06-22 12:48:52 -04:00
if [ -d $serverPath/openresty ];then
echo "${VERSION}" > $serverPath/openresty/version.pl
2022-06-29 22:51:54 -04:00
mkdir -p $serverPath/web_conf/php/conf
2022-07-04 21:04:14 -04:00
echo 'set $PHP_ENV 0;' > $serverPath/web_conf/php/conf/enable-php-00.conf
2022-06-28 13:07:25 -04:00
#初始化
2022-06-28 13:31:34 -04:00
cd ${rootPath} && python3 ${rootPath}/plugins/openresty/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/openresty/index.py initd_install
2022-06-22 12:48:52 -04:00
fi
2020-06-28 01:44:38 -04:00
echo '安装完成' > $install_tmp
}
Uninstall_openresty()
{
2022-06-28 13:07:25 -04:00
2022-07-11 03:19:39 -04:00
if [ -f /usr/lib/systemd/system/openresty.service ] || [ -f /lib/systemd/system/openresty.service ];then
2022-06-28 13:07:25 -04:00
systemctl stop openresty
2022-07-03 10:08:21 -04:00
rm -rf /usr/systemd/system/openresty.service
2022-07-11 03:19:39 -04:00
rm -rf /lib/systemd/system/openresty.service
2022-06-28 13:31:34 -04:00
systemctl daemon-reload
fi
if [ -f $serverPath/openresty/init.d/openresty ];then
$serverPath/openresty/init.d/openresty stop
2022-06-18 03:44:17 -04:00
fi
2022-06-28 13:07:25 -04:00
rm -rf $serverPath/openresty
2020-06-28 01:44:38 -04:00
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_openresty
else
Uninstall_openresty
fi