#!/bin/bash

systemctl stop minio smb tgtd nfs-service 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}1
elif [ $disk -eq 8 ];then
   mdadm --misc --zero-superblock /dev/sd{a..h}1
fi

rm -rf /etc/mdadm.conf

echo 'success'

