- #!/bin/bash
- #Author:jacky.lee
- #date:2010/4/12
- #Test platform on redhat linux
- #
- #
- #
- #
- main () {
- clear
- echo " -------------------------------------------"
- echo " 1)login iscsi target"
- echo " 2)logout iscsi target"
- echo " 3)Obtain current iscsi session information"
- echo " q)Exit"
- echo " -------------------------------------------"
- while true
- do
- echo -n "Please choice [1-q]:"
- read choice
- case $choice in
- 1)clear
- login
- main
- ;;
- 2)clear
- logout
- exit
- ;;
- 3)
- iscsiadm -m session -P 3
- main
- ;;
- q)clear
- exit
- ;;
- *)clear
- exit
- ;;
- esac
- done
- }
- #
- #define login function
- login () {
- echo " ---------------------------------------------------------------"
- echo " First,discovery the iscsi target,Please input the ip:"
- echo " ---------------------------------------------------------------"
- read ip
- iscsiadm -m discovery -t sendtargets -p $ip:3260
- echo " ---------------------------------------------------------------"
- echo " Second,login the iscsi target,Please input the target_iqn_name:"
- echo " ---------------------------------------------------------------"
- read target_iqn_name
- iscsiadm -m node -T $target_iqn_name -p $ip:3260 -l
- echo " ---------------------------------------------------------------"
- echo " Please use the 'fdisk -l' comand to display the new disk"
- }
- #define logout function
- logout () {
- echo " ----------------------------------------------------------------"
- echo " Please input the ip:"
- echo " ----------------------------------------------------------------"
- read ip
- echo " ----------------------------------------------------------------"
- echo " Second input the target_iqn_name:"
- echo " ----------------------------------------------------------------"
- read target_iqn_name
- iscsiadm -m node -T $target_iqn_name -p $ip:3260 -u
- echo " ----------------------------------------------------------------"
- echo " You were already logout!!!"
- echo " -----------------------------------------------------------------"
- echo " Do you delete the iscsi target record?Please input 'yes' or 'no':"
- echo " -----------------------------------------------------------------"
- read input
- case $input in
- yes) clear
- iscsiadm -m node -T $target_iqn_name -p $ip:3260 -o delete
- chkconfig iscsi off
- ;;
- no) clear
- exit
- ;;
- esac
- }
- #Call the main function
- main
73

被折叠的 条评论
为什么被折叠?



