diff options
author | Humble Devassy Chirammal <humble.devassy@gmail.com> | 2017-08-10 14:40:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-10 14:40:26 +0000 |
commit | e3c1f46e048707e43f92bfc4a1a5981c378eace3 (patch) | |
tree | 71a29e638b6ce02c3f83ad6402d01709eef7a991 /CentOS/gluster-setup.sh | |
parent | ef2078234bc1a18c5ebefa62d21f12149b4c9e80 (diff) | |
parent | 1171781ec72f3b804ca91e6db2dc456559acca05 (diff) | |
download | gluster-e3c1f46e048707e43f92bfc4a1a5981c378eace3.tar.gz gluster-e3c1f46e048707e43f92bfc4a1a5981c378eace3.tar.bz2 gluster-e3c1f46e048707e43f92bfc4a1a5981c378eace3.tar.xz gluster-e3c1f46e048707e43f92bfc4a1a5981c378eace3.zip |
Merge pull request #52 from MohamedAshiqrh/block
Update Fedora and CentOS scripts
Diffstat (limited to 'CentOS/gluster-setup.sh')
-rw-r--r-- | CentOS/gluster-setup.sh | 107 |
1 files changed, 67 insertions, 40 deletions
diff --git a/CentOS/gluster-setup.sh b/CentOS/gluster-setup.sh index 98570f5..1fdaf37 100644 --- a/CentOS/gluster-setup.sh +++ b/CentOS/gluster-setup.sh @@ -13,57 +13,84 @@ ### main () { - if test "$(ls /var/lib/heketi/fstab)" - then - mount -a --fstab /var/lib/heketi/fstab - if [ $? -eq 1 ] - then - echo "mount failed" - exit 1 - fi - echo "Mount Successful" - else - echo "heketi-fstab not found" - fi - DIR_1="/etc/glusterfs" - DIR_2="/var/log/glusterfs" - DIR_3="/var/lib/glusterd" - var=0 - for i in $DIR_1 $DIR_2 $DIR_3 + GLUSTERFS_CONF_DIR="/etc/glusterfs" + GLUSTERFS_LOG_DIR="/var/log/glusterfs" + GLUSTERFS_META_DIR="/var/lib/glusterd" + GLUSTERFS_LOG_CONT_DIR="/var/log/glusterfs/container" + GLUSTERFS_CUSTOM_FSTAB="/var/lib/heketi/fstab" + + mkdir $GLUSTERFS_LOG_CONT_DIR + for i in $GLUSTERFS_CONF_DIR $GLUSTERFS_LOG_DIR $GLUSTERFS_META_DIR do if test "$(ls $i)" then - echo "$i is not empty" - var=$((var+1)) + echo "$i is not empty" + else + bkp=$i"_bkp" + cp -r $bkp/* $i + if [ $? -eq 1 ] + then + echo "Failed to copy $i" + exit 1 + fi + ls -R $i > ${GLUSTERFS_LOG_CONT_DIR}/${i}_ls fi done - if [ $var -eq 3 ] + if test "$(ls $GLUSTERFS_LOG_CONT_DIR)" then - exit 1 + echo "" > $GLUSTERFS_LOG_CONT_DIR/brickattr + echo "" > $GLUSTERFS_LOG_CONT_DIR/failed_bricks + echo "" > $GLUSTERFS_LOG_CONT_DIR/lvscan + echo "" > $GLUSTERFS_LOG_CONT_DIR/mountfstab + else + mkdir $GLUSTERFS_LOG_CONT_DIR + echo "" > $GLUSTERFS_LOG_CONT_DIR/brickattr + echo "" > $GLUSTERFS_LOG_CONT_DIR/failed_bricks fi - - cp -r /etc/glusterfs_bkp/* /etc/glusterfs - if [ $? -eq 1 ] + if test "$(ls $GLUSTERFS_CUSTOM_FSTAB)" then - echo "Failed to copy $DIR_1" - exit 1 - fi - - cp -r /var/log/glusterfs_bkp/* /var/log/glusterfs - if [ $? -eq 1 ] - then - echo "Failed to copy $DIR_2" - exit 1 + sleep 5 + pvscan > $GLUSTERFS_LOG_CONT_DIR/pvscan + vgscan > $GLUSTERFS_LOG_CONT_DIR/vgscan + lvscan > $GLUSTERFS_LOG_CONT_DIR/lvscan + mount -a --fstab $GLUSTERFS_CUSTOM_FSTAB > $GLUSTERFS_LOG_CONT_DIR/mountfstab + if [ $? -eq 1 ] + then + echo "mount binary not failed" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab + exit 1 + fi + echo "Mount command Successful" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab + sleep 40 + cut -f 2 -d " " $GLUSTERFS_CUSTOM_FSTAB | while read -r line + do + if grep -qs "$line" /proc/mounts; then + echo "$line mounted." >> $GLUSTERFS_LOG_CONT_DIR/mountfstab + if test "ls $line/brick" + then + echo "$line/brick is present" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab + getfattr -d -m . -e hex "$line"/brick >> $GLUSTERFS_LOG_CONT_DIR/brickattr + else + echo "$line/brick is not present" >> $GLUSTERFS_LOG_CONT_DIR/mountfstab + sleep 1 + fi + else + grep "$line" $GLUSTERFS_CUSTOM_FSTAB >> $GLUSTERFS_LOG_CONT_DIR/failed_bricks + echo "$line not mounted." >> $GLUSTERFS_LOG_CONT_DIR/mountfstab + sleep 0.5 + fi + done + if [ "$(wc -l $GLUSTERFS_LOG_CONT_DIR/failed_bricks )" -gt 1 ] + then + vgscan --mknodes > $GLUSTERFS_LOG_CONT_DIR/vgscan_mknodes + sleep 10 + mount -a --fstab $GLUSTERFS_LOG_CONT_DIR/failed_bricks + fi + else + echo "heketi-fstab not found" fi - cp -r /var/lib/glusterd_bkp/* /var/lib/glusterd - if [ $? -eq 1 ] - then - echo "Failed to copy $DIR_3" - exit 1 - fi - echo "Script Ran Successfully" + exit 0 } main |