fix script and systemd service for manager

This commit is contained in:
jr-k 2024-05-17 12:29:00 +02:00
parent 08dd69217d
commit 4592ffffa9
5 changed files with 10 additions and 21 deletions

View File

@ -48,7 +48,7 @@ sudo apt-get update
sudo apt-get install -y git python3-pip python3-venv sudo apt-get install -y git python3-pip python3-venv
# Get files # Get files
git clone https://github.com/jr-k/obscreen.git && cd obscreen cd ~ && git clone https://github.com/jr-k/obscreen.git && cd obscreen
# Install application dependencies # Install application dependencies
python3 -m venv venv python3 -m venv venv

View File

@ -7,7 +7,7 @@
## 🎛️ Hardware installation ## 🎛️ Hardware installation
1. Download RaspberryPi Imager and setup an sdcard with `Raspberry Pi OS Lite` (🚨without desktop, only `Lite` version!). You'll find it under category `Raspberry PI OS (other)` 1. Download RaspberryPi Imager and setup an sdcard with `Raspberry Pi OS Lite` (🚨without desktop, only `Lite` version!). You'll find it under category `Raspberry PI OS (other)`
2. Log into your pi user locally or via ssh (`ssh pi@raspberrypi.local`) 2. Log into your RaspberryPi locally or via ssh (by default it's `ssh pi@raspberrypi.local`)
## 📺 Run the player ## 📺 Run the player
Install player autorun by executing following script Install player autorun by executing following script
@ -65,7 +65,7 @@ sudo apt-get update
sudo apt-get install -y git python3-pip python3-venv sudo apt-get install -y git python3-pip python3-venv
# Get files # Get files
git clone https://github.com/jr-k/obscreen.git && cd obscreen cd ~ && git clone https://github.com/jr-k/obscreen.git && cd obscreen
# Install application dependencies # Install application dependencies
python3 -m venv venv python3 -m venv venv

View File

@ -1,5 +1,6 @@
import os import os
import re import re
import logging
import subprocess import subprocess
import platform import platform
@ -125,25 +126,14 @@ def get_ip_address() -> Optional[str]:
try: try:
os_name = platform.system().lower() os_name = platform.system().lower()
if os_name == "linux": if os_name == "linux":
result = subprocess.run( result = subprocess.run(["ip", "-4", "route", "get", "8.8.8.8"], capture_output=True, text=True)
["ip", "-4", "route", "get", "8.8.8.8"],
capture_output=True,
text=True
)
ip_address = result.stdout.split()[6] ip_address = result.stdout.split()[6]
elif os_name == "darwin": elif os_name == "darwin":
result = subprocess.run( result = subprocess.run(
["ipconfig", "getifaddr", "en0"], ["ipconfig", "getifaddr", "en0"], capture_output=True, text=True)
capture_output=True,
text=True
)
ip_address = result.stdout.strip() ip_address = result.stdout.strip()
elif os_name == "windows": elif os_name == "windows":
result = subprocess.run( result = subprocess.run(["ipconfig"], capture_output=True, text=True)
["ipconfig"],
capture_output=True,
text=True
)
lines = result.stdout.split('\n') lines = result.stdout.split('\n')
ip_address = None ip_address = None
for line in lines: for line in lines:
@ -151,11 +141,11 @@ def get_ip_address() -> Optional[str]:
ip_address = line.split(': ')[1].strip() ip_address = line.split(': ')[1].strip()
break break
else: else:
print(f"Unsupported OS: {os_name}") logging.warn(f"Unsupported OS: {os_name}")
return None return None
return ip_address return ip_address
except Exception as e: except Exception as e:
print(f"Error obtaining IP address: {e}") logging.error(f"Error obtaining IP address: {e}")
return None return None

View File

@ -4,7 +4,7 @@ OWNER=${1:-$USER}
WORKING_DIR=${2:-$HOME} WORKING_DIR=${2:-$HOME}
echo "### Installing Obscreen Player ###" echo "### Installing Obscreen Player ###"
echo "# Using user: $USER_ARG" echo "# Using user: $OWNER"
echo "# Working Directory: $WORKING_DIR" echo "# Working Directory: $WORKING_DIR"
echo "# ------------------------------ #" echo "# ------------------------------ #"

View File

@ -6,7 +6,6 @@ After=network.target
User=pi User=pi
Group=pi Group=pi
Environment=VIRTUAL_ENV="/home/pi/obscreen/venv" Environment=VIRTUAL_ENV="/home/pi/obscreen/venv"
Environment=PATH="$VIRTUAL_ENV/bin:$PATH"
WorkingDirectory=/home/pi/obscreen WorkingDirectory=/home/pi/obscreen
ExecStart=/home/pi/obscreen/venv/bin/python /home/pi/obscreen/obscreen.py ExecStart=/home/pi/obscreen/venv/bin/python /home/pi/obscreen/obscreen.py
Restart=always Restart=always