|
@@ -20,23 +20,6 @@ cleanup() {
|
|
./power_off_hdd.sh || echo "Failed to power off HDD"
|
|
./power_off_hdd.sh || echo "Failed to power off HDD"
|
|
}
|
|
}
|
|
|
|
|
|
-# Function to retry unmounting
|
|
|
|
-retry_umount() {
|
|
|
|
- local max_retries=5
|
|
|
|
- local count=0
|
|
|
|
- while [ $count -lt $max_retries ]; do
|
|
|
|
- if ./unmount_hdd.sh; then
|
|
|
|
- echo "Successfully unmounted HDD."
|
|
|
|
- return 0
|
|
|
|
- else
|
|
|
|
- echo "Unmount failed. Retrying ($((count + 1))/$max_retries)..."
|
|
|
|
- sleep 15
|
|
|
|
- count=$((count + 1))
|
|
|
|
- fi
|
|
|
|
- done
|
|
|
|
- return 1
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
# Set trap to call cleanup on script exit or error
|
|
# Set trap to call cleanup on script exit or error
|
|
trap 'cleanup' EXIT
|
|
trap 'cleanup' EXIT
|
|
|
|
|
|
@@ -66,7 +49,7 @@ sleep 5
|
|
|
|
|
|
# Unmount HDD
|
|
# Unmount HDD
|
|
echo "Unmounting HDD..."
|
|
echo "Unmounting HDD..."
|
|
-retry_umount || handle_error "unmount_hdd.sh"
|
|
|
|
|
|
+./unmount_hdd.sh || handle_error "unmount_hdd.sh"
|
|
|
|
|
|
# Power off HDD
|
|
# Power off HDD
|
|
echo "Turning off HDD power..."
|
|
echo "Turning off HDD power..."
|