cmd 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/env bash
  2. #fonts color
  3. Green="\033[32m"
  4. Red="\033[31m"
  5. GreenBG="\033[42;37m"
  6. RedBG="\033[41;37m"
  7. Font="\033[0m"
  8. #notification information
  9. OK="${Green}[OK]${Font}"
  10. Error="${Red}[错误]${Font}"
  11. cur_path="$(pwd)"
  12. supervisorctl_restart() {
  13. RES=`docker-compose exec php /bin/bash -c "supervisorctl update $1"`
  14. if [ -z "$RES" ];then
  15. docker-compose exec php /bin/bash -c "supervisorctl restart $1"
  16. else
  17. echo -e "$RES"
  18. fi
  19. }
  20. ####################################################################################
  21. ####################################################################################
  22. ####################################################################################
  23. COMPOSE="docker-compose"
  24. if [ $# -gt 0 ];then
  25. if [[ "$1" == "init" ]] || [[ "$1" == "install" ]]; then
  26. shift 1
  27. if [ ! -f ".env" ];then
  28. cp .env.docker .env
  29. fi
  30. rm -rf composer.lock
  31. rm -rf package-lock.json
  32. $COMPOSE build php
  33. $COMPOSE up -d
  34. $COMPOSE restart php
  35. $COMPOSE exec php /bin/bash -c "composer install"
  36. $COMPOSE exec php /bin/bash -c "php artisan key:generate"
  37. $COMPOSE exec php /bin/bash -c "php artisan migrate --seed"
  38. $COMPOSE exec php /bin/bash -c "php bin/wookteam --port=8000 --ssl=44300"
  39. $COMPOSE exec php /bin/bash -c "php bin/wookteam --wookteam=prod"
  40. $COMPOSE stop
  41. $COMPOSE start
  42. elif [[ "$1" == "update" ]]; then
  43. shift 1
  44. git fetch --all
  45. git reset --hard origin/master
  46. git pull
  47. $COMPOSE exec php /bin/bash -c "composer install"
  48. $COMPOSE exec php /bin/bash -c "php artisan migrate"
  49. $COMPOSE stop
  50. $COMPOSE start
  51. elif [[ "$1" == "dev" ]]; then
  52. shift 1
  53. $COMPOSE exec php /bin/bash -c "php bin/wookteam --wookteam=dev"
  54. supervisorctl_restart php
  55. npm run hot
  56. elif [[ "$1" == "prod" ]]; then
  57. shift 1
  58. $COMPOSE exec php /bin/bash -c "php bin/wookteam --wookteam=prod"
  59. supervisorctl_restart php
  60. npm run prod
  61. elif [[ "$1" == "artisan" ]]; then
  62. shift 1
  63. e="php artisan $@" && $COMPOSE exec php /bin/bash -c "$e"
  64. elif [[ "$1" == "php" ]]; then
  65. shift 1
  66. e="php $@" && $COMPOSE exec php /bin/bash -c "$e"
  67. elif [[ "$1" == "composer" ]]; then
  68. shift 1
  69. e="composer $@" && $COMPOSE exec php /bin/bash -c "$e"
  70. elif [[ "$1" == "supervisorctl" ]]; then
  71. shift 1
  72. e="supervisorctl $@" && $COMPOSE exec php /bin/bash -c "$e"
  73. elif [[ "$1" == "test" ]]; then
  74. shift 1
  75. e="./vendor/bin/phpunit $@" && $COMPOSE exec php /bin/bash -c "$e"
  76. elif [[ "$1" == "npm" ]]; then
  77. shift 1
  78. e="npm $@" && $COMPOSE exec php /bin/bash -c "$e"
  79. elif [[ "$1" == "yarn" ]]; then
  80. shift 1
  81. e="yarn $@" && $COMPOSE exec php /bin/bash -c "$e"
  82. elif [[ "$1" == "mysql" ]]; then
  83. shift 1
  84. e="mysql $@" && $COMPOSE exec mariadb /bin/sh -c "$e"
  85. elif [[ "$1" == "restart" ]]; then
  86. shift 1
  87. $COMPOSE stop "$@"
  88. $COMPOSE start "$@"
  89. else
  90. $COMPOSE "$@"
  91. fi
  92. else
  93. $COMPOSE ps
  94. fi