startup.sh 976 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. if [ -f /opt/docker/startup/.env ]
  3. then
  4. echo "OK: .env file found"
  5. source /opt/docker/startup/.env
  6. else
  7. echo '.env is missing, please consult README.md' && exit 1
  8. fi
  9. # test if a variable with the hostname of the machine,
  10. # as defined in $HOSTNAME, exists
  11. if [ ! -z "${!HOSTNAME}" ]
  12. then
  13. echo "OK: Container list found in \$$HOSTNAME"
  14. else
  15. echo "NOK: No container list found for $HOSTNAME" && exit 1
  16. fi
  17. up() {
  18. for service in ${!HOSTNAME}
  19. do
  20. cd $service
  21. docker compose up -d --remove-orphans
  22. done
  23. }
  24. down() {
  25. for service in $services
  26. do
  27. cd $service
  28. docker compose down
  29. done
  30. }
  31. pull() {
  32. for service in $services
  33. do
  34. cd $service
  35. docker compose pull
  36. done
  37. }
  38. case "$1" in
  39. up)
  40. up
  41. ;;
  42. down)
  43. down
  44. ;;
  45. pull)
  46. pull
  47. ;;
  48. *)
  49. echo $"Usage: $0 {up|down|pull}"
  50. exit 1
  51. esac