|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Initialize variables with default values |
| 4 | +ram_version="https://github.com/JdeRobot/RoboticsApplicationManager.git" |
| 5 | +branch="humble-devel" |
| 6 | +radi_version="humble" |
| 7 | +gpu_mode="false" |
| 8 | +nvidia="false" |
| 9 | +compose_file="dev_humble_cpu" |
| 10 | + |
| 11 | +# Loop through the arguments using a while loop |
| 12 | +while getopts ":r:b:i:g:n" opt; do |
| 13 | + case $opt in |
| 14 | + r) ram_version="$OPTARG" ;; |
| 15 | + b) branch="$OPTARG" ;; |
| 16 | + i) radi_version="$OPTARG" ;; |
| 17 | + g) gpu_mode="true" ;; |
| 18 | + n) nvidia="true" ;; |
| 19 | + \?) echo "Invalid option: -$OPTARG" >&2 ;; # If an invalid option is provided, print an error message |
| 20 | + esac |
| 21 | +done |
| 22 | + |
| 23 | +echo "RAM src: $ram_version" |
| 24 | +echo "RAM branch: $branch" |
| 25 | +echo "RoboticsBackend version: $radi_version" |
| 26 | + |
| 27 | +# Install docker-compose if not installed |
| 28 | +if ! command -v docker-compose &> /dev/null; then |
| 29 | + sudo apt install docker-compose |
| 30 | +fi |
| 31 | + |
| 32 | +# Clone the desired RAM fork and branch |
| 33 | +if ! [ -d src ]; then |
| 34 | + git clone $ram_version -b $branch src; |
| 35 | + chown -R $(id -u):$(id -g) src/ |
| 36 | +fi |
| 37 | + |
| 38 | +# Prepare nvm |
| 39 | +export NVM_DIR=$HOME/.nvm; |
| 40 | +source $NVM_DIR/nvm.sh; |
| 41 | +if ! command -v nvm &> /dev/null; then |
| 42 | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash |
| 43 | + export NVM_DIR=$HOME/.nvm; |
| 44 | + source $NVM_DIR/nvm.sh; |
| 45 | +fi |
| 46 | + |
| 47 | +# Prepare yarn |
| 48 | +if ! command -v yarn --version &> /dev/null; then |
| 49 | + npm install --global yarn |
| 50 | +fi |
| 51 | + |
| 52 | +# Prepare the frontend |
| 53 | +nvm install 16 |
| 54 | +nvm use 16 |
| 55 | +cd react_frontend/ |
| 56 | +yarn install |
| 57 | +yarn build |
| 58 | +cd .. |
| 59 | + |
| 60 | +# Prepare the compose file |
| 61 | +if [ "$gpu_mode" = "true" ]; then |
| 62 | + compose_file="dev_humble_gpu" |
| 63 | +fi |
| 64 | +if [ "$nvidia" = "true" ]; then |
| 65 | + compose_file="dev_humble_nvidia" |
| 66 | +fi |
| 67 | +cp compose_cfg/$compose_file.yaml docker-compose.yaml |
| 68 | + |
| 69 | +# Proceed with docker-compose commands |
| 70 | +if [ "$nvidia" = "true" ]; then |
| 71 | + docker compose --compatibility up |
| 72 | +else |
| 73 | + docker compose up |
| 74 | +fi |
| 75 | +docker compose down; |
| 76 | +rm docker-compose.yaml |
0 commit comments