#!/bin/bash # Quick start script for TeamSpeak Echoion when systemd user session is not available # This script can be used as a fallback when systemctl --user doesn't work set -e USER_NAME="${USER_NAME:-$(whoami)}" SERVICE_NAME="teamspeak-echoion" echo "TeamSpeak Echoion - Quick Start" echo "===============================" echo "" # Check if we're in a systemd user session if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] || [ -z "$XDG_RUNTIME_DIR" ]; then echo "No systemd user session detected." echo "" echo "You have three options:" echo "" echo "1. Start via systemd (requires session bus - see below)" echo "2. Start manually with the wrapper script" echo "3. Use a tmux/screen session" echo "" echo -e "\033[1;33mOption 1: Using systemd (recommended for production)\033[0m" echo " First, start a proper user session:" echo " - Log in via SSH with a pseudo-terminal: ssh -t user@host bash" echo " - Or enable lingering and reboot:" echo " sudo loginctl enable-linger $USER_NAME" echo " Then:" echo " systemctl --user daemon-reload" echo " systemctl --user start $SERVICE_NAME" echo "" echo -e "\033[1;33mOption 2: Manual start (for testing)\033[0m" echo " ~/echoion/scripts/run-teamspeak-headless.sh" echo "" echo -e "\033[1;33mOption 3: Using tmux\033[0m" echo " tmux new-session -d -s teamspeak '~/echoion/scripts/run-teamspeak-headless.sh'" echo " tmux attach -t teamspeak" echo "" read -p "Would you like to start manually now? (y/N) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "Starting TeamSpeak..." exec ~/echoion/scripts/run-teamspeak-headless.sh else exit 0 fi else # We have a session, try systemd echo "Systemd user session detected!" echo "" # Check if service file exists if [ ! -f "$HOME/.config/systemd/user/$SERVICE_NAME.service" ]; then echo "Service file not found. Please run the install script first:" echo " ~/echoion/scripts/install-service.sh user" exit 1 fi # Check if service is running if systemctl --user is-active --quiet $SERVICE_NAME; then echo "Service is already running!" echo "View status: systemctl --user status $SERVICE_NAME" echo "View logs: journalctl --user -u $SERVICE_NAME -f" else echo "Starting service..." systemctl --user daemon-reload systemctl --user start $SERVICE_NAME sleep 2 if systemctl --user is-active --quiet $SERVICE_NAME; then echo -e "\033[0;32mService started successfully!\033[0m" echo "" echo "Status: systemctl --user status $SERVICE_NAME" echo "Logs: journalctl --user -u $SERVICE_NAME -f" echo "Stop: systemctl --user stop $SERVICE_NAME" else echo -e "\033[0;31mService failed to start. Check logs:\033[0m" echo "journalctl --user -u $SERVICE_NAME --no-pager -n 50" exit 1 fi fi fi