menu.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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 main menu
  18. ## @audience public
  19. ## @stability stable
  20. main_menu()
  21. {
  22. cat<<MENULIST
  23. ====================================================================================
  24. SUBMARINE INSTALLER ${SUBMARINE_INSTALLER_VERSION}
  25. HOST:${LOCAL_HOST_IP} DOWNLOAD_SERVER:http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}
  26. ====================================================================================
  27. [Main menu]
  28. ------------------------------------------------------------------------------------
  29. MENULIST
  30. echo -e " \e[32m1.prepare system environment [..]\e[0m"
  31. echo -e " \e[32m2.install component [..]\e[0m"
  32. echo -e " \e[32m3.uninstall component [..]\e[0m"
  33. echo -e " \e[32m4.start component [..]\e[0m"
  34. echo -e " \e[32m5.stop component [..]\e[0m"
  35. echo -e " \e[32m6.start download server [..]\e[0m"
  36. echo -e ""
  37. echo -e " \e[32mq.quit\e[0m"
  38. cat<<MENULIST
  39. ====================================================================================
  40. MENULIST
  41. echo -ne "Please input your choice [\e[32m1\e[0m-\e[32m6\e[0m,\e[32mq\e[0m(quit)]:"
  42. }
  43. ## @description check menu
  44. ## @audience public
  45. ## @stability stable
  46. check_menu()
  47. {
  48. cat<<MENULIST
  49. ====================================================================================
  50. SUBMARINE INSTALLER ${SUBMARINE_INSTALLER_VERSION}
  51. HOST:${LOCAL_HOST_IP} DOWNLOAD_SERVER:http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}
  52. ====================================================================================
  53. [Main menu] > [prepare system environment]
  54. ------------------------------------------------------------------------------------
  55. MENULIST
  56. echo -e " \e[32m1.prepare operation system\e[0m"
  57. echo -e " \e[32m2.prepare operation system kernel\e[0m"
  58. echo -e " \e[32m3.prepare GCC version\e[0m"
  59. echo -e " \e[32m4.check GPU\e[0m"
  60. echo -e " \e[32m5.prepare user&group\e[0m"
  61. echo -e " \e[32m6.prepare nvidia environment\e[0m"
  62. echo -e ""
  63. echo -e " \e[32mb.back main menu\e[0m"
  64. cat<<MENULIST
  65. ====================================================================================
  66. MENULIST
  67. echo -ne "Please input your choice [\e[32m1\e[0m-\e[32m5\e[0m,\e[32mb\e[0m(back)]:"
  68. }
  69. ## @description install menu
  70. ## @audience public
  71. ## @stability stable
  72. install_menu()
  73. {
  74. cat<<MENULIST
  75. ====================================================================================
  76. SUBMARINE INSTALLER ${SUBMARINE_INSTALLER_VERSION}
  77. HOST:${LOCAL_HOST_IP} DOWNLOAD_SERVER:http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}
  78. ====================================================================================
  79. [Main menu] > [install component]
  80. ------------------------------------------------------------------------------------
  81. MENULIST
  82. echo -e " \e[32m1.instll etcd\e[0m"
  83. echo -e " \e[32m2.instll docker\e[0m"
  84. echo -e " \e[32m3.instll calico network\e[0m"
  85. echo -e " \e[32m4.instll nvidia driver\e[0m"
  86. echo -e " \e[32m5.instll nvidia docker\e[0m"
  87. echo -e " \e[32m6.instll yarn container-executor\e[0m"
  88. echo -e " \e[32m7.instll submarine autorun script\e[0m"
  89. echo -e ""
  90. echo -e " \e[32mb.back main menu\e[0m"
  91. cat<<MENULIST
  92. ====================================================================================
  93. MENULIST
  94. echo -ne "Please input your choice [\e[32m1\e[0m-\e[32m7\e[0m,\e[32mb\e[0m(back)]:"
  95. }
  96. ## @description unstall menu
  97. ## @audience public
  98. ## @stability stable
  99. uninstall_menu()
  100. {
  101. cat<<MENULIST
  102. ====================================================================================
  103. SUBMARINE INSTALLER ${SUBMARINE_INSTALLER_VERSION}
  104. HOST:${LOCAL_HOST_IP} DOWNLOAD_SERVER:http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}
  105. ====================================================================================
  106. [Main menu] > [uninstll component]
  107. ------------------------------------------------------------------------------------
  108. MENULIST
  109. echo -e " \e[32m1.uninstll etcd\e[0m"
  110. echo -e " \e[32m2.uninstll docker\e[0m"
  111. echo -e " \e[32m3.uninstll calico network\e[0m"
  112. echo -e " \e[32m4.uninstll nvidia driver\e[0m"
  113. echo -e " \e[32m5.uninstll nvidia docker\e[0m"
  114. echo -e " \e[32m6.uninstll yarn container-executor\e[0m"
  115. echo -e " \e[32m7.uninstll submarine autorun script\e[0m"
  116. echo -e ""
  117. echo -e " \e[32mb.back main menu\e[0m"
  118. cat<<MENULIST
  119. ====================================================================================
  120. MENULIST
  121. echo -ne "Please input your choice [\e[32m1\e[0m-\e[32m7\e[0m,\e[32mb\e[0m(back)]:"
  122. }
  123. ## @description start menu
  124. ## @audience public
  125. ## @stability stable
  126. start_menu()
  127. {
  128. cat<<MENULIST
  129. ====================================================================================
  130. SUBMARINE INSTALLER ${SUBMARINE_INSTALLER_VERSION}
  131. HOST:${LOCAL_HOST_IP} DOWNLOAD_SERVER:http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}
  132. ====================================================================================
  133. [Main menu] > [stop component]
  134. ------------------------------------------------------------------------------------
  135. MENULIST
  136. echo -e " \e[32m1.start etcd\e[0m"
  137. echo -e " \e[32m2.start docker\e[0m"
  138. echo -e " \e[32m3.start calico network\e[0m"
  139. echo -e ""
  140. echo -e " \e[32mb.back main menu\e[0m"
  141. cat<<MENULIST
  142. ====================================================================================
  143. MENULIST
  144. echo -ne "Please input your choice [\e[32m1\e[0m-\e[32m3\e[0m,\e[32mb\e[0m(back)]:"
  145. }
  146. ## @description stop menu
  147. ## @audience public
  148. ## @stability stable
  149. stop_menu()
  150. {
  151. cat<<MENULIST
  152. ====================================================================================
  153. SUBMARINE INSTALLER ${SUBMARINE_INSTALLER_VERSION}
  154. HOST:${LOCAL_HOST_IP} DOWNLOAD_SERVER:http://${DOWNLOAD_SERVER_IP}:${DOWNLOAD_SERVER_PORT}
  155. ====================================================================================
  156. [Main menu] > [stop component]
  157. ------------------------------------------------------------------------------------
  158. MENULIST
  159. echo -e " \e[32m1.stop etcd\e[0m"
  160. echo -e " \e[32m2.stop docker\e[0m"
  161. echo -e " \e[32m3.stop calico network\e[0m"
  162. echo -e ""
  163. echo -e " \e[32mb.back main menu\e[0m"
  164. cat<<MENULIST
  165. ====================================================================================
  166. MENULIST
  167. echo -ne "Please input your choice [\e[32m1\e[0m-\e[32m3\e[0m,\e[32mb\e[0m(back)]:"
  168. }
  169. ## @description menu operation
  170. ## @audience public
  171. ## @stability stable
  172. menu_index="0"
  173. menu()
  174. {
  175. clear
  176. # echo "menu_index-menu_choice=$menu_index-$menu_choice"
  177. case $menu_index in
  178. "0")
  179. main_menu
  180. ;;
  181. "1")
  182. check_menu
  183. ;;
  184. "2")
  185. install_menu
  186. ;;
  187. "3")
  188. uninstall_menu
  189. ;;
  190. "4")
  191. start_menu
  192. ;;
  193. "5")
  194. stop_menu
  195. ;;
  196. "6")
  197. start_download_server
  198. ;;
  199. "q")
  200. exit 1
  201. ;;
  202. *)
  203. echo "error input!"
  204. menu_index="0"
  205. menu_choice="0"
  206. main_menu
  207. ;;
  208. esac
  209. read menu_choice
  210. }
  211. ## @description menu process
  212. ## @audience public
  213. ## @stability stable
  214. menu_process()
  215. {
  216. process=0
  217. unset myselect
  218. # echo "debug=$menu_index-$menu_choice"
  219. case "$menu_index-$menu_choice" in
  220. "1-b"|"2-b"|"3-b"|"4-b"|"5-b"|"6-b")
  221. menu_index="0"
  222. menu_choice="0"
  223. ;;
  224. # check system environment
  225. "1-1")
  226. myselect="y"
  227. check_operationSystem
  228. ;;
  229. "1-2")
  230. myselect="y"
  231. check_operationSystemKernel
  232. ;;
  233. "1-3")
  234. myselect="y"
  235. check_gccVersion
  236. ;;
  237. "1-4")
  238. myselect="y"
  239. check_GPU
  240. ;;
  241. "1-5")
  242. myselect="y"
  243. check_userGroup
  244. ;;
  245. "1-6")
  246. myselect="y"
  247. prepare_nvidia_environment
  248. ;;
  249. # install component
  250. "2-1")
  251. echo -n "Do you want to install etcd?[y|n]"
  252. read myselect
  253. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  254. then
  255. install_etcd
  256. fi
  257. ;;
  258. "2-2")
  259. echo -n "Do you want to install docker?[y|n]"
  260. read myselect
  261. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  262. then
  263. install_docker
  264. fi
  265. ;;
  266. "2-3")
  267. echo -n "Do you want to install calico network?[y|n]"
  268. read myselect
  269. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  270. then
  271. install_calico
  272. fi
  273. ;;
  274. "2-4")
  275. echo -n "Do you want to install nvidia driver?[y|n]"
  276. read myselect
  277. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  278. then
  279. install_nvidia
  280. fi
  281. ;;
  282. "2-5")
  283. echo -n "Do you want to install nvidia docker?[y|n]"
  284. read myselect
  285. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  286. then
  287. install_nvidia_docker
  288. fi
  289. ;;
  290. "2-6")
  291. echo -n "Do you want to install yarn container-executor?[y|n]"
  292. read myselect
  293. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  294. then
  295. install_yarn
  296. fi
  297. ;;
  298. "2-7")
  299. echo -n "Do you want to install submarine auto start script?[y|n]"
  300. read myselect
  301. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  302. then
  303. install_submarine
  304. fi
  305. ;;
  306. # uninstall component
  307. "3-1")
  308. echo -n "Do you want to uninstall etcd?[y|n]"
  309. read myselect
  310. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  311. then
  312. uninstall_etcd
  313. fi
  314. ;;
  315. "3-2")
  316. echo -n "Do you want to uninstall docker?[y|n]"
  317. read myselect
  318. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  319. then
  320. uninstall_docker
  321. fi
  322. ;;
  323. "3-3")
  324. echo -n "Do you want to uninstall calico network?[y|n]"
  325. read myselect
  326. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  327. then
  328. uninstall_calico
  329. fi
  330. ;;
  331. "3-4")
  332. echo -n "Do you want to uninstall nvidia driver?[y|n]"
  333. read myselect
  334. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  335. then
  336. uninstall_nvidia
  337. fi
  338. ;;
  339. "3-5")
  340. echo -n "Do you want to uninstall nvidia docker?[y|n]"
  341. read myselect
  342. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  343. then
  344. uninstall_nvidia_docker
  345. fi
  346. ;;
  347. "3-6")
  348. echo -n "Do you want to uninstall yarn container-executor?[y|n]"
  349. read myselect
  350. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  351. then
  352. uninstall_yarn
  353. fi
  354. ;;
  355. "3-7")
  356. echo -n "Do you want to uninstall submarine autostart script?[y|n]"
  357. read myselect
  358. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  359. then
  360. uninstall_submarine
  361. fi
  362. ;;
  363. # startup component
  364. "4-1")
  365. echo -n "Do you want to startup etcd?[y|n]"
  366. read myselect
  367. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  368. then
  369. start_etcd
  370. fi
  371. ;;
  372. "4-2")
  373. echo -n "Do you want to startup docker?[y|n]"
  374. read myselect
  375. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  376. then
  377. start_docker
  378. fi
  379. ;;
  380. "4-3")
  381. echo -n "Do you want to startup calico network?[y|n]"
  382. read myselect
  383. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  384. then
  385. start_calico
  386. fi
  387. ;;
  388. # stop component
  389. "5-1")
  390. echo -n "Do you want to stop etcd?[y|n]"
  391. read myselect
  392. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  393. then
  394. stop_etcd
  395. fi
  396. ;;
  397. "5-2")
  398. echo -n "Do you want to stop docker?[y|n]"
  399. read myselect
  400. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  401. then
  402. stop_docker
  403. fi
  404. ;;
  405. "5-3")
  406. echo -n "Do you want to stop calico network?[y|n]"
  407. read myselect
  408. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  409. then
  410. stop_calico
  411. fi
  412. ;;
  413. esac
  414. if [[ "$myselect" = "y" || "$myselect" = "Y" ]]
  415. then
  416. process=1
  417. fi
  418. # echo "process=$process"
  419. return $process
  420. }