Debian trixie-based build-compile-deploy workflow

This commit is contained in:
Mikkeli Matlock
2026-01-24 23:18:37 +09:00
parent 90ed757976
commit aabca4915c
8 changed files with 311 additions and 36 deletions

View File

@@ -6,6 +6,11 @@ set -e
echo "=== Smart Serow Pi Setup ==="
# Use current user (whoever is running this script on the Pi)
PI_USER="${USER:-$(whoami)}"
PI_UID=$(id -u "$PI_USER")
echo "Setting up for user: $PI_USER (uid: $PI_UID)"
# Check if running on Pi (arm architecture)
ARCH=$(uname -m)
if [[ "$ARCH" != "aarch64" && "$ARCH" != "armv7l" ]]; then
@@ -15,11 +20,12 @@ fi
APP_DIR="/opt/smartserow"
SERVICE_FILE="/etc/systemd/system/smartserow-ui.service"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Create app directory
echo "Creating app directory: $APP_DIR"
sudo mkdir -p "$APP_DIR/bundle"
sudo chown -R pi:pi "$APP_DIR"
sudo chown -R "$PI_USER:$PI_USER" "$APP_DIR"
# Install runtime dependencies for flutter-elinux
echo "Installing runtime dependencies..."
@@ -41,11 +47,15 @@ sudo apt-get install -y \
libx11-6 \
libxkbcommon-x11-0
# Copy systemd service
# Generate systemd service with correct user
echo "Installing systemd service..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/smartserow-ui.service" ]; then
sudo cp "$SCRIPT_DIR/smartserow-ui.service" "$SERVICE_FILE"
# Patch the template with actual user values
sed -e "s/User=.*/User=$PI_USER/" \
-e "s/Group=.*/Group=$PI_USER/" \
-e "s|HOME=/home/.*|HOME=/home/$PI_USER|" \
-e "s|XDG_RUNTIME_DIR=/run/user/.*|XDG_RUNTIME_DIR=/run/user/$PI_UID|" \
"$SCRIPT_DIR/smartserow-ui.service" | sudo tee "$SERVICE_FILE" > /dev/null
else
echo "WARNING: Service file not found at $SCRIPT_DIR/smartserow-ui.service"
echo "Copy it manually to $SERVICE_FILE"
@@ -56,11 +66,11 @@ echo "Enabling service..."
sudo systemctl daemon-reload
sudo systemctl enable smartserow-ui
# Add pi user to required groups for DRM/KMS access
echo "Setting up permissions..."
sudo usermod -aG video pi
sudo usermod -aG input pi
sudo usermod -aG render pi 2>/dev/null || true
# Add user to required groups for DRM/KMS access
echo "Setting up permissions for $PI_USER..."
sudo usermod -aG video "$PI_USER"
sudo usermod -aG input "$PI_USER"
sudo usermod -aG render "$PI_USER" 2>/dev/null || true
echo ""
echo "=== Setup Complete ==="