install-escheduler-ui.sh 5.8 KB

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