install-dolphinscheduler-ui.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #!/bin/bash
  16. # current path
  17. esc_basepath=$(cd `dirname $0`; pwd)
  18. menu(){
  19. cat <<END
  20. =================================================
  21. 1.CentOS6 Installation
  22. 2.CentOS7 Installation
  23. 3.Ubuntu Installation
  24. 4.Exit
  25. =================================================
  26. END
  27. }
  28. # create a file and configure nginx
  29. dolphinschedulerConf(){
  30. E_host='$host'
  31. E_remote_addr='$remote_addr'
  32. E_proxy_add_x_forwarded_for='$proxy_add_x_forwarded_for'
  33. E_http_upgrade='$http_upgrade'
  34. echo "
  35. server {
  36. listen $1;# access port
  37. server_name localhost;
  38. #charset koi8-r;
  39. #access_log /var/log/nginx/host.access.log main;
  40. location / {
  41. root ${esc_basepath}/dist; # static file directory
  42. index index.html index.html;
  43. }
  44. location /dolphinscheduler {
  45. proxy_pass $2; # interface address
  46. proxy_set_header Host $E_host;
  47. proxy_set_header X-Real-IP $E_remote_addr;
  48. proxy_set_header x_real_ipP $E_remote_addr;
  49. proxy_set_header remote_addr $E_remote_addr;
  50. proxy_set_header X-Forwarded-For $E_proxy_add_x_forwarded_for;
  51. proxy_http_version 1.1;
  52. proxy_connect_timeout 300s;
  53. proxy_read_timeout 300s;
  54. proxy_send_timeout 300s;
  55. proxy_set_header Upgrade $E_http_upgrade;
  56. proxy_set_header Connection "upgrade";
  57. }
  58. #error_page 404 /404.html;
  59. # redirect server error pages to the static page /50x.html
  60. #
  61. error_page 500 502 503 504 /50x.html;
  62. location = /50x.html {
  63. root /usr/share/nginx/html;
  64. }
  65. }
  66. " >> /etc/nginx/conf.d/dolphinscheduler.conf
  67. }
  68. ubuntu(){
  69. # update source
  70. apt-get update
  71. # install nginx
  72. apt-get install -y nginx
  73. # config nginx
  74. dolphinschedulerConf $1 $2
  75. # startup nginx
  76. /etc/init.d/nginx start
  77. sleep 1
  78. if [ $? -ne 0 ];then
  79. /etc/init.d/nginx start
  80. fi
  81. nginx -s reload
  82. }
  83. centos7(){
  84. rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  85. yum install -y nginx
  86. # config nginx
  87. dolphinschedulerConf $1 $2
  88. # solve 0.0.0.0:8888 problem
  89. yum -y install policycoreutils-python
  90. semanage port -a -t http_port_t -p tcp $esc_proxy
  91. # open front access port
  92. firewall-cmd --zone=public --add-port=$esc_proxy/tcp --permanent
  93. # startup nginx
  94. systemctl start nginx
  95. sleep 1
  96. if [ $? -ne 0 ];then
  97. systemctl start nginx
  98. fi
  99. nginx -s reload
  100. # set SELinux parameters
  101. sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
  102. # temporary effect
  103. setenforce 0
  104. }
  105. centos6(){
  106. rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
  107. # install nginx
  108. yum install nginx -y
  109. # config nginx
  110. dolphinschedulerConf $1 $2
  111. # startup nginx
  112. /etc/init.d/nginx start
  113. sleep 1
  114. if [ $? -ne 0 ];then
  115. /etc/init.d/nginx start
  116. fi
  117. nginx -s reload
  118. # set SELinux parameters
  119. sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
  120. # temporary effect
  121. setenforce 0
  122. }
  123. function main(){
  124. echo "Welcome to thedolphinscheduler front-end deployment script, which is currently only supported by front-end deployment scripts : CentOS and Ubuntu"
  125. echo "Please execute in the dolphinscheduler-ui directory"
  126. #To be compatible with MacOS and Linux
  127. if [[ "$OSTYPE" == "darwin"* ]]; then
  128. # Mac OSX
  129. echo "Easy Scheduler ui install not support Mac OSX operating system"
  130. exit 1
  131. elif [[ "$OSTYPE" == "linux-gnu" ]]; then
  132. # linux
  133. echo "linux"
  134. elif [[ "$OSTYPE" == "cygwin" ]]; then
  135. # POSIX compatibility layer and Linux environment emulation for Windows
  136. echo "Easy Scheduler ui not support Windows operating system"
  137. exit 1
  138. elif [[ "$OSTYPE" == "msys" ]]; then
  139. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  140. echo "Easy Scheduler ui not support Windows operating system"
  141. exit 1
  142. elif [[ "$OSTYPE" == "win32" ]]; then
  143. echo "Easy Scheduler ui not support Windows operating system"
  144. exit 1
  145. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  146. # ...
  147. echo "freebsd"
  148. else
  149. # Unknown.
  150. echo "Operating system unknown, please tell us(submit issue) for better service"
  151. exit 1
  152. fi
  153. # config front-end access ports
  154. read -p "Please enter the nginx proxy port, do not enter, the default is 8888 :" esc_proxy_port
  155. if [ -z "${esc_proxy_port}" ];then
  156. esc_proxy_port="8888"
  157. fi
  158. read -p "Please enter the api server proxy ip, you must enter, for example: 192.168.xx.xx :" esc_api_server_ip
  159. if [ -z "${esc_api_server_ip}" ];then
  160. echo "api server proxy ip can not be empty."
  161. exit 1
  162. fi
  163. read -p "Please enter the api server proxy port, do not enter, the default is 12345:" esc_api_server_port
  164. if [ -z "${esc_api_server_port}" ];then
  165. esc_api_server_port="12345"
  166. fi
  167. # api server backend address
  168. esc_api_server="http://$esc_api_server_ip:$esc_api_server_port"
  169. # local ip address
  170. 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}')
  171. # Prompt message
  172. menu
  173. read -p "Please enter the installation number(1|2|3|4):" num
  174. case $num in
  175. 1)
  176. centos6 ${esc_proxy_port} ${esc_api_server}
  177. ;;
  178. 2)
  179. centos7 ${esc_proxy_port} ${esc_api_server}
  180. ;;
  181. 3)
  182. ubuntu ${esc_proxy_port} ${esc_api_server}
  183. ;;
  184. 4)
  185. echo $"Usage :sh $0"
  186. exit 1
  187. ;;
  188. *)
  189. echo $"Usage :sh $0"
  190. exit 1
  191. esac
  192. echo "Please visit the browser:http://${esc_ipaddr}:${esc_proxy_port}"
  193. }
  194. main