#!/bin/bash IQN=$1 if [ -z "${IQN}" ]; then echo "usage: $0 TargetIQN" echo "" exit fi FOLDER="/mnt/iSCSI_${IQN}" if [ -d "${FOLDER}" ]; then umount /mnt/iSCSI_${IQN} RETURNCODE=$? if [ "${RETURNCODE}" != "0" ]; then echo "Unmount of ${FOLDER} failed" else echo "Unmount of ${FOLDER} succeed" fi rm -rf "${FOLDER}" else echo "${FOLDER} doesn't exist" fi iscsiadm -m node -T ${IQN} -u &> /dev/null RETURNCODE=$? if [ "${RETURNCODE}" != "0" ]; then echo "Logout of ${IQN} failed" else echo "Logout of ${IQN} succeeded" fi echo ""