diff --git a/unmountVolume b/unmountVolume index ee5f33a..c0ad0fe 100755 --- a/unmountVolume +++ b/unmountVolume @@ -2,14 +2,38 @@ IQN=$1 -if [[ -z "${IQN}" ]]; then +if [ -z "${IQN}" ]; then echo "usage: $0 TargetIQN" echo "" exit fi -umount /mnt/iSCSI_${IQN} -rm -rf /mnt/iSCSI_${IQN} -iscsiadm -m node -T ${IQN} -u +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 ""