#!/bin/bash

i=1

systemctl stop minio nfs-server smb tgtd

umount /opt/storage/data{1..8}

disk=$(lsblk |grep -Ew "sda|sdb|sdc|sdd|sde|sdf|sdg|sdh"|wc -l)

if [ $disk -eq 4 ];then
  echo "y"|mkfs.ext4 /dev/sda1
  echo "y"|mkfs.ext4 /dev/sdb1
  echo "y"|mkfs.ext4 /dev/sdc1
  echo "y"|mkfs.ext4 /dev/sdd1
else
  echo "y"|mkfs.ext4 /dev/sda1
  echo "y"|mkfs.ext4 /dev/sdb1
  echo "y"|mkfs.ext4 /dev/sdc1
  echo "y"|mkfs.ext4 /dev/sdd1
  echo "y"|mkfs.ext4 /dev/sde1
  echo "y"|mkfs.ext4 /dev/sdf1
  echo "y"|mkfs.ext4 /dev/sdg1
  echo "y"|mkfs.ext4 /dev/sdh1
fi
sleep 3

/opt/tool/saturn-mount.py

sleep 1

brick=$(df |grep data|wc -l)

if [ ${brick} -eq 4 ];then
   echo "success_brick_4"
elif [ ${brick} -eq 8 ];then
   echo "success_brick_8"
else
   echo "Missing device block"
fi

