mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-12 05:42:59 +00:00
Add systemd service documentation to README and update install script for dynamic user detection
This commit is contained in:
64
README.md
64
README.md
@@ -225,3 +225,67 @@ LEDMatrix/
|
|||||||
## Fonts
|
## Fonts
|
||||||
You can add any font to the assets/fonts/ folder but they need to be .ttf and updated in display_manager.py
|
You can add any font to the assets/fonts/ folder but they need to be .ttf and updated in display_manager.py
|
||||||
|
|
||||||
|
## Systemd Service Installation
|
||||||
|
|
||||||
|
The LEDMatrix can be installed as a systemd service to run automatically at boot and be managed easily. The service runs as root to ensure proper hardware timing access for the LED matrix.
|
||||||
|
|
||||||
|
### Installing the Service
|
||||||
|
|
||||||
|
1. Make the install script executable:
|
||||||
|
```bash
|
||||||
|
chmod +x install_service.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Run the install script with sudo:
|
||||||
|
```bash
|
||||||
|
sudo ./install_service.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The script will:
|
||||||
|
- Detect your user account and home directory
|
||||||
|
- Install the service file with the correct paths
|
||||||
|
- Enable the service to start on boot
|
||||||
|
- Start the service immediately
|
||||||
|
|
||||||
|
### Managing the Service
|
||||||
|
|
||||||
|
The following commands are available to manage the service:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Stop the display
|
||||||
|
sudo systemctl stop ledmatrix.service
|
||||||
|
|
||||||
|
# Start the display
|
||||||
|
sudo systemctl start ledmatrix.service
|
||||||
|
|
||||||
|
# Check service status
|
||||||
|
sudo systemctl status ledmatrix.service
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
journalctl -u ledmatrix.service
|
||||||
|
|
||||||
|
# Disable autostart
|
||||||
|
sudo systemctl disable ledmatrix.service
|
||||||
|
|
||||||
|
# Enable autostart
|
||||||
|
sudo systemctl enable ledmatrix.service
|
||||||
|
```
|
||||||
|
|
||||||
|
### Convenience Scripts
|
||||||
|
|
||||||
|
Two convenience scripts are provided for easy service management:
|
||||||
|
|
||||||
|
- `start_display.sh` - Starts the LED matrix display service
|
||||||
|
- `stop_display.sh` - Stops the LED matrix display service
|
||||||
|
|
||||||
|
Make them executable with:
|
||||||
|
```bash
|
||||||
|
chmod +x start_display.sh stop_display.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then use them to control the service:
|
||||||
|
```bash
|
||||||
|
sudo ./start_display.sh
|
||||||
|
sudo ./stop_display.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,27 @@
|
|||||||
# Exit on error
|
# Exit on error
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Installing LED Matrix Display Service..."
|
# 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)
|
||||||
|
|
||||||
|
echo "Installing LED Matrix Display Service for user: $ACTUAL_USER"
|
||||||
|
echo "Using home directory: $USER_HOME"
|
||||||
|
|
||||||
|
# Create a temporary service file with the correct paths
|
||||||
|
sed "s|/home/ledpi|$USER_HOME|g" ledmatrix.service > /tmp/ledmatrix.service.tmp
|
||||||
|
|
||||||
# Copy the service file to the systemd directory
|
# Copy the service file to the systemd directory
|
||||||
sudo cp ledmatrix.service /etc/systemd/system/
|
sudo cp /tmp/ledmatrix.service.tmp /etc/systemd/system/ledmatrix.service
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm /tmp/ledmatrix.service.tmp
|
||||||
|
|
||||||
# Reload systemd to recognize the new service
|
# Reload systemd to recognize the new service
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
|||||||
Reference in New Issue
Block a user