install.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # description: sumbarine install scripts.
  18. ROOT=$(cd "$(dirname "$0")"; pwd)
  19. SUBMARINE_INSTALLER_VERSION="v0.7"
  20. PACKAGE_DIR=${ROOT}/package
  21. SCRIPTS_DIR=${ROOT}/scripts
  22. INSTALL_TEMP_DIR=${ROOT}/temp
  23. DOWNLOAD_DIR=${ROOT}/downloads
  24. DATE=`date +%Y%m%d-%H:%M:%S`
  25. LOG=${ROOT}/logs/install.log.`date +%Y%m%d%H%M%S`
  26. LOCAL_HOST_IP_LIST=()
  27. LOCAL_HOST_IP=""
  28. OPERATING_SYSTEM=""
  29. DOWNLOAD_HTTP=""
  30. # import shell script
  31. . ${ROOT}/install.conf
  32. . ${ROOT}/scripts/calico.sh
  33. . ${ROOT}/scripts/docker.sh
  34. . ${ROOT}/scripts/download-server.sh
  35. . ${ROOT}/scripts/environment.sh
  36. . ${ROOT}/scripts/etcd.sh
  37. . ${ROOT}/scripts/hadoop.sh
  38. . ${ROOT}/scripts/menu.sh
  39. . ${ROOT}/scripts/nvidia.sh
  40. . ${ROOT}/scripts/nvidia-docker.sh
  41. . ${ROOT}/scripts/submarine.sh
  42. . ${ROOT}/scripts/utils.sh
  43. #================================= Main ========================================
  44. mkdir $ROOT/logs/ -p
  45. mkdir $INSTALL_TEMP_DIR -p
  46. mkdir $DOWNLOAD_DIR -p
  47. source /etc/os-release
  48. OPERATING_SYSTEM=$ID
  49. get_ip_list
  50. ipCount=${#LOCAL_HOST_IP_LIST[@]}
  51. if [[ $ipCount -eq 1 ]]; then
  52. LOCAL_HOST_IP=${LOCAL_HOST_IP_LIST[0]}
  53. else
  54. echo -e "Detect the network card IP in the server, \e[31m[${LOCAL_HOST_IP_LIST[@]}]\e[0m"
  55. echo -n -e "please enter a valid IP address: "
  56. read ipInput
  57. if ! valid_ip $ipInput; then
  58. echo -e "you input \e[31m$ipInput\e[0m address format is incorrect! " | tee -a $LOG
  59. exit_install
  60. else
  61. LOCAL_HOST_IP=$ipInput
  62. fi
  63. fi
  64. echo -n -e "Please confirm whether the IP address of this machine is \e[31m${LOCAL_HOST_IP}\e[0m?[y|n]"
  65. read myselect
  66. if [[ "$myselect" != "y" && "$myselect" != "Y" ]]; then
  67. exit_install
  68. fi
  69. check_install_conf
  70. if [[ -n "$DOWNLOAD_SERVER_IP" && -n "$DOWNLOAD_SERVER_PORT" && "$DOWNLOAD_SERVER_IP" != "$LOCAL_HOST_IP" ]]; then
  71. DOWNLOAD_HTTP="http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}"
  72. fi
  73. check_install_user
  74. # 清理安装临时目录
  75. rm $INSTALL_TEMP_DIR/* -rf >>$LOG 2>&1
  76. menu_index="0"
  77. for ((j=1;;j++))
  78. do
  79. menu
  80. case "$menu_index" in
  81. "0")
  82. menu_index="$menu_choice"
  83. ;;
  84. "1"|"2"|"3"|"4"|"5")
  85. # echo "aaaa=$menu_index-$menu_choice"
  86. menu_process
  87. if [[ $? = 1 ]]; then
  88. echo "Press any key to return menu!"
  89. read
  90. fi
  91. ;;
  92. "a")
  93. exit_install
  94. ;;
  95. "q")
  96. exit_install
  97. ;;
  98. *)
  99. menu_index="0"
  100. menu_choice="0"
  101. menu
  102. ;;
  103. esac
  104. done