您的位置:首页 > 其它

hell script自动搭建简单的iscsi服务器

2013-03-04 17:15 351 查看
#!/bin/bash

#Shell name:conf_iscsi.sh

#

#Program:

# config for iscis

#Author: pero

#Email: perofu.com@gmail.com

#

#History:

# 2012/8/13

#Usage:

#

#If you have any opinion please contact me

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:.

export PATH

if [ $UID -ne 0 ]

then

echo "Run as root"

exit 77

fi

read -p "please input a name of LVG which is really in you system: " lvg

read -p "please input a sizes to be created: " size

read -p "Please input a name for logic volume : " lvn

lvcreate -L ${size}G -n $lvn $lvg

if [ $? -ne 0 ]

then

echo "Please check the $lvn and $lvg are right ... "

exit 77

fi

soft=$(rpm -qa |grep scsi-target |wc -l)

if [ $soft -eq 0 ]

then

yum install scsi-target-* -y

fi

/etc/init.d/tgtd restart &> /dev/null

read -p "Please input a name of tid: " tidn

read -p "Please input a number of tid: " tid

read -p "Please input a number of lun: " lun

tgtadm --lld iscsi --mode target --op new --tid $tid -T $tidn

if [ $? -ne 0 ]

then

echo "Please check the $tid and $tidn are right ... "

exit 77

fi

tgtadm --lld iscsi --mode logicalunit --op new --tid $tid --lun $lun -b /dev/${lvg}/${lvn}

if [ $? -ne 0 ]

then

echo "Please check the $lun is right ... "

exit 77

fi

#read -p "Please input a subnet like " net

#if [ -n $net ]

#then

# tgtadm --lld iscsi --mode target --op bind --tid $tid -I $net

#else

# net=ALL

# tgtadm --lld iscsi --mode target --op bind --tid $tid -I ALL

#fi

tgtadm --lld iscsi --mode target --op bind --tid $tid -I ALL

if [ $? -ne 0 ]

then

echo "Please check the $tid and $tidn are right ... "

exit 77

else

echo "It's ok..."

fi

本文出自 “无咎” 博客,请务必保留此出处http://perofu.blog.51cto.com/6061242/1144575
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: