#!/bin/bash
yum install -y cloud-utils-growpart
read -p "现在开始扩容网盘；请输入网盘目录如：/wwwroot:  " dir
cd /root
umount /$dir
iscsiadm -m node --logoutall=all  #登出

echo -e "\033[31m  记录网盘iqn！\033[0m"
cat /etc/iscsi/initiatorname.iscsi 

iscsiadm --mode node --portal 10.100.66.14:3260 -u

echo -e "\033[31m  请到工作机登陆面板http://172.22.66.204:8443;更新网盘容量！\033[0m"

echo -e "\033[33m "
read -p "    已更新网盘容量？；(yes/no): [no] " input1
echo -e "\e[0m"
if [[ ! -n ${input1} || ${input1} != "yes" ]];then
        exit 0
fi

iscsiadm --mode node --portal 10.100.66.14:3260 --login     #登陆存储

sleep 3s
lsblk

read -p "    是否继续安装?(yes/no): [no] " input1
echo -e "\e[0m"
if [[ ! -n ${input1} || ${input1} != "yes" ]];then
        exit 0
fi

growpart /dev/sdb 1

sleep 3s

resize2fs -f  /dev/sdb1

mount -o discard /dev/sdb1 /wwwroot
