Files
infoscreen-dev/scripts/restart-all.sh
2026-03-29 13:10:33 +02:00

72 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -e
cd "$(dirname "$0")/.."
echo "Restarting infoscreen services..."
# Kill existing processes first
./scripts/kill-all.sh
sleep 2
# Load .env for environment variables
if [ -f .env ]; then
set -a
source .env
set +a
fi
# Create log directory if it doesn't exist
mkdir -p logs
# Set up display environment for screenshots
# Required for X11/Wayland screenshot capture when started from SSH
export DISPLAY="${DISPLAY:-:0}"
export XAUTHORITY="${XAUTHORITY:-$HOME/.Xauthority}"
# Wayland sessions also need runtime dir and display socket.
USER_UID="$(id -u)"
if [ -z "$XDG_RUNTIME_DIR" ] && [ -d "/run/user/$USER_UID" ]; then
export XDG_RUNTIME_DIR="/run/user/$USER_UID"
fi
if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$XDG_RUNTIME_DIR" ] && [ -d "$XDG_RUNTIME_DIR" ]; then
if [ -S "$XDG_RUNTIME_DIR/wayland-0" ]; then
export WAYLAND_DISPLAY="wayland-0"
else
WAYLAND_SOCKET="$(find "$XDG_RUNTIME_DIR" -maxdepth 1 -type s -name 'wayland-*' | head -n 1)"
if [ -n "$WAYLAND_SOCKET" ]; then
export WAYLAND_DISPLAY="$(basename "$WAYLAND_SOCKET")"
fi
fi
fi
if [ -n "$WAYLAND_DISPLAY" ]; then
export XDG_SESSION_TYPE="wayland"
fi
echo "📺 Display env: DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-<unset>} XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-<unset>}"
# Start simclient.py with nohup (persists after SSH disconnect)
echo "Starting simclient.py..."
nohup ./scripts/start-dev.sh > logs/simclient.log 2>&1 &
SIMCLIENT_PID=$!
echo "✓ simclient.py started (PID: $SIMCLIENT_PID)"
# Start display_manager.py with nohup (persists after SSH disconnect)
echo "Starting display_manager.py..."
nohup env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" WAYLAND_DISPLAY="$WAYLAND_DISPLAY" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" XDG_SESSION_TYPE="$XDG_SESSION_TYPE" ./scripts/start-display-manager.sh > logs/display_manager.log 2>&1 &
DISPLAY_PID=$!
echo "✓ display_manager.py started (PID: $DISPLAY_PID)"
echo ""
echo "Both services are running and will persist after SSH disconnect."
echo ""
echo "Monitor logs:"
echo " tail -f logs/simclient.log"
echo " tail -f logs/display_manager.log"
echo ""
echo "Kill processes:"
echo " ./scripts/kill-all.sh"