-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·71 lines (57 loc) · 1.69 KB
/
setup.sh
File metadata and controls
executable file
·71 lines (57 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
# === Config ===
# Folder where this script lives = project root
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VENV_DIR="$PROJECT_DIR/venv"
LAUNCHER="$HOME/ros2_debug_desktop_launcher.sh"
ALIAS_NAME="bug" # shortcut command name
echo "=== Setting up ROS 2 Debug Desktop App ==="
echo "Project dir : $PROJECT_DIR"
echo "Venv dir : $VENV_DIR"
echo "Alias : $ALIAS_NAME"
echo
# 1) Create venv if not exists
if [ ! -d "$VENV_DIR" ]; then
echo "[1/3] Creating virtual environment..."
python3 -m venv "$VENV_DIR"
else
echo "[1/3] Virtual environment already exists -> $VENV_DIR"
fi
# 2) Install dependencies
echo "[2/3] Installing Python dependencies..."
# shellcheck source=/dev/null
source "$VENV_DIR/bin/activate"
pip install --upgrade pip
if [ -f "$PROJECT_DIR/requirements.txt" ]; then
pip install -r "$PROJECT_DIR/requirements.txt"
else
echo "ERROR: requirements.txt not found in $PROJECT_DIR"
exit 1
fi
# 3) Create launcher script
echo "[3/3] Creating launcher -> $LAUNCHER"
cat > "$LAUNCHER" <<EOL
#!/bin/bash
set -e
PROJECT_DIR="$PROJECT_DIR"
VENV_DIR="\$PROJECT_DIR/venv"
# Activate venv
# shellcheck source=/dev/null
source "\$VENV_DIR/bin/activate"
cd "\$PROJECT_DIR"
# Run app
python3 ros2_debug_desktop/main.py
EOL
chmod +x "$LAUNCHER"
# Add alias in ~/.bashrc if not present
if ! grep -q "alias $ALIAS_NAME=" "$HOME/.bashrc"; then
echo "alias $ALIAS_NAME=\"$LAUNCHER\"" >> "$HOME/.bashrc"
echo "Alias '$ALIAS_NAME' added to ~/.bashrc"
else
echo "Alias '$ALIAS_NAME' already exists in ~/.bashrc"
fi
echo
echo "=== Setup complete ==="
echo "Now run: source ~/.bashrc"
echo "Then launch app from anywhere using: $ALIAS_NAME"