diff --git a/install_service.sh b/install_service.sh new file mode 100644 index 00000000..faeef717 --- /dev/null +++ b/install_service.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Exit on error +set -e + +# Get the current user +CURRENT_USER=$(whoami) + +echo "Installing LED Matrix Display Service for user: $CURRENT_USER..." + +# Copy the service file to the systemd directory +sudo cp ledmatrix.service /etc/systemd/system/ + +# Create a systemd override to set the user +sudo mkdir -p /etc/systemd/system/ledmatrix.service.d/ +echo "[Service]" | sudo tee /etc/systemd/system/ledmatrix.service.d/override.conf +echo "User=$CURRENT_USER" | sudo tee -a /etc/systemd/system/ledmatrix.service.d/override.conf + +# Reload systemd to recognize the new service +sudo systemctl daemon-reload + +# Enable the service to start on boot +sudo systemctl enable ledmatrix.service + +# Start the service now +sudo systemctl start ledmatrix.service + +# Check the status +echo "Service status:" +sudo systemctl status ledmatrix.service + +echo "" +echo "LED Matrix Display Service has been installed and started." +echo "" +echo "To stop the display when you SSH in:" +echo " sudo systemctl stop ledmatrix.service" +echo "" +echo "To check if the service is running:" +echo " sudo systemctl status ledmatrix.service" +echo "" +echo "To restart the service:" +echo " sudo systemctl restart ledmatrix.service" +echo "" +echo "To view logs:" +echo " journalctl -u ledmatrix.service" +echo "" +echo "To disable autostart:" +echo " sudo systemctl disable ledmatrix.service" \ No newline at end of file diff --git a/ledmatrix.service b/ledmatrix.service new file mode 100644 index 00000000..b76dc894 --- /dev/null +++ b/ledmatrix.service @@ -0,0 +1,17 @@ +[Unit] +Description=LED Matrix Display Service +After=network.target + +[Service] +Type=simple +User=%i +WorkingDirectory=/home/%i/LEDMatrix +ExecStart=/usr/bin/sudo /usr/bin/python3 /home/%i/LEDMatrix/display_controller.py +Restart=on-failure +RestartSec=10 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=ledmatrix + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/start_display.sh b/start_display.sh new file mode 100644 index 00000000..df9fcb92 --- /dev/null +++ b/start_display.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Get the current user +CURRENT_USER=$(whoami) + +echo "Starting LED Matrix Display Service for user: $CURRENT_USER..." + +# Start the service +sudo systemctl start ledmatrix.service + +# Check the status +echo "Service status:" +sudo systemctl status ledmatrix.service + +echo "" +echo "LED Matrix Display Service has been started." +echo "" +echo "To stop the service:" +echo " sudo systemctl stop ledmatrix.service" \ No newline at end of file diff --git a/stop_display.sh b/stop_display.sh new file mode 100644 index 00000000..da37b27c --- /dev/null +++ b/stop_display.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Get the current user +CURRENT_USER=$(whoami) + +echo "Stopping LED Matrix Display Service for user: $CURRENT_USER..." + +# Stop the service +sudo systemctl stop ledmatrix.service + +# Check the status +echo "Service status:" +sudo systemctl status ledmatrix.service + +echo "" +echo "LED Matrix Display Service has been stopped." +echo "" +echo "To start the service again:" +echo " sudo systemctl start ledmatrix.service" \ No newline at end of file