Skip to content

Commit 5c3f74b

Browse files
committed
add sudo if not sufficient
1 parent 7b7268e commit 5c3f74b

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

.docker/jazzy.amd64.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh
4545
RUN bash install.sh
4646

4747
# Install Ardusub
48-
ADD https://raw.githubusercontent.com/IOES-Lab/dave/ardusub_install/\
48+
ADD https://raw.githubusercontent.com/IOES-Lab/dave/dockertest/\
4949
extras/ardusub-ubuntu-install.sh install.sh
5050
RUN bash install.sh
5151

.docker/jazzy.arm64v8.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh
101101
RUN bash install.sh
102102

103103
# Install Ardusub
104-
ADD https://raw.githubusercontent.com/IOES-Lab/dave/ardusub_install/\
104+
ADD https://raw.githubusercontent.com/IOES-Lab/dave/dockertest/\
105105
extras/ardusub-ubuntu-install.sh install.sh
106106
RUN bash install.sh
107107

@@ -162,7 +162,7 @@ RUN mkdir -p /home/docker/.config/autostart && \
162162
printf '\033[1;32m\n =====\n\033[0m' >> ~/.hi && \
163163
printf "\\033[1;32m 👋 Hi! This is Docker virtual environment\n\\033[0m" \
164164
>> ~/.hi && \
165-
printf "\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic\n\n\n\\033[0m" \
165+
printf "\\033[1;33m\tROS2 Jazzy - Gazebo Harmonic (w ardusub)\n\n\n\\033[0m" \
166166
>> ~/.hi
167167

168168
# Remove sudo message

extras/ardusub-ubuntu-install.sh

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
#!/bin/bash
22

3-
mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
3+
mkdir -p "/opt/ardupilot_dave" 2>/dev/null
4+
if [ $? -ne 0 ]; then
5+
echo "Insufficient privileges to create directory in /opt."
6+
sudo mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
7+
else
8+
mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
9+
fi
10+
411
# Really should do version pinning but Sub-4.5 is waaaay behind master
512
# (e.g. it doesn't know about "noble" yet)
613
export ARDUPILOT_RELEASE=master
7-
git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
14+
mkdir -p "/opt/ardupilot_dave/ardupilot" 2>/dev/null
15+
if [ $? -ne 0 ]; then
16+
sudo git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
17+
else
18+
git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
19+
fi
820

921
# Install ArduSub dependencies
1022
cd "/opt/ardupilot_dave/ardupilot" || exit
@@ -18,18 +30,36 @@ Tools/environment_install/install-prereqs-ubuntu.sh -y
1830
# Build ArduSub
1931
cd "/opt/ardupilot_dave/ardupilot" || exit
2032
# needs python binary (e.g. sudo apt install python-is-python3)
21-
apt-get install -y python-is-python3 python3-future
22-
modules/waf/waf-light configure --board still \
33+
mkdir -p "/opt/ardupilot_dave/ardupilot/mktest" 2>/dev/null
34+
if [ $? -ne 0 ]; then
35+
sudo modules/waf/waf-light configure --board still \
36+
&& sudo modules/waf/waf-light build --target bin/ardusub
37+
else
38+
modules/waf/waf-light configure --board still \
2339
&& modules/waf/waf-light build --target bin/ardusub
40+
fi
2441

2542
# Clone ardupilot_gazebo code
2643
cd "/opt/ardupilot_dave" || exit
27-
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
44+
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo" 2>/dev/null
45+
if [ $? -ne 0 ]; then
46+
sudo git clone https://github.com/ArduPilot/ardupilot_gazebo.git
47+
else
48+
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
49+
fi
2850

2951
# Install ardupilot_gazebo plugin
30-
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \
31-
&& cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
32-
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2
52+
# Check if the directory creation was successful
53+
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" 2>/dev/null
54+
if [ $? -ne 0 ]; then
55+
echo "Insufficient privileges to create directory in /opt. Using sudo for cmake and make."
56+
sudo mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \
57+
&& cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
58+
sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && sudo make -j2
59+
else
60+
cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
61+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2
62+
fi
3363

3464
# Add results of ArduSub build
3565
export PATH=/opt/ardupilot_dave/ardupilot/build/still/bin:\$PATH

0 commit comments

Comments
 (0)