Index: scripts/usb_unmount.sh =================================================================== diff -u -r468de49b0616e53a79b1100d9dbc87a7ca82e2b0 -re3f3836273d068ae1bd0b0c5d6a9d25765d34aba --- scripts/usb_unmount.sh (.../usb_unmount.sh) (revision 468de49b0616e53a79b1100d9dbc87a7ca82e2b0) +++ scripts/usb_unmount.sh (.../usb_unmount.sh) (revision e3f3836273d068ae1bd0b0c5d6a9d25765d34aba) @@ -6,29 +6,47 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file unmountUSB.sh +# @file usb_mount.sh # # @author (last) Behrouz NematiPour -# @date (last) 11-May-2021 +# @date (last) 15-Jan-2025 # @author (original) Behrouz NematiPour -# @date (original) 11-May-2021 +# @date (original) 15-Jan-2025 # ############################################################################ -# $1 - usb device -# $2 - usb drive +# Description +# Trys to unmount the given usb device from the usb drive/location. +# Parameters +# $1: usb device full path +# $2: usb drive full path (mount point) +# Retruns +# No specific response +# Considerations +# No specific considerations. -sudo umount $2 -if [ $? != 0 ]; then - echo "usb drive '$2' cannot be unmounted." - exit 1001 -fi +# sources +. ./_errors_ +. ./_functions_ -mkdir -p "$2" -if [ $? != 0 ]; then - echo "usb mount point '$2' cannot be removed." - exit 1002 -fi +# variables +PARAM_COUNT=2 +USB_DEVICE="$(trim "$1")" +USB_FOLDER="$(trim "$2")" +# functions + +# checks +check_param_count "$#" "$PARAM_COUNT" +check_empty_string "$USB_DEVICE" "$ERR_MTPARAM_USB_DEVICE" +check_empty_string "$USB_FOLDER" "$ERR_MTPARAM_USB_FOLDER" + +sudo umount "$USB_FOLDER" +check_result "$?" "$ERR_CMDFAIL_USB_DEVICE_UMOUNT" + +rmdir "$USB_FOLDER" +check_result "$?" "$ERR_CMDFAIL_USB_FOLDER_REMOVE" + +sleep 0.1 echo "" exit 0 \ No newline at end of file