- 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
+11 -3
View File
@@ -7,6 +7,7 @@ MOUNT_DIR="/home/dunestorm/VMs"
show_usage (){
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;
}
@@ -16,10 +17,10 @@ check_dir (){
if [ "$file_count" -ge 1 ]
then
echo ""
echo "Directory has been mounted at:" $MOUNT_DIR
echo "Directory is mounted at:" $MOUNT_DIR
else
echo ""
echo "Directory has been un-mounted from:" $MOUNT_DIR
echo "Directory is un-mounted from:" $MOUNT_DIR
fi
}
@@ -34,6 +35,7 @@ fi
while (( "$#" )); do
case "$1" in
-m|--mount)
echo "[Attempting to mount iSCSI volume]"
iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --login
sleep 3
mount /dev/disk/by-uuid/$DISK_UUID $MOUNT_DIR
@@ -41,11 +43,17 @@ while (( "$#" )); do
exit 0;
;;
-u|--umount)
echo "[Attempting to un-mount iSCSI volume]"
umount $MOUNT_DIR
iscsiadm --mode node --targetname $IQN --portal $PORTAL_IP --logout
check_dir
exit 0;
;;
-s|--status)
echo "[Showing status of mount-point]"
check_dir
exit 0;
;;
-*)
show_usage
;;
@@ -56,4 +64,4 @@ while (( "$#" )); do
if [[ $# -eq 0 ]]
then
show_usage
fi
fi