84 lines
2.3 KiB
Bash
Executable File
84 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# TeamSpeak 3 Headless Runner with Echoion Bot
|
|
# This script sets up the environment and starts TeamSpeak with Weston compositor
|
|
|
|
set -e
|
|
|
|
# Configuration
|
|
USER_NAME="${USER_NAME:-bot}"
|
|
HOME_DIR="/home/${USER_NAME}"
|
|
TS3_DIR="${HOME_DIR}/TeamSpeak3-Client-linux_amd64"
|
|
CONFIG_DIR="${HOME_DIR}/.config"
|
|
RUNTIME_DIR="/tmp/.ts3bot-display-${USER_NAME}"
|
|
CERT_FILE="${CONFIG_DIR}/EchoionTsBot.crt"
|
|
KEY_FILE="${CONFIG_DIR}/EchoionTsBot.key"
|
|
RDP_PORT="${RDP_PORT:-3390}"
|
|
|
|
# Check if running as root
|
|
if [ "$EUID" -eq 0 ]; then
|
|
echo "Please do not run this script as root"
|
|
echo "Run as the bot user: sudo -u ${USER_NAME} $0"
|
|
exit 1
|
|
fi
|
|
|
|
# Create runtime directory
|
|
mkdir -p "${RUNTIME_DIR}"
|
|
chmod 700 "${RUNTIME_DIR}"
|
|
|
|
# Export environment variables
|
|
export XDG_RUNTIME_DIR="${RUNTIME_DIR}"
|
|
export HOME="${HOME_DIR}"
|
|
export USER="${USER_NAME}"
|
|
|
|
# Check if port is already in use
|
|
if ss -tlnp | grep -q ":${RDP_PORT} "; then
|
|
echo "Error: Port ${RDP_PORT} is already in use"
|
|
echo "Choose a different port by setting RDP_PORT environment variable"
|
|
echo "Example: RDP_PORT=3391 $0"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if certificates exist and have correct permissions
|
|
if [ ! -f "${CERT_FILE}" ] || [ ! -f "${KEY_FILE}" ]; then
|
|
echo "Warning: TLS certificates not found at:"
|
|
echo " Cert: ${CERT_FILE}"
|
|
echo " Key: ${KEY_FILE}"
|
|
echo "RDP connections may not work without certificates"
|
|
sleep 2
|
|
else
|
|
# Check permissions - key should be readable by user
|
|
if [ ! -r "${KEY_FILE}" ]; then
|
|
echo "Error: Cannot read key file: ${KEY_FILE}"
|
|
echo "Fix permissions: chmod 600 ${KEY_FILE}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Check if TeamSpeak directory exists
|
|
if [ ! -d "${TS3_DIR}" ]; then
|
|
echo "Error: TeamSpeak directory not found at: ${TS3_DIR}"
|
|
exit 1
|
|
fi
|
|
|
|
cd "${TS3_DIR}"
|
|
|
|
echo "Starting TeamSpeak 3 with Echoion Bot..."
|
|
echo " User: ${USER_NAME}"
|
|
echo " Runtime Dir: ${RUNTIME_DIR}"
|
|
echo " Weston Backend: RDP"
|
|
echo " RDP Port: ${RDP_PORT}"
|
|
echo " TLS Cert: ${CERT_FILE}"
|
|
echo ""
|
|
|
|
# Start dbus-run-session with weston and TeamSpeak
|
|
# Using explicit IP binding and port
|
|
exec dbus-run-session -- \
|
|
weston \
|
|
--backend=rdp \
|
|
--xwayland \
|
|
--rdp-tls-cert="${CERT_FILE}" \
|
|
--rdp-tls-key="${KEY_FILE}" \
|
|
--rdp-address=0.0.0.0 \
|
|
--rdp-port=${RDP_PORT} \
|
|
-- ./ts3client_runscript.sh "$@"
|