Root/ibrdtnd/files/mkcontainer.sh

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

Archive Download this file



interactive