mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-08-21 10:29:06 +00:00
git tracks five scripts as mode 644 that first_time_install.sh then chmods to
755 (start_display.sh, stop_display.sh, the two install_*_service.sh, and
one-shot-install.sh does the same to first_time_install.sh). With
core.fileMode true, the default on Linux, git reports all five as modified
from then on, in files the user never touched.
The update button stashes local changes before pulling, so it is not blocked
by this. But it never pops that stash -- stash pop and stash apply appear
nowhere in the update flow -- so the mode change is stashed away and left
there, and the files revert:
=== file modes after the update button's stash ===
664 first_time_install.sh <- installer had made these 755
664 start_display.sh
664 stop_display.sh
664 scripts/install/install_service.sh
So every web-UI update silently strips the executable bit from the installer's
own scripts, and leaves a stash entry holding the difference. start_display.sh
and stop_display.sh stop working from the shell afterwards.
A manual `git pull --rebase` over SSH fails outright, since nothing stashes for
it: "cannot pull with rebase: You have unstaged changes". That is the likely
source of the reports, since plenty of people update that way.
Tracking the five as 755 -- what they should always have been, as the
installer chmodding them attests -- removes the spurious mode change
entirely: nothing to stash, nothing stripped, no stash entry, and manual
pulls work.
The pull also passes --autostash, for the case the code explicitly tolerates:
when the stash fails it logs a warning and pulls anyway, and that pull is what
then fails. Autostash also pops what it stashes, which the manual stash does
not.
Note that `git add -A` after `git update-index --chmod=+x` silently reverts
the index to the on-disk mode, so the modes here were set by chmodding the
files themselves.
Regression test asserts the five stay tracked executable; reverting any one
of them fails it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STMbQE4YctTacQXfbYqKuW
126 lines
4.3 KiB
Bash
Executable File
126 lines
4.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit on error
|
|
set -e
|
|
|
|
# Get the actual user who invoked sudo
|
|
if [ -n "$SUDO_USER" ]; then
|
|
ACTUAL_USER="$SUDO_USER"
|
|
else
|
|
ACTUAL_USER=$(whoami)
|
|
fi
|
|
|
|
# Get the home directory of the actual user
|
|
USER_HOME=$(eval echo ~$ACTUAL_USER)
|
|
|
|
# Determine the Project Root Directory (parent of scripts/install/)
|
|
PROJECT_ROOT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
|
|
|
|
echo "Installing LED Matrix Display Service for user: $ACTUAL_USER"
|
|
echo "Using home directory: $USER_HOME"
|
|
echo "Project root directory: $PROJECT_ROOT_DIR"
|
|
|
|
# Create a temporary service file for the main display with the correct paths
|
|
# Assuming ledmatrix.service template exists and uses /home/ledpi as a placeholder for user home
|
|
if [ -f "$PROJECT_ROOT_DIR/systemd/ledmatrix.service" ]; then
|
|
sed "s|/home/ledpi|$USER_HOME|g; s|__PROJECT_ROOT_DIR__|$PROJECT_ROOT_DIR|g; s|__USER__|root|g" "$PROJECT_ROOT_DIR/systemd/ledmatrix.service" > /tmp/ledmatrix.service.tmp
|
|
# Copy the service file to the systemd directory
|
|
sudo cp /tmp/ledmatrix.service.tmp /etc/systemd/system/ledmatrix.service
|
|
# Clean up
|
|
rm /tmp/ledmatrix.service.tmp
|
|
else
|
|
echo "WARNING: ledmatrix.service template not found at $PROJECT_ROOT_DIR/systemd/ledmatrix.service. Main display service not configured."
|
|
fi
|
|
|
|
|
|
# Reload systemd to recognize the new service (or modified service)
|
|
sudo systemctl daemon-reload
|
|
|
|
if [ -f "/etc/systemd/system/ledmatrix.service" ]; then
|
|
echo "Enabling ledmatrix.service (main display) to start on boot..."
|
|
sudo systemctl enable ledmatrix.service
|
|
echo "Starting ledmatrix.service (main display)..."
|
|
sudo systemctl start ledmatrix.service
|
|
else
|
|
echo "Skipping enable/start for ledmatrix.service as it was not configured."
|
|
fi
|
|
|
|
# === LEDMatrix Web Interface service (ledmatrix-web.service) ===
|
|
echo "Installing LEDMatrix Web Interface service (ledmatrix-web.service)..."
|
|
|
|
WEB_SERVICE_FILE_CONTENT=$(cat <<EOF
|
|
[Unit]
|
|
Description=LED Matrix Web Interface (Conditional Start)
|
|
After=network.target
|
|
# Wants=ledmatrix.service
|
|
# After=network.target ledmatrix.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
ExecStart=/usr/bin/python3 ${PROJECT_ROOT_DIR}/scripts/utils/start_web_conditionally.py
|
|
WorkingDirectory=${PROJECT_ROOT_DIR}
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
User=${ACTUAL_USER}
|
|
Restart=on-failure
|
|
# Environment="PYTHONUNBUFFERED=1"
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
)
|
|
|
|
# Write the new service file
|
|
echo "$WEB_SERVICE_FILE_CONTENT" | sudo tee /etc/systemd/system/ledmatrix-web.service > /dev/null
|
|
|
|
echo "Reloading systemd daemon for web service..."
|
|
sudo systemctl daemon-reload
|
|
|
|
echo "Enabling ledmatrix-web.service to start on boot..."
|
|
sudo systemctl enable ledmatrix-web.service
|
|
|
|
echo "Starting ledmatrix-web.service..."
|
|
sudo systemctl start ledmatrix-web.service
|
|
|
|
echo "LEDMatrix Web Interface service (ledmatrix-web.service) installation complete."
|
|
echo "It will start based on the 'web_display_autostart' setting in config/config.json."
|
|
# === End of LEDMatrix Web Interface service ===
|
|
|
|
|
|
# Check the status
|
|
echo "Service status for main display (ledmatrix.service):"
|
|
sudo systemctl status ledmatrix.service || echo "ledmatrix.service not found or failed to get status."
|
|
echo "Service status for web interface (ledmatrix-web.service):"
|
|
sudo systemctl status ledmatrix-web.service || echo "ledmatrix-web.service not found or failed to get status."
|
|
|
|
echo ""
|
|
echo "LED Matrix Services have been processed."
|
|
echo ""
|
|
echo "To stop the main display when you SSH in:"
|
|
echo " sudo systemctl stop ledmatrix.service"
|
|
echo "To stop the web interface:"
|
|
echo " sudo systemctl stop ledmatrix-web.service"
|
|
|
|
echo ""
|
|
echo "To check if the main display service is running:"
|
|
echo " sudo systemctl status ledmatrix.service"
|
|
echo "To check if the web interface service is running:"
|
|
echo " sudo systemctl status ledmatrix-web.service"
|
|
|
|
echo ""
|
|
echo "To restart the main display service:"
|
|
echo " sudo systemctl restart ledmatrix.service"
|
|
echo "To restart the web interface service:"
|
|
echo " sudo systemctl restart ledmatrix-web.service"
|
|
|
|
echo ""
|
|
echo "To view logs for the main display:"
|
|
echo " journalctl -u ledmatrix.service"
|
|
echo "To view logs for the web interface:"
|
|
echo " journalctl -u ledmatrix-web.service"
|
|
|
|
echo ""
|
|
echo "To disable autostart for the main display:"
|
|
echo " sudo systemctl disable ledmatrix.service"
|
|
echo "To disable autostart for the web interface:"
|
|
echo " sudo systemctl disable ledmatrix-web.service" |