代码拉取完成,页面将自动刷新
同步操作将从 WeBank/Scriptis 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
# 当前路径
workDir=$(cd `dirname $0`; pwd)
echo "Scriptis front-end deployment script"
source $workDir/config.sh
# 前端放置目录,默认为解压目录
scriptis_basepath=$workDir
#To be compatible with MacOS and Linux
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
echo "scriptis install not support Mac OSX operating system"
exit 1
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
# linux
echo "linux"
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
echo "scriptis not support Windows operating system"
exit 1
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
echo "scriptis not support Windows operating system"
exit 1
elif [[ "$OSTYPE" == "win32" ]]; then
echo "scriptis not support Windows operating system"
exit 1
elif [[ "$OSTYPE" == "freebsd"* ]]; then
# ...
echo "freebsd"
else
# Unknown.
echo "Operating system unknown, please tell us(submit issue) for better service"
exit 1
fi
# 区分版本
version=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`
echo "========================================================================配置信息======================================================================="
echo "前端访问端口:${scriptis_port}"
echo "后端Linkis的地址:${linkis_url}"
echo "静态文件地址:${scriptis_basepath}/dist"
echo "当前路径:${workDir}"
echo "本机ip:${scriptis_ipaddr}"
echo "========================================================================配置信息======================================================================="
echo ""
# 创建文件并配置nginx
scriptiConf(){
s_host='$host'
s_remote_addr='$remote_addr'
s_proxy_add_x_forwarded_for='$proxy_add_x_forwarded_for'
s_http_upgrade='$http_upgrade'
echo "
server {
listen $scriptis_port;# 访问端口
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root ${scriptis_basepath}/dist; # 静态文件目录
index index.html index.html;
}
location /ws {
proxy_pass $linkis_url;#后端Linkis的地址
proxy_http_version 1.1;
proxy_set_header Upgrade $s_http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api {
proxy_pass $linkis_url; #后端Linkis的地址
proxy_set_header Host $s_host;
proxy_set_header X-Real-IP $s_remote_addr;
proxy_set_header x_real_ipP $s_remote_addr;
proxy_set_header remote_addr $s_remote_addr;
proxy_set_header X-Forwarded-For $s_proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_connect_timeout 4s;
proxy_read_timeout 600s;
proxy_send_timeout 12s;
proxy_set_header Upgrade $s_http_upgrade;
proxy_set_header Connection upgrade;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
" > /etc/nginx/conf.d/scriptis.conf
}
centos7(){
# nginx是否安装
#sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install -y nginx
echo "nginx 安装成功"
# 配置nginx
scriptiConf
# 解决 0.0.0.0:8888 问题
yum -y install policycoreutils-python
semanage port -a -t http_port_t -p tcp $scriptis_port
# 开放前端访问端口
firewall-cmd --zone=public --add-port=$scriptis_port/tcp --permanent
# 重启防火墙
firewall-cmd --reload
# 启动nginx
systemctl restart nginx
# 调整SELinux的参数
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# 临时生效
setenforce 0
}
centos6(){
# yum
S_basearch='$basearch'
S_releasever='$releasever'
echo "
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$E_releasever/$S_basearch/
gpgcheck=0
enabled=1
" >> /etc/yum.repos.d/nginx.repo
# install nginx
yum install nginx -y
# 配置nginx
scriptiConf
# 防火墙
S_iptables=`lsof -i:$scriptis_port | wc -l`
if [ "$S_iptables" -gt "0" ];then
# 已开启端口防火墙重启
service iptables restart
else
# 未开启防火墙添加端口再重启
iptables -I INPUT 5 -i eth0 -p tcp --dport $scriptis_port -m state --state NEW,ESTABLISHED -j ACCEPT
service iptables save
service iptables restart
fi
# start
/etc/init.d/nginx start
# 调整SELinux的参数
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# 临时生效
setenforce 0
}
# centos 6
if [[ $version -eq 6 ]]; then
centos6
fi
# centos 7
if [[ $version -eq 7 ]]; then
centos7
fi
echo "请浏览器访问:http://${scriptis_ipaddr}:${scriptis_port}"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。