#!/bin/bash

#i=1

systemctl stop minio nfs-server smb tgtd

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

#ext=`lsblk -f|grep sd|grep ext4|wc -l`
disk=$(lsblk |grep -Ew "sda|sdb|sdc|sdd|sde|sdf|sdg|sdh"|wc -l)

#if [ $ext -ne 4 ] && [ $ext -ne 8 ];then
  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
#else
   echo "磁盘文件系统已存在"
#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

