Fix deployment to use git clone instead of copying files

This commit is contained in:
timmyhadwen
2025-12-21 16:58:56 +10:00
parent 4010ffc01b
commit 05cec3718f
2 changed files with 15 additions and 24 deletions

View File

@@ -30,14 +30,11 @@ sudo apt update
sudo apt install -y python3 python3-pip python3-venv libusb-1.0-0-dev
```
### Step 2: Clone/Copy the Project
### Step 2: Clone the Repository
```bash
# Create project directory
mkdir -p ~/brother-ql-bridge
cd ~/brother-ql-bridge
# Copy files: bridge.py, config.py, pyproject.toml, requirements.txt
git clone https://github.com/timmyhadwen/brother-ql-bridge.git
cd brother-ql-bridge
```
### Step 3: Setup Python Environment

View File

@@ -1,13 +1,13 @@
#!/bin/bash
# Brother QL Bridge - Raspberry Pi Deployment Script
# Run this from within the cloned repository
set -e
INSTALL_DIR="${INSTALL_DIR:-$HOME/brother-ql-bridge}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
echo "=== Brother QL Bridge Deployment ==="
echo "Install directory: $INSTALL_DIR"
echo "Project directory: $PROJECT_DIR"
echo ""
# Check if running on Raspberry Pi
@@ -19,32 +19,26 @@ if [[ ! -f /proc/device-tree/model ]] || ! grep -q "Raspberry Pi" /proc/device-t
fi
# Step 1: Install system dependencies
echo "[1/5] Installing system dependencies..."
echo "[1/4] Installing system dependencies..."
sudo apt update
sudo apt install -y python3 python3-pip python3-venv libusb-1.0-0-dev
# Step 2: Install uv if not present
echo "[2/5] Setting up Python package manager..."
echo "[2/4] Setting up Python package manager..."
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
fi
# Step 3: Setup project
echo "[3/5] Setting up project..."
mkdir -p "$INSTALL_DIR"
cp "$PROJECT_DIR/bridge.py" "$INSTALL_DIR/"
cp "$PROJECT_DIR/config.py" "$INSTALL_DIR/"
cp "$PROJECT_DIR/requirements.txt" "$INSTALL_DIR/"
cp "$PROJECT_DIR/pyproject.toml" "$INSTALL_DIR/"
cd "$INSTALL_DIR"
# Step 3: Setup Python environment
echo "[3/4] Installing Python dependencies..."
cd "$PROJECT_DIR"
uv venv
uv pip install -r requirements.txt
# Step 4: Setup udev rules
echo "[4/5] Configuring USB permissions..."
echo "[4/4] Configuring USB permissions..."
if [[ ! -f /etc/udev/rules.d/99-brother-ql.rules ]]; then
sudo tee /etc/udev/rules.d/99-brother-ql.rules > /dev/null << 'EOF'
# Brother QL label printers
@@ -58,7 +52,7 @@ else
fi
# Step 5: Install systemd service
echo "[5/5] Installing systemd service..."
echo "Installing systemd service..."
sudo tee /etc/systemd/system/brother-ql-bridge.service > /dev/null << EOF
[Unit]
Description=Brother QL USB-to-Network Bridge
@@ -67,8 +61,8 @@ After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=$INSTALL_DIR
ExecStart=$INSTALL_DIR/.venv/bin/python bridge.py
WorkingDirectory=$PROJECT_DIR
ExecStart=$PROJECT_DIR/.venv/bin/python bridge.py
Restart=always
RestartSec=10
@@ -92,4 +86,4 @@ echo "To view logs:"
echo " sudo journalctl -u brother-ql-bridge -f"
echo ""
echo "To test manually:"
echo " cd $INSTALL_DIR && source .venv/bin/activate && python bridge.py -v"
echo " cd $PROJECT_DIR && source .venv/bin/activate && python bridge.py -v"