Smart iSCSI Mounter v0.96

- The status function now lists active connections.
- Active iSCSI connections are now tested for when mounting/un-mounting
targets.
- The force flag is now required to override mounting/un-mounting
exceptions.
This commit is contained in:
2020-05-21 17:44:29 +01:00
parent 08c9458929
commit 6f6bb50444
+21 -1
View File
@@ -9,6 +9,7 @@ MONITOR_PROC_CNT=7
# Do not modify
_MONITOR_PROC_CNT=$(pgrep -f $MONITOR_PROC | wc -l)
_ISCSI_CON_CNT=$(iscsiadm -m session | wc -l)
_FLAG_FORCE=0
show_usage (){
@@ -32,6 +33,10 @@ check_dir (){
echo ""
echo "Directory is un-mounted from:" $MOUNT_DIR
fi
echo ""
echo "The below iSCSI connection(s) is/are open:"
echo "$(iscsiadm -m session)"
}
check_proc_status (){
@@ -46,6 +51,14 @@ check_proc_status (){
mount_func (){
echo "[Attempting to mount iSCSI volume]"
if [[ ${_ISCSI_CON_CNT} -gt 0 ]] && [[ $_FLAG_FORCE -eq 0 ]]
then
echo "WARNING: You're already connected to an iSCSI target."
echo "Use the -f (--force) flag to bypass this warning."
exit 2;
fi
iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --login
sleep 3
mount /dev/disk/by-uuid/$DISK_UUID $MOUNT_DIR -o noauto,noperm
@@ -59,6 +72,13 @@ umount_func (){
check_proc_status
fi
if [[ ${_ISCSI_CON_CNT} -eq 0 ]] && [[ $_FLAG_FORCE -eq 0 ]]
then
echo "WARNING: You're not currently connected to an iSCSI target."
echo "Use the -f (--force) flag to bypass this warning."
exit 2;
fi
umount -l $MOUNT_DIR
sleep 3
iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --logout
@@ -95,7 +115,7 @@ while (( "$#" )); do
check_dir
;;
-r|--release)
echo "Smart iSCSI Mounter v0.95"
echo "Smart iSCSI Mounter v0.96"
;;
-*)
show_usage