3.0 KiB
Environment Configuration Setup
This document explains how to configure the Video Player system using environment variables.
Environment File Setup
The system now supports reading configuration from a .env file. This allows you to customize the user, group, and other settings without modifying the installation scripts.
Creating the Environment File
-
Copy the template file:
cp templates/env.template .env -
Edit the
.envfile with your preferred settings:nano .env
Available Configuration Variables
| Variable | Default | Description |
|---|---|---|
USER |
pi |
System user to run the video player service |
GROUP |
pi |
System group for the user |
VIDEO_FOLDER |
/home/pi/Videos |
Directory containing video files |
SERVICE_NAME |
video-player |
Name of the systemd service |
INSTALL_DIR |
/opt/video_player |
Installation directory |
CONFIG_DIR |
/etc/video_player |
Configuration directory |
GPIO_GROUP |
gpio |
Group for GPIO access |
LOG_FILE |
/var/log/video_player.log |
Log file path |
LOG_LEVEL |
INFO |
Logging level |
DISPLAY |
:0 |
X11 display |
XAUTHORITY |
/home/pi/.Xauthority |
X11 authority file |
Example .env File
# System User Configuration
USER=myuser
GROUP=myuser
# Video Configuration
VIDEO_FOLDER=/home/myuser/Videos
# Service Configuration
SERVICE_NAME=video-player
INSTALL_DIR=/opt/video_player
CONFIG_DIR=/etc/video_player
# GPIO Configuration
GPIO_GROUP=gpio
# Logging Configuration
LOG_FILE=/var/log/video_player.log
LOG_LEVEL=INFO
# Display Configuration
DISPLAY=:0
XAUTHORITY=/home/myuser/.Xauthority
Installation Process
-
Create your .env file (as described above)
-
Run the installation script:
sudo ./install.shThe script will:
- Load configuration from your
.envfile - Create the specified user and group if they don't exist
- Set up the service with the correct user/group
- Configure file permissions appropriately
- Load configuration from your
-
Verify the installation:
video-player-test
Troubleshooting
User/Group Issues
If you encounter permission errors:
-
Check that the user exists:
id $USER -
Check that the user is in the GPIO group:
groups $USER -
If needed, manually add the user to the GPIO group:
sudo usermod -a -G gpio $USER
Service Issues
If the service fails to start:
-
Check the service status:
sudo systemctl status video-player -
Check the logs:
sudo journalctl -u video-player -f -
Verify the service file has the correct user/group:
sudo systemctl cat video-player
Uninstallation
To uninstall the system:
-
Create your .env file (if not already done)
-
Run the uninstall script:
sudo ./uninstall.sh
The uninstall script will use the same configuration from your .env file to properly clean up the installation.