summaryrefslogtreecommitdiffstats
path: root/helper_scripts/glusterfs-precreate.sh
blob: c5b62a2f1497b7d0eb6a07be06365403db675f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

set -e;

if [ $# -eq 0 ]; then
    echo "Usage: $0 <dir1> [dir2 [dir3 [dir4 ...]]]";
    exit 1
fi

for dir in "$@"; do
    if [ ! -d "$dir" ]; then
	echo "$0: $dir not a directory"
	exit 1;
    fi
done

subdirs="{00"
for i in {1..255}; do
    n=$(printf "%02x" $i);
    subdirs="$subdirs,$n";
done
subdirs="$subdirs}"

mkdir -vp "$dir/.glusterfs";

for dir in $@; do
    for i in {0..255}; do
	n=$(printf "%02x" $i);
	mkdir -vp "$dir/.glusterfs/$n"
	eval "mkdir -vp $dir/.glusterfs/$n/$subdirs"
    done
done