create_vols.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # Define the container prefix
  3. CONTAINER="nc3_"
  4. # Define the volumes to create
  5. VOLUMES=(
  6. "db:local"
  7. "files:bind:./storage/data"
  8. "redis:local"
  9. "es_root:local"
  10. "es_index:local"
  11. "oo_data:local"
  12. "clamav:local"
  13. )
  14. # Loop through the volumes and create them
  15. for volume in "${VOLUMES[@]}"; do
  16. # Split the volume definition into name, driver, and bind location
  17. IFS=: read -r name driver bind_location <<< "$volume"
  18. # Append the container prefix to the volume name
  19. volume_name="${CONTAINER}${name}"
  20. echo "Creating volume: $volume_name"
  21. # Create the volume based on the driver
  22. case $driver in
  23. local)
  24. #docker volume create "$volume_name"
  25. echo $volume_name
  26. ;;
  27. bind)
  28. if [ -z "$bind_location" ]; then
  29. echo "Error: Bind location not specified for volume: $volume_name"
  30. exit 1
  31. fi
  32. # docker volume create --driver local --opt type=none --opt device=$bind_location --opt o=bind "$volume_name"
  33. echo docker volume create --driver local --opt type=none --opt device=$bind_location --opt o=bind "$volume_name"
  34. ;;
  35. *)
  36. echo "Error: Unknown driver: $driver for volume: $volume_name"
  37. exit 1
  38. ;;
  39. esac
  40. done