- Added support to show mount status

- Showing better verbosity of run commands
This commit is contained in:
2020-05-20 14:40:55 +01:00
parent b7151c57c6
commit a503fcad48
+10 -2
View File
@@ -7,6 +7,7 @@ MOUNT_DIR="/home/dunestorm/VMs"
show_usage (){ show_usage (){
echo "Please use either '-m (--mount)' to mount or '-u (--umount)' to unmount this volume." echo "Please use either '-m (--mount)' to mount or '-u (--umount)' to unmount this volume."
echo "The use of '-s (--status)' is additionally an option."
exit 1; exit 1;
} }
@@ -16,10 +17,10 @@ check_dir (){
if [ "$file_count" -ge 1 ] if [ "$file_count" -ge 1 ]
then then
echo "" echo ""
echo "Directory has been mounted at:" $MOUNT_DIR echo "Directory is mounted at:" $MOUNT_DIR
else else
echo "" echo ""
echo "Directory has been un-mounted from:" $MOUNT_DIR echo "Directory is un-mounted from:" $MOUNT_DIR
fi fi
} }
@@ -34,6 +35,7 @@ fi
while (( "$#" )); do while (( "$#" )); do
case "$1" in case "$1" in
-m|--mount) -m|--mount)
echo "[Attempting to mount iSCSI volume]"
iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --login iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --login
sleep 3 sleep 3
mount /dev/disk/by-uuid/$DISK_UUID $MOUNT_DIR mount /dev/disk/by-uuid/$DISK_UUID $MOUNT_DIR
@@ -41,11 +43,17 @@ while (( "$#" )); do
exit 0; exit 0;
;; ;;
-u|--umount) -u|--umount)
echo "[Attempting to un-mount iSCSI volume]"
umount $MOUNT_DIR umount $MOUNT_DIR
iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --logout iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --logout
check_dir check_dir
exit 0; exit 0;
;; ;;
-s|--status)
echo "[Showing status of mount-point]"
check_dir
exit 0;
;;
-*) -*)
show_usage show_usage
;; ;;