You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
963 B

  1. #!/bin/sh
  2. #
  3. # This script creates a bundle storage of a given size.
  4. #
  5. # $1 = container file
  6. # $2 = size of the container in MB
  7. #
  8. help_message() {
  9. echo "usage: "
  10. echo " $0 <container file> <size in MB>"
  11. }
  12. if [ $# -le 1 ]; then
  13. help_message
  14. exit 1
  15. fi
  16. CONTAINER=$(cd "$(dirname "$1")"; pwd)/$(basename $1)
  17. SIZE=$2
  18. # check if the container already exists
  19. if [ -f $CONTAINER ]; then
  20. echo "Aborted! The specified container already exists."
  21. exit 1
  22. fi
  23. # create the container
  24. echo -n "creating the container file..."
  25. /bin/dd if=/dev/zero of=$CONTAINER bs=1M count=$SIZE >/dev/null 2>/dev/null
  26. echo " done"
  27. # create file system
  28. echo -n "initializing ext3 filesystem for the container..."
  29. /usr/sbin/mkfs.ext3 -q -F $CONTAINER > /dev/null
  30. echo " done"
  31. # final hint
  32. echo "The container is now ready. To use it with IBR-DTN set the container with:"
  33. echo "# uci set ibrdtn.storage.container=$CONTAINER"
  34. echo "# uci set ibrdtn.storage.container_size=$SIZE"
  35. exit 0