install-escheduler-ui.sh 5.8 KB
Newer Older
G
gongzijian 已提交
1
#!/bin/bash
2
# current path
D
dailidong 已提交
3 4
esc_basepath=$(cd `dirname $0`; pwd)

5 6 7
menu(){
        cat <<END
=================================================
8 9 10 11
        1.CentOS6 Installation
        2.CentOS7 Installation
        3.Ubuntu Installation
        4.Exit
12 13 14
=================================================
END
}
G
gongzijian 已提交
15 16


17 18
# create a file and configure nginx
dolphinschedulerConf(){
G
gongzijian 已提交
19

G
gongzijian 已提交
20 21 22 23 24 25
    E_host='$host'
    E_remote_addr='$remote_addr'
    E_proxy_add_x_forwarded_for='$proxy_add_x_forwarded_for'
    E_http_upgrade='$http_upgrade'
    echo "
        server {
26
            listen       $1;# access port
G
gongzijian 已提交
27 28 29 30
            server_name  localhost;
            #charset koi8-r;
            #access_log  /var/log/nginx/host.access.log  main;
            location / {
31
            root   ${esc_basepath}/dist; # static file directory
G
gongzijian 已提交
32 33 34
            index  index.html index.html;
            }
            location /escheduler {
35
            proxy_pass $2; # interface address
G
gongzijian 已提交
36 37 38 39 40 41
            proxy_set_header Host $E_host;
            proxy_set_header X-Real-IP $E_remote_addr;
            proxy_set_header x_real_ipP $E_remote_addr;
            proxy_set_header remote_addr $E_remote_addr;
            proxy_set_header X-Forwarded-For $E_proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
Q
qiaozhanwei 已提交
42 43 44
            proxy_connect_timeout 300s;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
G
gongzijian 已提交
45 46 47 48 49 50 51 52 53 54 55
            proxy_set_header Upgrade $E_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;
            }
        }
56
    " >> /etc/nginx/conf.d/dolphinscheduler.conf
G
gongzijian 已提交
57 58 59

}

60
ubuntu(){
61
    # update source
62 63
    apt-get update

64
    # install nginx
65 66
    apt-get install -y nginx

67 68
    # config nginx
    dolphinschedulerConf $1 $2
69

70
    # startup nginx
71 72 73 74 75 76 77
    /etc/init.d/nginx start
    sleep 1
    if [ $? -ne 0 ];then
        /etc/init.d/nginx start
    fi
    nginx -s reload
}
G
gongzijian 已提交
78 79

centos7(){
80 81 82

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    yum install -y nginx
G
gongzijian 已提交
83

84 85
    # config nginx
    dolphinschedulerConf $1 $2
G
gongzijian 已提交
86

87
    # solve 0.0.0.0:8888 problem
G
gongzijian 已提交
88 89
    yum -y install policycoreutils-python
    semanage port -a -t http_port_t -p tcp $esc_proxy
G
gongzijian 已提交
90

91
    # open front access port
G
gongzijian 已提交
92
    firewall-cmd --zone=public --add-port=$esc_proxy/tcp --permanent
G
gongzijian 已提交
93

94
    # startup nginx
G
gongzijian 已提交
95
    systemctl start nginx
96 97 98 99 100
    sleep 1
    if [ $? -ne 0 ];then
        systemctl start nginx
    fi
    nginx -s reload
G
gongzijian 已提交
101

102
    # set SELinux parameters
G
gongzijian 已提交
103
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
104
    # temporary effect
G
gongzijian 已提交
105
    setenforce 0
G
gongzijian 已提交
106 107 108 109 110

}


centos6(){
111 112

    rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
G
gongzijian 已提交
113 114 115 116

    # install nginx
    yum install nginx -y

117 118
    # config nginx
    dolphinschedulerConf $1 $2
G
gongzijian 已提交
119

120
    # startup nginx
G
gongzijian 已提交
121
    /etc/init.d/nginx start
122 123 124 125 126
    sleep 1
	if [ $? -ne 0 ];then
        /etc/init.d/nginx start
    fi
    nginx -s reload
G
gongzijian 已提交
127

128
    # set SELinux parameters
G
gongzijian 已提交
129 130
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

131
    # temporary effect
G
gongzijian 已提交
132
    setenforce 0
G
gongzijian 已提交
133 134 135

}

136
function main(){
137 138
	echo "Welcome to thedolphinscheduler front-end deployment script, which is currently only supported by front-end deployment scripts : CentOS and Ubuntu"
	echo "Please execute in the dolphinscheduler-ui directory"
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

	#To be compatible with MacOS and Linux
	if [[ "$OSTYPE" == "darwin"* ]]; then
    		# Mac OSX
    		echo "Easy Scheduler ui 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 "Easy Scheduler ui not support Windows operating system"
    		exit 1
	elif [[ "$OSTYPE" == "msys" ]]; then
    		# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
    		echo "Easy Scheduler ui not support Windows operating system"
    		exit 1
	elif [[ "$OSTYPE" == "win32" ]]; then
    		echo "Easy Scheduler ui 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


169 170
	# config front-end access ports
	read -p "Please enter the nginx proxy port, do not enter, the default is 8888 :" esc_proxy_port
171 172 173 174
	if [ -z "${esc_proxy_port}" ];then
    	esc_proxy_port="8888"
	fi

175
	read -p "Please enter the api server proxy ip, you must enter, for example: 192.168.xx.xx :" esc_api_server_ip
176
	if [ -z "${esc_api_server_ip}" ];then
177
		echo "api server proxy ip can not be empty."
178 179 180
		exit 1
	fi

181
	read -p "Please enter the api server proxy port, do not enter, the default is 12345:" esc_api_server_port
182 183 184 185
	if [ -z "${esc_api_server_port}" ];then
		esc_api_server_port="12345"
	fi

186
	# api server backend address
187 188
	esc_api_server="http://$esc_api_server_ip:$esc_api_server_port"

189
	# local ip address
190 191
	esc_ipaddr=$(ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2 | head -n 1 | awk -F '/' '{print $1}')

192
	# Prompt message
193 194
	menu

195
	read -p "Please enter the installation number(1|2|3|4):" num
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214

   	case $num in
        	1)
			centos6 ${esc_proxy_port} ${esc_api_server}
                	;;
       		2)
                	centos7 ${esc_proxy_port} ${esc_api_server}
                	;;
        	3)
			ubuntu ${esc_proxy_port} ${esc_api_server}
                	;;
		4)
			echo $"Usage :sh $0"
                	exit 1
			;;
        	*)
                	echo $"Usage :sh $0"
                	exit 1
	esac
215
	echo "Please visit the browser:http://${esc_ipaddr}:${esc_proxy_port}"
G
gongzijian 已提交
216

217
}
G
gongzijian 已提交
218

219
main