Created
October 25, 2025 16:22
-
-
Save GoXLd/a3ce0bbb9637f7ae4181e909d0226c5a to your computer and use it in GitHub Desktop.
TeamSpeak3 script installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # === Paramètres === | |
| LOG_FILE="/root/install_ts3.log" | |
| IP_SERVER="${IP_SERVER:-}" | |
| TS_VERSION="3.13.7" | |
| TS_PKG="teamspeak3-server_linux_amd64-${TS_VERSION}.tar.bz2" | |
| TS_URL="https://files.teamspeak-services.com/releases/server/${TS_VERSION}/${TS_PKG}" | |
| TS_USER="teamspeak" | |
| TS_GROUP="teamspeak" | |
| TS_HOME="/opt/teamspeak" | |
| TS_LOG_DIR="/var/log/teamspeak" | |
| # === Préparation === | |
| echo -e "\n$(date +'%F %T') :: Installation du serveur TeamSpeak 3 version ${TS_VERSION}\n" | tee -a "$LOG_FILE" | |
| if [[ "$(id -u)" -ne 0 ]]; then | |
| echo "Ce script doit être exécuté en tant que root." | tee -a "$LOG_FILE" | |
| exit 1 | |
| fi | |
| if ! command -v systemctl >/dev/null 2>&1; then | |
| echo "Systemd n’a pas été trouvé. Ce script nécessite systemd." | tee -a "$LOG_FILE" | |
| exit 1 | |
| fi | |
| if [[ -z "${IP_SERVER}" ]]; then | |
| IP_SERVER="0.0.0.0" | |
| fi | |
| # Installation des dépendances | |
| if command -v apt-get >/dev/null 2>&1; then | |
| apt-get update -y >>"$LOG_FILE" 2>&1 || true | |
| apt-get install -y wget tar bzip2 >>"$LOG_FILE" 2>&1 | |
| elif command -v dnf >/dev/null 2>&1; then | |
| dnf install -y wget tar bzip2 >>"$LOG_FILE" 2>&1 | |
| elif command -v yum >/dev/null 2>&1; then | |
| yum install -y wget tar bzip2 >>"$LOG_FILE" 2>&1 | |
| fi | |
| # Création de l’utilisateur système | |
| if ! id -u "$TS_USER" >/dev/null 2>&1; then | |
| useradd --system --home-dir "$TS_HOME" --shell /usr/sbin/nologin "$TS_USER" | |
| fi | |
| mkdir -p "$TS_HOME" "$TS_LOG_DIR" | |
| chown -R "$TS_USER":"$TS_GROUP" "$TS_HOME" "$TS_LOG_DIR" | |
| # Téléchargement et extraction | |
| TMPD="$(mktemp -d)" | |
| trap 'rm -rf "$TMPD"' EXIT | |
| echo "Téléchargement de ${TS_URL}..." | tee -a "$LOG_FILE" | |
| wget -q -O "${TMPD}/${TS_PKG}" "$TS_URL" | |
| tar -xjf "${TMPD}/${TS_PKG}" -C "$TMPD" | |
| cp -a "${TMPD}/teamspeak3-server_linux_amd64/." "$TS_HOME/" | |
| # Fichier de configuration | |
| cat > "${TS_HOME}/ts3server.ini" <<EOF | |
| machine_id= | |
| default_voice_port=9987 | |
| voice_ip=${IP_SERVER} | |
| licensepath= | |
| filetransfer_port=30033 | |
| filetransfer_ip=${IP_SERVER} | |
| query_port=10011 | |
| query_ip=${IP_SERVER} | |
| query_ip_whitelist=query_ip_whitelist.txt | |
| query_ip_blacklist=query_ip_blacklist.txt | |
| dbplugin=ts3db_sqlite3 | |
| dbconnections=10 | |
| logpath=${TS_LOG_DIR}/ | |
| logquerycommands=0 | |
| EOF | |
| # Acceptation de la licence | |
| touch "${TS_HOME}/.ts3server_license_accepted" | |
| chown "$TS_USER":"$TS_GROUP" "${TS_HOME}/.ts3server_license_accepted" | |
| chown -R "$TS_USER":"$TS_GROUP" "$TS_HOME" | |
| # Service systemd | |
| cat > /etc/systemd/system/teamspeak3.service <<'UNIT' | |
| [Unit] | |
| Description=TeamSpeak 3 Server | |
| Wants=network-online.target | |
| After=network-online.target | |
| [Service] | |
| Type=simple | |
| User=teamspeak | |
| Group=teamspeak | |
| WorkingDirectory=/opt/teamspeak | |
| Environment=TS3SERVER_LICENSE=accept | |
| ExecStart=/opt/teamspeak/ts3server inifile=ts3server.ini | |
| Restart=on-failure | |
| RestartSec=5s | |
| LimitNOFILE=1048576 | |
| [Install] | |
| WantedBy=multi-user.target | |
| UNIT | |
| # Activation et démarrage | |
| systemctl daemon-reload | |
| systemctl enable --now teamspeak3.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment