Improve unmount error handling

This commit is contained in:
2023-05-12 11:15:56 +02:00
parent 2519322aac
commit add03de4a3
+28 -4
View File
@@ -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 ""