#!/bin/bash

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
        dd if=/dev/zero of=/dev/$d bs=10M count=1
        echo "yes" |parted /dev/$d mklabel gpt
        echo "Ignore" | parted /dev/$d "mkpart primary ext4 2048s -1"
	wipefs -a /dev/${d}1
    done

    sleep 1
    partprobe
    hostnamectl set-hostname $(/opt/tool/saturn-device-id -r 14)    
    echo 'success'
else
    echo "error:磁盘个数与型号不匹配."
    exit 1
fi

