#!/bin/bash

systemctl stop minio smb tgtd nfs-server minio-colony glusterd

umount /opt/storage/data1

md=$(cat /proc/mdstat|awk 'NR==2{print $1}')

if [ ${md} = 'md5' ];then
   mdadm -S /dev/md5
else
   mdadm -S /dev/md127
fi

sleep 2

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

if [ $disk -eq 4 ];then
   mdadm --misc --zero-superblock /dev/sd{a..d}
elif [ $disk -eq 8 ];then
   mdadm --misc --zero-superblock /dev/sd{a..h}
fi

rm -rf /etc/mdadm.conf

echo 'success'

