diff options
author | Rahul C S <rahulcs@redhat.com> | 2012-02-27 16:19:42 +0530 |
---|---|---|
committer | Rahul C S <rahulcs@redhat.com> | 2012-02-27 16:23:08 +0530 |
commit | 9c41477719971d04276e4c271fe5070314fff753 (patch) | |
tree | fd7d64cabfa8cf37a2ea475be3df52448fc20810 | |
parent | a53faa6b9d92be769fad0d47cd7e6b7bc023fc3f (diff) |
precreate .glusterfs directory in the backend
Thanks to Avati <aavati@redhat.com> for the patch
Helps creating .glusterfs directory hierarchy
structure in the backend. Could be useful for the
client as well.
Signed-off-by: Rahul C S <rahulcs@redhat.com>
Change-Id: Ia540c4b6a3e4ea3b05aa7de216ff6c3734eb5792
-rwxr-xr-x | helper_scripts/glusterfs-precreate.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/helper_scripts/glusterfs-precreate.sh b/helper_scripts/glusterfs-precreate.sh new file mode 100755 index 0000000..c5b62a2 --- /dev/null +++ b/helper_scripts/glusterfs-precreate.sh @@ -0,0 +1,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
\ No newline at end of file |