#!/bin/bash

#i=1

services=(minio smb tgtd nfs-server minio-colony glusterd)
for sc in ${services[@]};do
    systemctl stop $sc || echo "$sc not run"
done

modedata=($(/opt/tool/saturn-get-mode.sh))
num=${modedata[0]}
disks=${modedata[@]:1:${num}}

if [ $num -eq 4 ] || [ $num -eq 8 ];then
    for d in ${disks[@]};do
        umount /dev/${d}1
        echo "y"|mkfs.ext4 /dev/${d}1
    done
else
    echo "error:磁盘个数与型号不匹配"
    exit 1
fi

sleep 3

/opt/tool/saturn-mount.py

sleep 1

brick=$(df |grep "/opt/storage/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

