#!/bin/bash

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

mds=$(cat /proc/mdstat | egrep -o "md[0-9]{1,3}")

if [ -n "$mds" ];then
    for i in $mds;do
	umount /dev/${i}
	mdadm -S /dev/${i}
    done
    sleep 2

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

    for d in ${disks[*]};do dn="${dn}/dev/${d}1 ";done
    if [ $num -eq 4 ] || [ $num -eq 8 ];then
        mdadm --misc --zero-superblock $dn
    fi

    rm -rf /etc/mdadm.conf
    echo 'success'
else
    echo -e "Not Raid\nsuccess"
fi

