### Download and Install piSignage Source: https://docs.pisignage.com/doc/setup/custom-hardware Downloads the software package, sets necessary permissions, and runs the installation script. ```bash wget https://pisignage.com/releases/pi-image-p2-v20.zip ``` ```bash unzip -o pi-image-p2-v20.zip cp player2/build-scripts/install-pisignage.sh . chmod +x install-pisignage.sh chmod +x -R player2/build-scripts chmod +x -R player2/shell-scripts ``` ```bash ./install-pisignage.sh ``` ```bash sudo apt update --fix-missing ``` -------------------------------- ### Configure SSH Server Source: https://docs.pisignage.com/doc/setup/custom-hardware Commands to install, enable, and start the SSH service for remote terminal access. ```bash sudo apt install openssh-server # Install the SSH server sudo systemctl enable ssh # Enable SSH service at boot sudo systemctl start ssh # Start the SSH service (or use sudo systemctl restart ssh if needed) ``` -------------------------------- ### Verify and Install Chromium Source: https://docs.pisignage.com/doc/setup/custom-hardware Checks for existing Chromium installations and installs the browser if missing. ```bash which chromium-browser which chromium # If neither is present, install using the following steps: sudo apt-get -y install chromium-browser # If 'chromium-browser' package is not found: sudo apt-get -y install chromium cd /usr/bin sudo ln -s chromium chromium-browser ``` -------------------------------- ### Compile and Run Signal Example Source: https://docs.pisignage.com/doc/playlists Commands to compile the C signal handler and execute it. ```bash gcc sigusr2_example.c -o sigusr2_example ``` ```bash ./sigusr2_example ``` -------------------------------- ### Manual Software Upgrade Source: https://docs.pisignage.com/doc/setup/custom-hardware Steps to manually upgrade the piSignage software using a zip file. ```bash 1. Copy the pi-image-p2-v14.zip to home directory /home/pi 2. unzip -o pi-image-p2-v14.zip 3. chmod +x -R player2/shell-scripts ``` -------------------------------- ### Upgrade OS Packages Source: https://docs.pisignage.com/doc/setup/custom-hardware Updates the package list and performs a full system upgrade. ```bash sudo apt update sudo apt full-upgrade -y ``` -------------------------------- ### Verify Hostname Configuration Source: https://docs.pisignage.com/doc/setup/custom-hardware Checks the system hostname and ensures it is mapped in the hosts file. ```bash hostname cat hostname otherwise add the same 127.0.0.1 ``` -------------------------------- ### Configure User Permissions Source: https://docs.pisignage.com/doc/setup/custom-hardware Commands to add a user to the sudo group and configure passwordless sudo access. ```bash su - usermod -aG sudo pi ``` ```bash sudo visudo and add the following as last line ALL=(ALL) NOPASSWD:ALL ``` -------------------------------- ### Run and Signal Python Process Source: https://docs.pisignage.com/doc/playlists Commands to execute the Python script and send the SIGUSR2 signal using the kill command. ```bash python3 signal_handler.py ``` ```bash kill -SIGUSR2 # or using the signal number (SIGUSR2 is typically 12) kill -12 ``` -------------------------------- ### Handle SIGUSR2 Signals in C Source: https://docs.pisignage.com/doc/playlists Uses sigaction to catch and handle SIGUSR2 signals in a C program. ```c #include #include #include #include void signal_handler(int signum) { if (signum == SIGUSR2) { printf("\nReceived SIGUSR2 signal!\n"); printf("Performing some action...\n"); } } int main() { struct sigaction sa; // Zero out the structure memset(&sa, 0, sizeof(sa)); // Set the handler function sa.sa_handler = signal_handler; // Install the signal handler for SIGUSR2 if (sigaction(SIGUSR2, &sa, NULL) == -1) { perror("sigaction"); return 1; } printf("My PID is: %d\n", getpid()); printf("Waiting for SIGUSR2...\n"); // Keep the program running while (1) { sleep(1); } return 0; ``` -------------------------------- ### Handle SIGUSR2 in Python Source: https://docs.pisignage.com/doc/playlists Registers a signal handler for SIGUSR2 to perform custom actions when the signal is received. ```python import os import signal import time # Define the signal handler function def receive_sigusr2(signal_number, frame): print(f"\nReceived signal: {signal_number} (SIGUSR2)") print("Performing custom action (e.g., reloading config, toggling a GPIO pin)...") # Register the SIGUSR2 signal handler signal.signal(signal.SIGUSR2, receive_sigusr2) print(f"My PID is: {os.getpid()}") print("Waiting for SIGUSR2... (Press Ctrl+C to exit)") # Keep the program running indefinitely while True: time.sleep(1) ```