working parsing

master
lub 5 years ago
commit 92fbd0b4c5

@ -0,0 +1,63 @@
version: "3.2"
services:
teamspeak:
image: docker.io/teamspeak
deploy:
replicas: 1
placement:
constraints: [node.labels.gluster == true]
depends_on:
- mariadb
environment:
- TS3SERVER_DB_PLUGIN=ts3db_mariadb
- TS3SERVER_DB_SQLCREATEPATH=create_mariadb
- TS3SERVER_DB_HOST=mariadb
- TS3SERVER_DB_USER=teamspeak
- TS3SERVER_DB_NAME=teamspeak
- TS3SERVER_LICENSE=accept
ports:
- target: 9987
published: "145.239.119.128:42842"
protocol: udp
mode: ingress
- target: 30033
mode: ingress
volumes:
- "/gluster/docker/gamemodeon-teamspeak_teamspeak/var/ts3server/:/var/ts3server/"
networks:
- database
- teamspeak
mariadb:
image: docker.io/mariadb
deploy:
replicas: 1
placement:
constraints: [node.hostname == stan.lubi.link]
environment:
- MYSQL_USER=teamspeak
- MYSQL_DATABASE=teamspeak
- MYSQL_RANDOM_ROOT_PASSWORD=yes
volumes:
- "/mnt/gamemodeon-teamspeak_mariadb/var/lib/mysql/:/var/lib/mysql/"
networks:
- database
synapse:
image: matrixdotorg/synapse
deploy:
replicas: 1
placement:
constraints: [node.labels.gluster == true]
depends_on:
- postgres
environment:
- SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
volumes:
- "/gluster/docker/imninja_synapse/data/:/data/"
ports:
- "145.239.119.128:8448:8448"
- "145.239.119.128:42933:443"
networks:
- homeserver
- database
- lubiland-lb

@ -0,0 +1,55 @@
#Requires -Modules powershell-yaml
$ErrorActionPreference = 'Stop'
foreach($yaml in (Get-ChildItem -Filter '*.yml')) {
Write-Output ('Processing {0}' -f $yaml)
$definition = Get-Content -Path $yaml -Raw | ConvertFrom-Yaml
foreach($port in $definition.services.Values.ports) {
$nat = @{
protocol = $null
public_ip = $null
public_port = $null
internal_port = $null
}
if($port.Count -eq 4) {
#long form
$published_splitted = $port.published -split ':'
$nat.protocol = $port.protocol
$nat.public_ip = $published_splitted[0]
$nat.public_port = $port.target
$nat.internal_port = $published_splitted[1]
} else {
#short form
$ports_splitted = $port -split ':'
$nat.public_ip = $ports_splitted[0]
$nat.public_port = $ports_splitted[2]
$nat.internal_port = $ports_splitted[1]
}
if(!$nat.protocol) {
#this is also Docker's default
$nat.protocol = 'tcp'
}
if($nat.Values -contains $null) {
#if $nat doesn't conatain all needed attributes skip the port
$error_message = 'Skipping port, because $nat contains $null: {0}' `
-f ($nat | ConvertTo-Json)
Write-Error -Message $error_message `
-ErrorAction Continue
continue
}
if($nat.internal_port -ne $nat.public_port) {
Write-Output ('Additional NAT rule required, because published {0} and target {1} differ' `
-f $nat.internal_port,$nat.public_port)
$nat.protocol
$nat.public_ip
$nat.public_port
$nat.internal_port
}
}
}
Loading…
Cancel
Save