Skip to content

Commit

Permalink
add sudo if not sufficient
Browse files Browse the repository at this point in the history
  • Loading branch information
woensug-choi committed Sep 9, 2024
1 parent 7b7268e commit 5c3f74b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .docker/jazzy.amd64.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh
RUN bash install.sh

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

Expand Down
4 changes: 2 additions & 2 deletions .docker/jazzy.arm64v8.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extras/ros-jazzy-binary-gz-harmonic-source-install.sh install.sh
RUN bash install.sh

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

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

# Remove sudo message
Expand Down
46 changes: 38 additions & 8 deletions extras/ardusub-ubuntu-install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#!/bin/bash

mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
mkdir -p "/opt/ardupilot_dave" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Insufficient privileges to create directory in /opt."
sudo mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
else
mkdir -p "/opt/ardupilot_dave" && cd "/opt/ardupilot_dave" || exit
fi

# Really should do version pinning but Sub-4.5 is waaaay behind master
# (e.g. it doesn't know about "noble" yet)
export ARDUPILOT_RELEASE=master
git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
mkdir -p "/opt/ardupilot_dave/ardupilot" 2>/dev/null
if [ $? -ne 0 ]; then
sudo git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
else
git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
fi

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

# Clone ardupilot_gazebo code
cd "/opt/ardupilot_dave" || exit
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo" 2>/dev/null
if [ $? -ne 0 ]; then
sudo git clone https://github.com/ArduPilot/ardupilot_gazebo.git
else
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
fi

# Install ardupilot_gazebo plugin
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \
&& cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2
# Check if the directory creation was successful
mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Insufficient privileges to create directory in /opt. Using sudo for cmake and make."
sudo mkdir -p "/opt/ardupilot_dave/ardupilot_gazebo/build" \
&& cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && sudo make -j2
else
cd "/opt/ardupilot_dave/ardupilot_gazebo/build" || exit
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2
fi

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

0 comments on commit 5c3f74b

Please sign in to comment.