summaryrefslogtreecommitdiffstats
path: root/CentOS/gluster-setup.sh
blob: 98570f578890530148afca4b7d4884f450bea0fc (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash

###
# Description: Script to move the glusterfs initial setup to bind mounted directories of Atomic Host.
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
#
# This file is part of GlusterFS.
#
# This file is licensed to you under your choice of the GNU Lesser
# General Public License, version 3 or any later version (LGPLv3 or
# later), or the GNU General Public License, version 2 (GPLv2), in all
# cases as published by the Free Software Foundation.
###

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
  do
    if test "$(ls $i)"
    then
      echo "$i is not empty"
      var=$((var+1))
    fi
  done

  if [ $var -eq 3 ]
  then
        exit 1
  fi
  
  cp -r /etc/glusterfs_bkp/* /etc/glusterfs
  if [ $? -eq 1 ]
  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
  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"
}
main