OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
| 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 | |
| 9 | help_message() { |
| 10 | echo "usage: " |
| 11 | echo " $0 <container file> <size in MB>" |
| 12 | } |
| 13 | |
| 14 | if [ $# -le 1 ]; then |
| 15 | help_message |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | CONTAINER=$(cd "$(dirname "$1")"; pwd)/$(basename $1) |
| 20 | SIZE=$2 |
| 21 | |
| 22 | # check if the container already exists |
| 23 | if [ -f $CONTAINER ]; then |
| 24 | echo "Aborted! The specified container already exists." |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | # create the container |
| 29 | echo -n "creating the container file..." |
| 30 | /bin/dd if=/dev/zero of=$CONTAINER bs=1M count=$SIZE >/dev/null 2>/dev/null |
| 31 | echo " done" |
| 32 | |
| 33 | # create file system |
| 34 | echo -n "initializing ext3 filesystem for the container..." |
| 35 | /usr/sbin/mkfs.ext3 -q -F $CONTAINER > /dev/null |
| 36 | echo " done" |
| 37 | |
| 38 | # final hint |
| 39 | echo "The container is now ready. To use it with IBR-DTN set the container with:" |
| 40 | echo "# uci set ibrdtn.storage.container=$CONTAINER" |
| 41 | echo "# uci set ibrdtn.storage.container_size=$SIZE" |
| 42 | |
| 43 | exit 0 |
| 44 |
