deploy.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #使用说明,用来提示输入参数
  2. usage() {
  3. echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm|rmiNoneTag]"
  4. exit 1
  5. }
  6. #开启所需端口
  7. port(){
  8. firewall-cmd --add-port=88/tcp --permanent
  9. firewall-cmd --add-port=8000/tcp --permanent
  10. firewall-cmd --add-port=8848/tcp --permanent
  11. firewall-cmd --add-port=3306/tcp --permanent
  12. firewall-cmd --add-port=3379/tcp --permanent
  13. firewall-cmd --add-port=7002/tcp --permanent
  14. service firewalld restart
  15. }
  16. ##放置挂载文件
  17. mount(){
  18. if test ! -f "/docker/nginx/gateway/nginx.conf" ;then
  19. mkdir -p /docker/nginx/gateway
  20. cp nginx/gateway/nginx.conf /docker/nginx/gateway/nginx.conf
  21. fi
  22. if test ! -f "/docker/nginx/web/nginx.conf" ;then
  23. mkdir -p /docker/nginx/web
  24. cp nginx/web/nginx.conf /docker/nginx/web/nginx.conf
  25. cp -r nginx/web/html /docker/nginx/web/html
  26. fi
  27. if test ! -f "/docker/nacos/init.d/custom.properties" ;then
  28. mkdir -p /docker/nacos/init.d
  29. cp nacos/custom.properties /docker/nacos/init.d/custom.properties
  30. fi
  31. }
  32. #启动基础模块
  33. base(){
  34. docker-compose up -d nacos sentinel web-nginx blade-nginx blade-redis
  35. }
  36. #启动程序模块
  37. modules(){
  38. docker-compose up -d blade-gateway1 blade-gateway2 blade-gateway3 blade-admin blade-auth blade-user blade-desk blade-system blade-log
  39. }
  40. #关闭所有模块
  41. stop(){
  42. docker-compose stop
  43. }
  44. #删除所有模块
  45. rm(){
  46. docker-compose rm
  47. }
  48. #删除Tag为空的镜像
  49. rmiNoneTag(){
  50. docker images|grep none|awk '{print $3}'|xargs docker rmi -f
  51. }
  52. #根据输入参数,选择执行对应方法,不输入则执行使用说明
  53. case "$1" in
  54. "port")
  55. port
  56. ;;
  57. "mount")
  58. mount
  59. ;;
  60. "base")
  61. base
  62. ;;
  63. "modules")
  64. modules
  65. ;;
  66. "stop")
  67. stop
  68. ;;
  69. "rm")
  70. rm
  71. ;;
  72. "rmiNoneTag")
  73. rmiNoneTag
  74. ;;
  75. *)
  76. usage
  77. ;;
  78. esac