From 778dd95047de0d95e7008f8b23543b144df897e3 Mon Sep 17 00:00:00 2001 From: "derek.smithson" Date: Sat, 14 Feb 2026 17:01:47 -0700 Subject: [PATCH 1/2] fix: ensure install.sh uses LF line endings for Linux compatibility Add .gitattributes to force LF endings on shell scripts, fixing "No such file or directory" errors when running on a Raspberry Pi from a Windows-authored script. Co-Authored-By: Claude Opus 4.6 --- .gitattributes | 2 + docs/sd_card/install.sh | 274 ++++++++++++++++++++-------------------- 2 files changed, 139 insertions(+), 137 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..403ff24 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Ensure shell scripts always have LF line endings, even on Windows +*.sh text eol=lf diff --git a/docs/sd_card/install.sh b/docs/sd_card/install.sh index 291e660..91761df 100644 --- a/docs/sd_card/install.sh +++ b/docs/sd_card/install.sh @@ -1,137 +1,137 @@ -#!/bin/bash -set -euo pipefail - -# Spyder Tally Controller - Install Script -# This script installs the Spyder Tally Controller application on a Raspberry Pi. -# It auto-detects architecture (arm64 vs arm32) and installs the correct binary. -# -# Usage: -# tar xzf spyder-tally-linux-arm64.tar.gz # (or linux-arm) -# cd spyder-tally-linux-arm64/ # (or linux-arm) -# sudo ./install.sh - -INSTALL_DIR="/opt/spyder-tally" -SERVICE_NAME="SpyderTallies" - -# --- Preflight checks --- - -if [ "$(id -u)" -ne 0 ]; then - echo "Error: This script must be run as root (use sudo ./install.sh)" - exit 1 -fi - -# Determine the real user who invoked sudo -INSTALL_USER="${SUDO_USER:-$(whoami)}" -if [ "$INSTALL_USER" = "root" ]; then - echo "Error: Please run this script with sudo from a regular user account, not as root directly." - exit 1 -fi - -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" - -# --- Architecture detection --- - -ARCH="$(uname -m)" -case "$ARCH" in - aarch64) - EXPECTED_RID="linux-arm64" - ;; - armv7l|armv6l) - EXPECTED_RID="linux-arm" - ;; - *) - echo "Error: Unsupported architecture '$ARCH'. Expected aarch64 (arm64) or armv7l/armv6l (arm32)." - exit 1 - ;; -esac - -# Check that the binary in this package matches the detected architecture -if [ ! -f "$SCRIPT_DIR/bin/SpyderTallyControllerWebApp" ]; then - echo "Error: Binary not found at $SCRIPT_DIR/bin/SpyderTallyControllerWebApp" - echo "" - echo "Detected architecture: $ARCH ($EXPECTED_RID)" - echo "Make sure you downloaded the correct package for your Pi:" - echo " - Raspberry Pi 4/5 (64-bit OS): spyder-tally-linux-arm64.tar.gz" - echo " - Raspberry Pi 3 or older (32-bit OS): spyder-tally-linux-arm.tar.gz" - exit 1 -fi - -echo "=== Spyder Tally Controller Installer ===" -echo "Detected architecture: $ARCH ($EXPECTED_RID)" -echo "Installing as user: $INSTALL_USER" -echo "Install directory: $INSTALL_DIR" -echo "" - -# --- Stop existing service if running --- - -if systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null; then - echo "Stopping existing $SERVICE_NAME service..." - systemctl stop "$SERVICE_NAME" -fi - -# --- Install nginx --- - -echo "Installing nginx..." -apt-get update -qq -apt-get install -y -qq nginx > /dev/null - -# --- Enable I2C --- - -echo "Enabling I2C interface..." -if command -v raspi-config &> /dev/null; then - raspi-config nonint do_i2c 0 -else - echo " Warning: raspi-config not found - skipping I2C setup." - echo " You may need to enable I2C manually if not already enabled." -fi - -# --- Install application --- - -echo "Installing application to $INSTALL_DIR..." -mkdir -p "$INSTALL_DIR" - -# Copy binary -cp "$SCRIPT_DIR/bin/SpyderTallyControllerWebApp" "$INSTALL_DIR/" -chmod +x "$INSTALL_DIR/SpyderTallyControllerWebApp" - -# Copy default config files (only if they don't already exist, to preserve user settings on upgrade) -for config_file in appConfig.json deviceConfig.json; do - if [ ! -f "$INSTALL_DIR/$config_file" ]; then - cp "$SCRIPT_DIR/$config_file" "$INSTALL_DIR/" - echo " Created default $config_file" - else - echo " Keeping existing $config_file (not overwriting)" - fi -done - -# Set ownership so the service user can write config files -chown -R "$INSTALL_USER":"$INSTALL_USER" "$INSTALL_DIR" - -# --- Install nginx config --- - -echo "Installing nginx configuration..." -cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/nginx.conf -nginx -t -q -systemctl restart nginx -systemctl enable nginx - -# --- Install systemd service --- - -echo "Installing systemd service..." -sed "s/__USER__/$INSTALL_USER/g" "$SCRIPT_DIR/SpyderTallies.service" > /etc/systemd/system/SpyderTallies.service -systemctl daemon-reload -systemctl enable "$SERVICE_NAME" -systemctl start "$SERVICE_NAME" - -# --- Done --- - -echo "" -echo "=== Installation complete! ===" -echo "" -echo "The Spyder Tally Controller is now running." -echo " Web UI: http://$(hostname -I | awk '{print $1}')" -echo "" -echo "Useful commands:" -echo " sudo systemctl status $SERVICE_NAME # Check service status" -echo " sudo systemctl restart $SERVICE_NAME # Restart the service" -echo " sudo journalctl -u $SERVICE_NAME -f # Tail the log" +#!/bin/bash +set -euo pipefail + +# Spyder Tally Controller - Install Script +# This script installs the Spyder Tally Controller application on a Raspberry Pi. +# It auto-detects architecture (arm64 vs arm32) and installs the correct binary. +# +# Usage: +# tar xzf spyder-tally-linux-arm64.tar.gz # (or linux-arm) +# cd spyder-tally-linux-arm64/ # (or linux-arm) +# sudo ./install.sh + +INSTALL_DIR="/opt/spyder-tally" +SERVICE_NAME="SpyderTallies" + +# --- Preflight checks --- + +if [ "$(id -u)" -ne 0 ]; then + echo "Error: This script must be run as root (use sudo ./install.sh)" + exit 1 +fi + +# Determine the real user who invoked sudo +INSTALL_USER="${SUDO_USER:-$(whoami)}" +if [ "$INSTALL_USER" = "root" ]; then + echo "Error: Please run this script with sudo from a regular user account, not as root directly." + exit 1 +fi + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +# --- Architecture detection --- + +ARCH="$(uname -m)" +case "$ARCH" in + aarch64) + EXPECTED_RID="linux-arm64" + ;; + armv7l|armv6l) + EXPECTED_RID="linux-arm" + ;; + *) + echo "Error: Unsupported architecture '$ARCH'. Expected aarch64 (arm64) or armv7l/armv6l (arm32)." + exit 1 + ;; +esac + +# Check that the binary in this package matches the detected architecture +if [ ! -f "$SCRIPT_DIR/bin/SpyderTallyControllerWebApp" ]; then + echo "Error: Binary not found at $SCRIPT_DIR/bin/SpyderTallyControllerWebApp" + echo "" + echo "Detected architecture: $ARCH ($EXPECTED_RID)" + echo "Make sure you downloaded the correct package for your Pi:" + echo " - Raspberry Pi 4/5 (64-bit OS): spyder-tally-linux-arm64.tar.gz" + echo " - Raspberry Pi 3 or older (32-bit OS): spyder-tally-linux-arm.tar.gz" + exit 1 +fi + +echo "=== Spyder Tally Controller Installer ===" +echo "Detected architecture: $ARCH ($EXPECTED_RID)" +echo "Installing as user: $INSTALL_USER" +echo "Install directory: $INSTALL_DIR" +echo "" + +# --- Stop existing service if running --- + +if systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null; then + echo "Stopping existing $SERVICE_NAME service..." + systemctl stop "$SERVICE_NAME" +fi + +# --- Install nginx --- + +echo "Installing nginx..." +apt-get update -qq +apt-get install -y -qq nginx > /dev/null + +# --- Enable I2C --- + +echo "Enabling I2C interface..." +if command -v raspi-config &> /dev/null; then + raspi-config nonint do_i2c 0 +else + echo " Warning: raspi-config not found - skipping I2C setup." + echo " You may need to enable I2C manually if not already enabled." +fi + +# --- Install application --- + +echo "Installing application to $INSTALL_DIR..." +mkdir -p "$INSTALL_DIR" + +# Copy binary +cp "$SCRIPT_DIR/bin/SpyderTallyControllerWebApp" "$INSTALL_DIR/" +chmod +x "$INSTALL_DIR/SpyderTallyControllerWebApp" + +# Copy default config files (only if they don't already exist, to preserve user settings on upgrade) +for config_file in appConfig.json deviceConfig.json; do + if [ ! -f "$INSTALL_DIR/$config_file" ]; then + cp "$SCRIPT_DIR/$config_file" "$INSTALL_DIR/" + echo " Created default $config_file" + else + echo " Keeping existing $config_file (not overwriting)" + fi +done + +# Set ownership so the service user can write config files +chown -R "$INSTALL_USER":"$INSTALL_USER" "$INSTALL_DIR" + +# --- Install nginx config --- + +echo "Installing nginx configuration..." +cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/nginx.conf +nginx -t -q +systemctl restart nginx +systemctl enable nginx + +# --- Install systemd service --- + +echo "Installing systemd service..." +sed "s/__USER__/$INSTALL_USER/g" "$SCRIPT_DIR/SpyderTallies.service" > /etc/systemd/system/SpyderTallies.service +systemctl daemon-reload +systemctl enable "$SERVICE_NAME" +systemctl start "$SERVICE_NAME" + +# --- Done --- + +echo "" +echo "=== Installation complete! ===" +echo "" +echo "The Spyder Tally Controller is now running." +echo " Web UI: http://$(hostname -I | awk '{print $1}')" +echo "" +echo "Useful commands:" +echo " sudo systemctl status $SERVICE_NAME # Check service status" +echo " sudo systemctl restart $SERVICE_NAME # Restart the service" +echo " sudo journalctl -u $SERVICE_NAME -f # Tail the log" From 02f0fbe2de4764401fd580435039e6ece82863b0 Mon Sep 17 00:00:00 2001 From: Derek Smithson Date: Sat, 14 Feb 2026 17:44:29 -0700 Subject: [PATCH 2/2] chore: removing nginx install from install.sh --- docs/sd_card/install.sh | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/docs/sd_card/install.sh b/docs/sd_card/install.sh index 91761df..97dc3ce 100644 --- a/docs/sd_card/install.sh +++ b/docs/sd_card/install.sh @@ -69,12 +69,6 @@ if systemctl is-active --quiet "$SERVICE_NAME" 2>/dev/null; then systemctl stop "$SERVICE_NAME" fi -# --- Install nginx --- - -echo "Installing nginx..." -apt-get update -qq -apt-get install -y -qq nginx > /dev/null - # --- Enable I2C --- echo "Enabling I2C interface..." @@ -94,6 +88,12 @@ mkdir -p "$INSTALL_DIR" cp "$SCRIPT_DIR/bin/SpyderTallyControllerWebApp" "$INSTALL_DIR/" chmod +x "$INSTALL_DIR/SpyderTallyControllerWebApp" +# Copy static web assets (CSS, JS, images, etc.) +if [ -d "$SCRIPT_DIR/bin/wwwroot" ]; then + cp -r "$SCRIPT_DIR/bin/wwwroot" "$INSTALL_DIR/" + echo " Installed static web assets" +fi + # Copy default config files (only if they don't already exist, to preserve user settings on upgrade) for config_file in appConfig.json deviceConfig.json; do if [ ! -f "$INSTALL_DIR/$config_file" ]; then @@ -107,14 +107,6 @@ done # Set ownership so the service user can write config files chown -R "$INSTALL_USER":"$INSTALL_USER" "$INSTALL_DIR" -# --- Install nginx config --- - -echo "Installing nginx configuration..." -cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/nginx.conf -nginx -t -q -systemctl restart nginx -systemctl enable nginx - # --- Install systemd service --- echo "Installing systemd service..."