Files
rpi-tulivision/ENV_SETUP.md

136 lines
3.0 KiB
Markdown

# 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
1. Copy the template file:
```bash
cp templates/env.template .env
```
2. Edit the `.env` file with your preferred settings:
```bash
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
```bash
# 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
1. **Create your .env file** (as described above)
2. **Run the installation script**:
```bash
sudo ./install.sh
```
The script will:
- Load configuration from your `.env` file
- Create the specified user and group if they don't exist
- Set up the service with the correct user/group
- Configure file permissions appropriately
3. **Verify the installation**:
```bash
video-player-test
```
## Troubleshooting
### User/Group Issues
If you encounter permission errors:
1. Check that the user exists:
```bash
id $USER
```
2. Check that the user is in the GPIO group:
```bash
groups $USER
```
3. If needed, manually add the user to the GPIO group:
```bash
sudo usermod -a -G gpio $USER
```
### Service Issues
If the service fails to start:
1. Check the service status:
```bash
sudo systemctl status video-player
```
2. Check the logs:
```bash
sudo journalctl -u video-player -f
```
3. Verify the service file has the correct user/group:
```bash
sudo systemctl cat video-player
```
## Uninstallation
To uninstall the system:
1. **Create your .env file** (if not already done)
2. **Run the uninstall script**:
```bash
sudo ./uninstall.sh
```
The uninstall script will use the same configuration from your `.env` file to properly clean up the installation.