add a service for the auracast script

This commit is contained in:
pstruebi
2025-08-19 15:13:55 +02:00
parent e2187df572
commit 6e021de1c7
4 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Auracast Multicast Script
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/caster/bumble-auracast
ExecStart=/home/caster/.local/bin/poetry run python src/auracast/multicast_script.py
Restart=on-failure
Environment=PYTHONUNBUFFERED=1
Environment=LOG_LEVEL=INFO
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,84 @@
#!/bin/bash
set -euo pipefail
# Print status of relevant services and warn if mutually exclusive ones are running.
# Utilities (network audio):
# - ptp_aes67.service (system)
# - pipewire-aes67.service (user)
# App services (mutually exclusive groups):
# - auracast-script.service (user)
# - auracast-server.service (prefer user; also check system)
# - auracast-frontend.service (system)
print_status() {
local scope="$1" # "system" or "user"
local unit="$2"
local act="unknown"
local ena="unknown"
if [[ "$scope" == "user" ]]; then
act=$(systemctl --user is-active "$unit" 2>/dev/null || true)
ena=$(systemctl --user is-enabled "$unit" 2>/dev/null || true)
else
act=$(systemctl is-active "$unit" 2>/dev/null || true)
ena=$(systemctl is-enabled "$unit" 2>/dev/null || true)
fi
act="${act:-unknown}"
ena="${ena:-unknown}"
printf " - %-24s [%s] active=%-10s enabled=%s\n" "$unit" "$scope" "$act" "$ena"
}
is_active() {
local scope="$1" unit="$2"
if [[ "$scope" == "user" ]]; then
systemctl --user is-active "$unit" &>/dev/null && echo yes || echo no
else
systemctl is-active "$unit" &>/dev/null && echo yes || echo no
fi
}
hr() { printf '\n%s\n' "----------------------------------------"; }
printf "AURACAST SERVICE STATUS\n"
hr
printf "Utilities (required for network audio)\n"
print_status system ptp_aes67.service
print_status user pipewire-aes67.service
PTP_ACTIVE=$(is_active system ptp_aes67.service)
PW_ACTIVE=$(is_active user pipewire-aes67.service)
if [[ "$PTP_ACTIVE" == "yes" && "$PW_ACTIVE" == "yes" ]]; then
echo " ✓ Utilities ready for AES67/network audio"
else
echo " ! Utilities not fully active (AES67/network audio may not work)"
fi
hr
printf "Application services (mutually exclusive)\n"
print_status user auracast-script.service
print_status user auracast-server.service
print_status system auracast-server.service
print_status system auracast-frontend.service
SCRIPT_ACTIVE=$(is_active user auracast-script.service)
SERVER_USER_ACTIVE=$(is_active user auracast-server.service)
SERVER_SYS_ACTIVE=$(is_active system auracast-server.service)
FRONT_ACTIVE=$(is_active system auracast-frontend.service)
# Consider server active if either user or system instance is active
if [[ "$SERVER_USER_ACTIVE" == "yes" || "$SERVER_SYS_ACTIVE" == "yes" ]]; then
SERVER_ACTIVE=yes
else
SERVER_ACTIVE=no
fi
if [[ "$SCRIPT_ACTIVE" == "yes" && ( "$SERVER_ACTIVE" == "yes" || "$FRONT_ACTIVE" == "yes" ) ]]; then
echo " ! WARNING: 'auracast-script' and 'server/frontend' are running together (mutually exclusive)."
fi
hr
printf "Hints\n"
echo " - Follow logs (user): journalctl --user -u auracast-script.service -f"
echo " - Follow logs (server): journalctl --user -u auracast-server.service -f || journalctl -u auracast-server.service -f"
echo " - Frontend logs: journalctl -u auracast-frontend.service -f"

View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -e
# This script stops and disables the auracast-script user service
# Stop service
systemctl --user stop auracast-script.service || true
# Disable service from starting on login
systemctl --user disable auracast-script.service || true
echo "\n--- auracast-script.service status (user) ---"
systemctl --user status auracast-script.service --no-pager || true
echo "auracast-script service stopped, disabled, and status printed successfully."

View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -e
# This script installs, enables, and restarts the auracast-script user service
# No sudo is required as it is a user service
# Copy user service file for auracast-script
mkdir -p /home/caster/.config/systemd/user
cp /home/caster/bumble-auracast/src/service/auracast-script.service /home/caster/.config/systemd/user/auracast-script.service
# Reload systemd to recognize new/updated services
systemctl --user daemon-reload
# Enable service to start on user login
systemctl --user enable auracast-script.service
# Restart service
systemctl --user restart auracast-script.service
echo "\n--- auracast-script.service status (user) ---"
systemctl --user status auracast-script.service --no-pager
echo "auracast-script service updated, enabled, restarted, and status printed successfully."