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