Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
exit when path does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Heavybullets8 committed Aug 20, 2023
1 parent 73391ba commit 432efbc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion functions/pvc/unmount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ unmount_app_func(){
unmount_array=()

for app in "${apps[@]}"; do
# Check if the directory exists
if [ ! -d "/mnt/mounted_pvc/$app" ]; then
echo -e "${red}Error:${reset} The directory '/mnt/mounted_pvc/$app' does not exist."
exit 1
fi

mapfile -t unmount_array < <(find "/mnt/mounted_pvc/$app" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' 2>/dev/null )

# Check if the unmount_array is empty
if [[ -z ${unmount_array[*]} ]]; then
echo -e "${yellow}$app's directory is empty, removing directory..${reset}"
Expand Down

0 comments on commit 432efbc

Please sign in to comment.