Skip to content

Commit 6f9489b

Browse files
committed
fix: Enforce volume removal and recreation in post_install script
1 parent 49cd994 commit 6f9489b

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

scripts/post_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
2424
cd "$SCRIPT_DIR"
2525

2626
./setup_docker_modules_link.sh $FORCE_FLAG
27-
./setup_docker_volume.sh
27+
./setup_docker_volume.sh $FORCE_FLAG
2828
./setup_isaac_link.sh
2929

3030
echo "Post Install Done."

scripts/setup_docker_volume.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
#!/bin/bash -e
22

3+
# Parse command line arguments
4+
FORCE_REMOVE=false
5+
while [[ $# -gt 0 ]]; do
6+
case $1 in
7+
-f|--force)
8+
FORCE_REMOVE=true
9+
shift
10+
;;
11+
*)
12+
echo "Unknown option: $1"
13+
echo "Usage: $0 [-f|--force]"
14+
echo " -f, --force Force removal of existing volumes"
15+
exit 1
16+
;;
17+
esac
18+
done
19+
320
# Get the directory of this script.
421
# Reference: https://stackoverflow.com/q/59895
522
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
623

7-
# Create docker volume
8-
docker volume create ros2-gazebo-cache >/dev/null
9-
docker volume create ros2-isaac-sim-cache >/dev/null
10-
docker volume create ros2-isaac-ros-assets >/dev/null
24+
volumes=(ros2-gazebo-cache ros2-isaac-sim-cache ros2-isaac-ros-assets)
25+
26+
# Check for existing volumes
27+
for v in "${volumes[@]}"; do
28+
if docker volume inspect "$v" >/dev/null 2>&1; then
29+
if [ "$FORCE_REMOVE" = true ]; then
30+
docker volume rm "$v" >/dev/null
31+
else
32+
echo "Error: Docker volume '$v' already exists."
33+
echo "Run with -f to remove existing volumes and continue."
34+
exit 1
35+
fi
36+
fi
37+
done
38+
39+
# Create docker volumes
40+
for v in "${volumes[@]}"; do
41+
docker volume create "$v" >/dev/null
42+
done
1143

1244
echo "Set up docker volume done."

0 commit comments

Comments
 (0)