From e72accc181db975b1c47e8478167d998b50cad1c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 13 Nov 2024 18:18:15 +0100 Subject: [PATCH] Add scripts for installing TeamSpeak --- .../teamspeak/docker-compose.base.yml | 19 +++++++ .../teamspeak/docker-compose.secrets.yml | 6 +++ .../docker/services/teamspeak/main.fish | 49 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 scripts/Common/Software/docker/services/teamspeak/docker-compose.base.yml create mode 100644 scripts/Common/Software/docker/services/teamspeak/docker-compose.secrets.yml create mode 100644 scripts/Common/Software/docker/services/teamspeak/main.fish diff --git a/scripts/Common/Software/docker/services/teamspeak/docker-compose.base.yml b/scripts/Common/Software/docker/services/teamspeak/docker-compose.base.yml new file mode 100644 index 00000000..c3b47c59 --- /dev/null +++ b/scripts/Common/Software/docker/services/teamspeak/docker-compose.base.yml @@ -0,0 +1,19 @@ +services: + teamspeak: + image: teamspeak + restart: unless-stopped + depends_on: + - db + environment: + TS3SERVER_DB_PLUGIN: ts3db_mariadb + TS3SERVER_DB_SQLCREATEPATH: create_mariadb + TS3SERVER_DB_HOST: db + TS3SERVER_DB_WAITUNTILREADY: 30 + TS3SERVER_LICENSE: accept + db: + image: mariadb + restart: unless-stopped + environment: + MARIADB_RANDOM_ROOT_PASSWORD: "yes" + volumes: + - ./database:/var/lib/mysql diff --git a/scripts/Common/Software/docker/services/teamspeak/docker-compose.secrets.yml b/scripts/Common/Software/docker/services/teamspeak/docker-compose.secrets.yml new file mode 100644 index 00000000..5c7deae1 --- /dev/null +++ b/scripts/Common/Software/docker/services/teamspeak/docker-compose.secrets.yml @@ -0,0 +1,6 @@ +services: + teamspeak: + ports: + - 9987:9987/udp + - 10011:10011 + - 30033:30033 diff --git a/scripts/Common/Software/docker/services/teamspeak/main.fish b/scripts/Common/Software/docker/services/teamspeak/main.fish new file mode 100644 index 00000000..97687793 --- /dev/null +++ b/scripts/Common/Software/docker/services/teamspeak/main.fish @@ -0,0 +1,49 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + set -l source "$dir/docker-compose.secrets.yml" + source "$dir/../service.fish" + + function installSW -V dir -V domain -V source + set -l service "teamspeak" + set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32") + set -l db "TeamSpeak" + set -l tsEnv "$(getServiceKey "$service").environment" + set -l dbEnv "$(getServiceKey db).environment" + initializeServiceInstallation $argv + cp "$dir/docker-compose.base.yml" (getServiceRoot $argv) + + USER="$service" begin + yq "$tsEnv.TS3SERVER_DB_USER = env.USER" "$source" | \ + yq "$dbEnv.MARIADB_USER = env.USER" + end | \ + PW="$pw" begin + yq "$tsEnv.TS3SERVER_DB_PASSWORD = env.PW" | \ + yq "$dbEnv.MARIADB_PASSWORD = env.PW" + end | \ + DB="$db" begin + yq "$tsEnv.TS3SERVER_DB_NAME = env.DB" | \ + yq "$dbEnv.MARIADB_DATABASE = env.DB" + end | \ + yq . | \ + sudo tee (getServiceSecretsConfig $argv) >/dev/null + + installDockerService $argv + end + + function configureSW -V dir + configureDockerService $argv + end + + function getServiceServers -V server + end + + function getServiceLocations + end + + function getBackupArgs + printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv) + end + + runInstaller --force $argv +end