-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01defa0
commit 0d0ac58
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/sh | ||
|
||
# Initialize variables with default values | ||
ram_version="https://github.com/JdeRobot/RoboticsApplicationManager.git" | ||
branch="humble-devel" | ||
radi_version="humble" | ||
gpu_mode="false" | ||
nvidia="false" | ||
compose_file="dev_humble_cpu" | ||
|
||
# Loop through the arguments using a while loop | ||
while getopts ":r:b:i:g:n" opt; do | ||
case $opt in | ||
r) ram_version="$OPTARG" ;; | ||
b) branch="$OPTARG" ;; | ||
i) radi_version="$OPTARG" ;; | ||
g) gpu_mode="true" ;; | ||
n) nvidia="true" ;; | ||
\?) echo "Invalid option: -$OPTARG" >&2 ;; # If an invalid option is provided, print an error message | ||
esac | ||
done | ||
|
||
echo "RAM src: $ram_version" | ||
echo "RAM branch: $branch" | ||
echo "RoboticsBackend version: $radi_version" | ||
|
||
# Install docker-compose if not installed | ||
if ! command -v docker-compose &> /dev/null; then | ||
sudo apt install docker-compose | ||
fi | ||
|
||
# Clone the desired RAM fork and branch | ||
if ! [ -d src ]; then | ||
git clone $ram_version -b $branch src; | ||
chown -R $(id -u):$(id -g) src/ | ||
fi | ||
|
||
# Prepare nvm | ||
export NVM_DIR=$HOME/.nvm; | ||
source $NVM_DIR/nvm.sh; | ||
if ! command -v nvm &> /dev/null; then | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | ||
export NVM_DIR=$HOME/.nvm; | ||
source $NVM_DIR/nvm.sh; | ||
fi | ||
|
||
# Prepare yarn | ||
if ! command -v yarn --version &> /dev/null; then | ||
npm install --global yarn | ||
fi | ||
|
||
# Prepare the frontend | ||
nvm install 16 | ||
nvm use 16 | ||
cd react_frontend/ | ||
yarn install | ||
yarn build | ||
cd .. | ||
|
||
# Prepare the compose file | ||
if [ "$gpu_mode" = "true" ]; then | ||
compose_file="dev_humble_gpu" | ||
fi | ||
if [ "$nvidia" = "true" ]; then | ||
compose_file="dev_humble_nvidia" | ||
fi | ||
cp compose_cfg/$compose_file.yaml docker-compose.yaml | ||
|
||
# Proceed with docker-compose commands | ||
if [ "$nvidia" = "true" ]; then | ||
docker compose --compatibility up | ||
else | ||
docker compose up | ||
fi | ||
docker compose down; | ||
rm docker-compose.yaml |