Compare commits

..

51 commits

Author SHA1 Message Date
e07626c4dc Add scripts for installing TrackMania server 2024-11-20 00:33:09 +01:00
55be9bc645 Replace yq with go-yq 2024-11-20 00:30:08 +01:00
96fbe54532 Add scripts for installing TeamSpeak 2024-11-13 18:18:15 +01:00
8285353536 Add scripts for installing ryot 2024-11-13 17:39:21 +01:00
c2716f1330 Add scripts for installing nextcloud 2024-11-13 17:19:10 +01:00
1869a90595 Restructure service overrides 2024-11-13 17:19:09 +01:00
21e0efa540 Add scripts for installing Minecraft 2024-11-10 13:00:23 +01:00
f299a88f53 Add settings for allowing VPN access in lxc 2024-11-10 12:56:48 +01:00
584ed2f2ea Improve look & feel of lxc config 2024-11-10 12:56:34 +01:00
37a89bc637 Add scripts for installing jellyfin 2024-11-10 12:33:36 +01:00
17a08ee782 Add a script for installing forgejo 2024-11-07 23:58:06 +01:00
85b503ea80 Add scripts for installing drone 2024-11-07 18:33:16 +01:00
5b1695c764 Allow configuring services with multiple domains 2024-11-07 11:54:50 +01:00
62ecabf471 Allow specifying domains per service 2024-11-07 03:31:48 +01:00
6292c75530 Fetch FQDN from configuration 2024-11-07 03:01:45 +01:00
ae8c65470d Generate nginx config using printf 2024-11-07 02:40:29 +01:00
0ad11b8da2 Add a function for initializing the service installation 2024-11-07 02:39:37 +01:00
84fbac93a6 Rename public API 2024-11-06 19:34:27 +01:00
e5d26993ba Add /etc/localtime file in test container 2024-11-06 03:33:01 +01:00
38f6bc2eaf Add a script for installing anki-sync 2024-11-06 03:32:45 +01:00
60381b82ac Add a script for installing nginx 2024-11-06 01:13:50 +01:00
6d25c16a9f Add a script for testing the Arch installation 2024-11-05 17:47:45 +01:00
1a180203a0 Add scripts for installing Arch 2024-11-05 17:47:39 +01:00
c1a5425a06 Add a function for declaring software dependencies 2024-11-05 17:45:13 +01:00
d0f05229f6 Ask for config profile in tmux 2024-11-05 17:39:06 +01:00
216a11285c Uninstall nixpkgs only after install 2024-11-04 01:34:43 +01:00
aaa0730f06 Initialize and dispose actions properly 2024-11-04 01:34:22 +01:00
aa2cc7122c Inherit CONFIG_NAME properly 2024-11-03 23:41:32 +01:00
805f512fbb Prevent early disposal 2024-11-03 23:41:17 +01:00
07dafd38ae Download nixpkgs only if necessary 2024-11-03 22:37:33 +01:00
17ced5abb7 Fix permissions issues 2024-11-03 22:37:22 +01:00
6f8d13f72a Rename hooks 2024-11-03 22:36:30 +01:00
b09d7cb390 Change global git config as root 2024-11-03 22:34:39 +01:00
fd1d131dd5 Create a separate config file for desktops 2024-11-03 22:33:44 +01:00
09b9d9e59e Initialize installer properly 2024-11-03 22:32:47 +01:00
3a2a0d1546 Add a script for setting up vaultwarden 2024-11-03 03:14:47 +01:00
646c340bbd Handle nix cache properly 2024-11-03 00:39:23 +01:00
b5c1fbb935 Allow fetching program config with named args 2024-11-02 22:45:22 +01:00
9817747218 Add scripts for backing up the home 2024-11-02 21:18:00 +01:00
fb99a321df Allow preparing backups 2024-11-02 20:56:54 +01:00
c3eaeabac7 Add backup capability for aliae 2024-11-02 18:26:33 +01:00
809155b9d5 Add support for backing up and restoring software 2024-11-02 18:26:21 +01:00
43c1bdf57a Improve readability of installer actions 2024-11-02 18:25:14 +01:00
e1de6b78c6 Forward installer parameters as named arguments 2024-11-02 18:14:54 +01:00
a2f27209b5 Erase installer functions automatically 2024-11-02 13:55:21 +01:00
027e0f9fd6 Streamline fish installer script 2024-11-02 13:50:51 +01:00
421cd32373 Remove unnecessary argument 2024-11-01 16:49:52 +01:00
c0c34f7a37 Add missing import 2024-11-01 16:40:39 +01:00
f5f51e6a6b Always flag git repo as safe 2024-11-01 16:39:18 +01:00
0e5370f7ca Remove safe config section after any action 2024-11-01 15:45:56 +01:00
029ad68e20 Create a script for initiating actions 2024-11-01 15:32:43 +01:00
57 changed files with 2372 additions and 97 deletions

View file

@ -1,4 +1,4 @@
{ lib, ... }:
{ config, lib, ... }:
let inherit (lib) mkOption types;
in {
imports = [
@ -28,6 +28,12 @@ in {
};
};
fqdn = mkOption {
type = types.str;
description = "The FQDN of the system.";
default = config.valhalla.hostname;
};
hostname = mkOption {
type = types.str;
description = "The hostname of the system.";

View file

@ -27,7 +27,7 @@ begin
and yayinst \
linux-headers \
pacman-contrib \
yq
go-yq
end
source "$dir/../../Common/OS/install.fish"

View file

@ -27,7 +27,7 @@ $null = New-Module {
Value = "$Value";
} `
-User $User `
".alias |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]";
".alias |= [((. // [])[] | select(.name != env(Name)))] + [{ name: env(Name), value: env(Value) }]";
}
<#
@ -53,7 +53,7 @@ $null = New-Module {
Value = "$Value";
} `
-User $User `
".env |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]";
".env |= [((. // [])[] | select(.name != env(Name)))] + [{ name: env(Name), value: env(Value) }]";
}
<#
@ -92,7 +92,7 @@ $null = New-Module {
}
sudo @using:flags pwsh -CommandWithArgs 'Get-Content -Raw $args[0]' $using:path | Set-Content $file;
yq -yi $using:Script $file;
yq -i $using:Script $file;
sudo @using:flags pwsh -CommandWithArgs 'Set-Content $args[0] -Value $args[1]' $using:path (Get-Content -Raw $file);
Remove-Item $file;
} | Receive-Job -Wait;

View file

@ -1,12 +0,0 @@
server {
listen 80;
server_name anki.nuth.ch;
location / {
proxy_pass http://127.0.0.1:1337;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View file

@ -2,8 +2,5 @@ services:
anki:
image: yangchuansheng/anki-sync-server
restart: unless-stopped
extends:
file: docker-compose.secrets.yml
service: anki
volumes:
- ./data:/ankisyncdir

View file

@ -1,5 +1,6 @@
#!/bin/env fish
begin
set -l name anki
set -l dir (status dirname)
set -l source "$dir/docker-compose.secrets.yml"
source "$dir/../service.fish"
@ -7,11 +8,12 @@ begin
function installSW -V dir -V source
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l userKey ".services.anki.environment.SYNC_USER1"
set -l user (yq --raw-output "$userKey" "$source" | sed "s/:.*\$/:$pw/")
sudo cp "$dir/docker-compose.yml" (getServiceRoot $argv)
set -l user (yq "$userKey" "$source" | sed "s/:.*\$/:$pw/")
initializeServiceInstallation $argv
sudo cp "$dir/docker-compose.base.yml" (getServiceRoot $argv)
USER=$user yq "$userKey = env.USER" "$source" | \
sudo tee (__getServiceSecretsConfig $argv) >/dev/null
USER=$user yq "$userKey = env(USER)" "$source" | \
sudo tee (getServiceSecretsConfig $argv) >/dev/null
installDockerService $argv
end
@ -20,12 +22,12 @@ begin
configureDockerService $argv
end
function getServiceNginxConfigSource -V dir
echo "$dir/anki.conf"
function getServiceServers -V name
printf "$name" ""
end
function getServiceConfigs
printf "%s\0" "anki" "/"
function getServiceLocations -V name
printf "%s\0" "$name" /
end
runInstaller --force $argv

View file

@ -0,0 +1,4 @@
include:
- path:
- docker-compose.base.yml
- docker-compose.secrets.yml

View file

@ -0,0 +1 @@
data/

View file

@ -0,0 +1,7 @@
FROM tetafro/golang-gcc AS builder
RUN apk add -U --no-cache git
RUN git clone -b "v2.20.0" --depth=1 https://github.com/drone/drone.git
RUN cd drone && go build -trimpath -ldflags='-w -s' -tags nolimit -o /usr/local/bin/drone-server ./cmd/drone-server
FROM drone/drone
COPY --from=builder /usr/local/bin/drone-server /bin/

View file

@ -0,0 +1,26 @@
services:
ci-template:
build:
context: .
dockerfile: ci.Dockerfile
restart: unless-stopped
env_file:
- server.common.env
docker-template:
image: drone/drone-runner-docker
restart: unless-stopped
depends_on: []
env_file:
- runner.common.env
environment:
DRONE_RUNNER_NAME: docker-runner
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ssh-template:
image: drone/drone-runner-ssh
restart: unless-stopped
depends_on: []
env_file:
- runner.common.env
environment:
DRONE_RUNNER_NAME: ssh-runner

View file

@ -0,0 +1,120 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l source "$dir/docker-compose.templates.yml"
source "$dir/../service.fish"
set -l environments \
forgejo mydrone "" \
github drone ""
function installSW -V dir -V environments -V source
set -l root (getServiceRoot $argv)
set -l config "$root/docker-compose.base.yml"
set -l secrets (getServiceSecretsConfig $argv)
set -l ciTemplate (yq (getServiceKey ci-template) "$source")
set -l dockerTemplate (yq (getServiceKey docker-template) "$source")
set -l sshTemplate (yq (getServiceKey ssh-template) "$source")
initializeServiceInstallation $argv
echo "{}" | sudo tee "$config" >/dev/null
echo "{}" | sudo tee "$secrets" >/dev/null
cp "$dir"/{ci.Dockerfile,.dockerignore} "$root"
echo "DRONE_JSONNET_ENABLED=true" | sudo tee "$root/server.common.env" >/dev/null
echo "DRONE_RUNNER_CAPACITY=2" | sudo tee "$root/runner.common.env" >/dev/null
for i in (seq 1 3 (count $environments))
set -l name $environments[$i]
set -l domain $environments[(math $i + 2)]
set -l subdomain $environments[(math $i + 1)]
set -l user $environments[(math $i + 3)]
set -l secret (openssl rand -hex 16)
set -l runners ssh docker
set -l services ci $runners
set -l tmpConfig (mktemp)
set -l tmpSecrets (mktemp)
set -l ciName "$name-ci"
set -l sshName "$name-ssh-runner"
set -l dockerName "$name-docker-runner"
set -l ciEnv
set -l sshEnv
set -l dockerEnv
cp "$config" "$tmpConfig"
cp "$secrets" "$tmpSecrets"
for serviceName in $services
set -l file (mktemp)
set -l nameVar "$serviceName""Name"
set -l serviceKey ".services.[\"$$nameVar\"]"
set "$serviceName""Key" "$serviceKey"
set "$serviceName""Env" "$serviceKey.environment"
end
CI_NAME=$ciName \
SECRET_ENV="$name.secret.env" \
RUNNER_ENV="$name.runner.env" begin
begin
printf "%s\n" \
DRONE_RPC_PROTO=http \
"DRONE_RPC_HOST=$name-ci"
end | sudo tee "$root/$RUNNER_ENV" >/dev/null
echo "DRONE_RPC_SECRET=$secret" | sudo tee "$root/$SECRET_ENV" >/dev/null
yq "$ciKey = $ciTemplate" "$tmpConfig" | \
ENTRY="./data/$name:/data" yq "$ciKey.volumes = [ env(ENTRY) ]" | \
yq "$ciKey.env_file |= . + [ env(SECRET_ENV) ]" | \
PROTO=https yq "$ciEnv.DRONE_SERVER_PROTO = env(PROTO)" | \
HOST=(getServiceDomain "$subdomain" "$domain") yq "$ciEnv.DRONE_SERVER_HOST = env(HOST)" | \
yq "$dockerKey = $dockerTemplate" | \
yq "$sshKey = $sshTemplate" | \
yq "$dockerKey.depends_on = [ env(CI_NAME) ]" | \
sudo tee "$config" >/dev/null
for key in $dockerKey $sshKey
set -l file (mktemp)
yq "$key.depends_on = [ env(CI_NAME) ]" "$config" | \
yq "$key.env_file |= . + [ env(RUNNER_ENV), env(SECRET_ENV) ]" | \
tee "$file" >/dev/null
sudo cp "$file" "$config"
rm "$file"
end
PORT="127.0.0.1:1337:80" yq "$ciKey.ports = [ env(PORT) ]" "$tmpSecrets" | \
sudo tee "$secrets" >/dev/null
end
end
installDockerService $argv
end
function configureSW -V dir
configureDockerService $argv
end
function getServiceServers -V environments
argparse -i "name=" -- $argv
set -l name "$_flag_name"
for i in (seq 1 3 (count $environments))
set -l domain $environments[(math $i + 2)]
set -l subdomain $environments[(math $i + 1)]
printf "%s\0" "$subdomain" "$domain"
end
end
function getServiceLocations -a index -V environments
set -l i (math (math (math $index - 1) / 2 "*" 3) + 1)
set -l name $environments[$i]
printf "%s\0" "$name-ci" /
end
function getBackupArgs
printf "%s\n" --hidden --no-ignore "data|\.secrets?\." (getServiceRoot $argv)
end
runInstaller --force $argv
end

View file

@ -0,0 +1,54 @@
services:
forgejo:
image: codeberg.org/forgejo/forgejo:7
restart: unless-stopped
depends_on:
- db
environment:
USER_UID: 1337
USER_GID: 1337
FORGEJO__database__DB_TYPE: mysql
FORGEJO__database__HOST: db
FORGEJO__database__LOG_SQL: "false"
FORGEJO__repository__DEFAULT_BRANCH: main
FORGEJO__server__SSH_DOMAIN: "%(DOMAIN)s"
FORGEJO__server__ROOT_URL: https://%(DOMAIN)s/
FORGEJO__server__DISABLE_SSH: "false"
FORGEJO__server__LFS_START_SERVER: "true"
FORGEJO__service__REGISTER_MANUEL_CONFIRM: "true"
FORGEJO__actions__ENABLED: "true"
FORGEJO__openid__ENABLE_OPENID_SIGNUP: "false"
FORGEJO__cron.git_gc_repos__ENABLED: "true"
FORGEJO__cron.git_lfs: "true"
volumes:
- ./data/forgejo:/data
- config:/data/gitea/conf
- /etc/timezone:/etc/timezone:ro
- /home/forgejo/.ssh:/data/git/.ssh
db:
image: mariadb
restart: unless-stopped
environment:
MARIADB_RANDOM_ROOT_PASSWORD: "yes"
MARIADB_AUTO_UPGRADE: "yes"
volumes:
- ./database:/var/lib/mysql
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
bridge:
image: shenxn/protonmail-bridge
restart: unless-stopped
volumes:
- ./bridge:/root
runner:
image: gitea/act_runner
restart: unless-stopped
depends_on:
- forgejo
volumes:
- ./data/act:/data
- /var/run/docker.sock:/var/run/docker.sock
volumes:
config: {}

View file

@ -0,0 +1,7 @@
services:
forgejo:
environment: {}
ports:
- 127.0.0.1:1337:3000
- 127.0.0.1:1338:22
db: {}

View file

@ -0,0 +1,98 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l user "forgejo"
set -l domain "git"
set -l server "$domain" ""
set -l service $user
source "$dir/../service.fish"
function getSSHPortKey -V service
echo "$(getServiceKey "$service").ports[1]"
end
function installSW -V dir -V domain -V server -V service
set -l root (getServiceRoot $argv)
set -l secrets (getServiceSecretsConfig $argv)
set -l source "$dir/$(basename "$secrets")"
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l port (getRandomPort)
initializeServiceInstallation $argv
sudo cp "$dir/docker-compose.base.yml" "$root"
installDockerService $argv
set port (yq (getSSHPortKey) "$source" | mutatePort "$port")
DOMAIN=(getServiceDomain $server) PW=$pw DB=Git USER=forgejo PW=$pw begin
set -l gitEnv "$(getServiceKey "$service").environment"
set -l dbEnv "$(getServiceKey "db").environment"
PORT=$port yq "$(getSSHPortKey) = env(PORT)" "$source" | \
yq "$gitEnv.FORGEJO__database__NAME = env(DB)" | \
yq "$gitEnv.FORGEJO__database__USER = env(USER)" | \
yq "$gitEnv.FORGEJO__database__PASSWD = env(PW)" | \
yq "$dbEnv.MARIADB_DATABASE = env(DB)" | \
yq "$dbEnv.MARIADB_USER = env(USER)" | \
yq "$dbEnv.MARIADB_PASSWORD = env(PW)" | \
sudo tee "$secrets" >/dev/null
end
end
function configureSW -V dir -V user -V service
set -l uid
set -l gid
set -l port
set -l file (mktemp)
set -l root (getServiceRoot $argv)
set -l dir "$root/data"
set -l bin "/usr/local/bin/forgejo"
set -l config "$root/docker-compose.base.yml"
set -l secrets (getServiceSecretsConfig $argv)
set -l envKey "$(getServiceKey "$service").environment"
configureDockerService $argv
cp "$config" "$file"
and sudo useradd \
--system \
--shell /bin/bash \
--comment 'Git Version Control' \
--create-home \
$user
set uid (id -u $user)
set gid (id -g $user)
and yq "$envKey.USER_UID = $uid" "$file" | \
yq "$envKey.USER_GID = $gid" | \
sudo tee "$config" >/dev/null
mkdir -p "$dir"
and chown -R $uid:$gid "$dir"
rm "$file"
set port (yq (getSSHPortKey) "$secrets" | extractPort)
begin
printf "%s\n" \
"#!/bin/sh" \
"ssh -p $port -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\""
end | sudo tee "$bin" >/dev/null
chmod +x "$bin"
end
function getServiceServers -V server
printf "%s\0" $server
end
function getServiceLocations
argparse -i "name=" -- $argv
printf "%s\0" "$_flag_name" /
end
function getBackupArgs -V root
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" --exclude "docker-compose.base.yml" "$root"
end
runInstaller --force $argv
end

View file

@ -0,0 +1,6 @@
config/
downloads/
media/
docker-compose.yml
*.env
*.Dockerfile

View file

@ -0,0 +1,109 @@
services:
jellyfin:
image: jellyfin/jellyfin
restart: unless-stopped
user: 1337:1337
hostname: Jellyfin
environment: {}
volumes:
- ./config/jellyfin:/config
- cache:/cache
- ./media:/media
radarr:
image: linuxserver/radarr
restart: unless-stopped
environment:
PUID: 1337
PGID: 1337
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config/radarr:/config
- ./media/movies:/movies
- ./downloads:/downloads
sonarr:
image: linuxserver/sonarr
restart: unless-stopped
environment:
PUID: 1337
PGID: 1337
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config/sonarr:/config
- ./media/series:/tv
- ./downloads:/downloads
lidarr:
image: linuxserver/lidarr
restart: unless-stopped
environment:
PUID: 1337
PGID: 1337
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config/lidarr:/config
- ./media/music:/music
- ./downloads:/downloads
prowlarr:
image: linuxserver/prowlarr
restart: unless-stopped
environment:
PUID: 1337
PGID: 1337
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config/prowlarr:/config
flaresolverr:
image: flaresolverr/flaresolverr
restart: unless-stopped
environment:
LOG_LEVEL: info
LOG_HTML: "false"
CAPTCHA_SOLVER: none
privoxy:
image: walt3rl/proton-privoxy
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
devices:
- /dev/net/tun
cap_add:
- NET_ADMIN
flood:
image: jesec/flood
restart: unless-stopped
user: 1337:1337
command: --baseuri /flood
--rundir /flood
--allowedpath /downloads
--rtsocket /rtorrent/.local/share/rtorrent/rtorrent.sock
volumes:
- ./config/flood:/flood
- ./downloads:/downloads
- ./config/rtorrent:/rtorrent
rtorrent:
build:
dockerfile: ./rtorrent.Dockerfile
context: .
restart: unless-stopped
hostname: rtorrent
environment:
PUID: 1337
PGID: 1337
PHOME: /config
MAX_UPTIME: 43200
command: -o ratio.enable=
-o ratio.min.set=200
-o ratio.max.set=10000
-o directory.default.set=/downloads
-o 'method.set=group.seeding.ratio.command, "d.cloase = ; d.erase = "'
volumes:
- ./config/rtorrent:/config
- ./downloads:/downloads
- /etc/localtime:/etc/localtime:ro
- ./proton:/proton
devices:
- /dev/net/tun
cap_add:
- NET_ADMIN
volumes:
cache: {}

View file

@ -0,0 +1,19 @@
services:
jellyfin:
ports:
- 127.0.0.1:1337:8096
radarr:
ports:
- 127.0.0.1:1337:7878
sonarr:
ports:
- 127.0.0.1:1337:8989
lidarr:
ports:
- 127.0.0.1:1337:8686
prowlarr:
ports:
- 127.0.0.1:1337:9696
flood:
ports:
- 127.0.0.1:1337:3000

View file

@ -0,0 +1,145 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l user "jellyfin"
set -l domain "media"
set -l server "$domain" ""
set -l servarr radarr sonarr lidarr prowlarr
set -l flood flood
set -l service $user
source "$dir/../service.fish"
function installSW -V dir -V domain -V server -V service
set -l root (getServiceRoot $argv)
set -l secrets (getServiceSecretsConfig $argv)
set -l source "$dir/$(basename "$secrets")"
set -l port (getRandomPort)
set -l servarrKeys
initializeServiceInstallation $argv
sudo cp "$dir/docker-compose.base.yml" "$root"
sudo cp "$dir/.dockerignore" "$root"
sudo cp "$dir/pvpn-cli.py" "$root"
sudo cp "$dir/rtorrent.Dockerfile" "$root"
sudo cp "$source" "$secrets"
installDockerService $argv
end
function configureSW -V dir -V user -V domain -V service -V servarr -V flood
set -l uid
set -l gid
set -l port
set -l file (mktemp)
set -l root (getServiceRoot $argv)
set -l bin "/usr/local/bin/forgejo"
set -l config "$root/docker-compose.base.yml"
set -l secrets (getServiceSecretsConfig $argv)
set -l envKey "$(getServiceKey "$service").environment"
configureDockerService $argv
and sudo useradd \
--system \
--shell /bin/false \
--comment 'Jellyfin server' \
--create-home \
$user
set uid (id -u $user)
set gid (id -g $user)
for name in $service $flood
set -l userKey "$(getServiceKey "$name").user"
cp "$config" "$file"
USER=$uid:$gid yq "$userKey = env(USER)" "$file" | sudo tee "$config" >/dev/null
end
for name in $servarr rtorrent
set -l envKey "$(getServiceKey "$name").environment"
sudo cp "$config" "$file"
and yq "$envKey.PUID = $uid" "$file" | \
yq "$envKey.PGID = $gid" | \
yq -y . | \
sudo tee "$config" >/dev/null
end
cp "$config" "$file"
URL="https://$(getServiceDomain "$domain" "")/" yq "$(getServiceKey "$service").environment.JELLYFIN_PublishedServerUrl = env(URL)" "$file" | \
sudo tee "$config" >/dev/null
for dir in "$root"/{downloads,config/{,jellyfin,flood,rtorrent,radarr,sonarr,lidarr,prowlarr},media/{,movies,series,music}}
sudo mkdir -p "$dir"
and chown -R $uid:$gid "$dir"
end
rm "$file"
begin
printf "%s\n" \
"#!/bin/sh" \
"ssh -p $port -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\""
end | sudo tee "$bin" >/dev/null
chmod +x "$bin"
end
function getServiceServers -V server
printf "%s\0" $server
end
function getServiceLocations -V servarr -V flood
argparse -i "name=" -- $argv
printf "%s\0" \
"$_flag_name" / (
for app in $servarr
printf "%s\n" "$app" "/$app"
end) \
flood "~ ^/flood.*"
end
function getServiceLocationConfig -a domain s location -V service -V flood
if [ "$s" = "$service" ]
set -l argv $argv[4..]
printf "%s\n" \
"location = / {" \
'return 302 $scheme://$host/web/;' \
"}"
getServiceDefaultProxy $domain $s "$location" --comment "Proxy main Jellyfin traffic" $argv
getServiceDefaultProxy $domain $s "= /web/" --path "/web/index.html" --comment "Proxy main Jellyfin traffic" $argv
getServiceDefaultProxy $domain $s "/socket" --comment "Proxy Jellyfin Websockets traffic" $argv
else if [ "$s" = "$flood" ]
getServiceDefaultProxy $argv
printf "%s\n" \
"location = /flood {" \
'return 302 $scheme://$host$uri/$is_args$args;' \
"}"
else
getServiceDefaultProxy $argv --path "$location"
end
end
function getExtraLocationSettings -a domain s location -V service
if [ "$s" = "$service" ]
if [ "$location" = / ]
printf "%s\n" \
"# Disable buffering when the nginx proxy gets very resource heavy upon streaming" \
"proxy_buffering off;"
else if [ "$location" = "/socket" ]
printf "%s\n" \
'# Websocket' \
"proxy_http_version 1.1;" \
'proxy_set_header Upgrade $http_upgrade;' \
'proxy_set_header Connection "upgrade";'
end
end
end
function getBackupArgs -V root
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" --exclude "docker-compose.base.yml" "$root"
end
runInstaller --force $argv
end

View file

@ -0,0 +1,100 @@
from argparse import ArgumentParser
from os import environ
from os.path import dirname
from re import M
import shlex
import subprocess
import sys
from protonvpn_cli.cli import FeatureEnum, protonvpn
def run_proton(args):
exit(
subprocess.run(
["pipenv", "run", "proton"],
cwd="/app",
env=dict(
environ,
PIPENV_VENV_IN_PROJECT=f"{1}",
PVPN_CMD_ARGS=" ".join(args))).returncode)
protonvpn.ensure_connectivity()
args = sys.argv[1:]
if not args:
args = shlex.split(environ.get("PVPN_CMD_ARGS") or "")
environ["PVPN_CMD_ARGS"] = ""
parser = ArgumentParser(exit_on_error=False)
subParsers = parser.add_subparsers(dest="command")
initParser = subParsers.add_parser("init", alias=["i"])
connectParser = subParsers.add_parser("connect", aliases=["c"])
for aliases in [
["-f", "--fastest"],
["-r", "--random"],
["-s", "--streaming"],
["--sc"],
["--p2p"],
["--tor"]
]:
connectParser.add_argument(*aliases, action="store_true")
connectParser.add_argument("--cc")
parsedArgs = None
try:
parsedArgs = parser.parse_args(args)
except:
pass
if parsedArgs is not None and parsedArgs.command == "init":
userName = input("Enter your Proton VPN username or email: ")
subprocess.run(["protonvpn-cli", "login", userName])
else:
session = protonvpn.get_session()
try:
session.ensure_valid()
except:
raise Exception("Your current session is invalid. Please initialize the session using the `init` subcommand.")
environ["PVPN_USERNAME"] = session.vpn_username + (environ.get("PVPN_TAGS") or "")
environ["PVPN_PASSWORD"] = session.vpn_password
environ["PVPN_TIER"] = f"{session.vpn_tier}"
if parsedArgs is not None and (
len(
list(
filter(
lambda item: item[1] not in [False, None],
vars(parsedArgs).items()))) > 1):
country = protonvpn.get_country()
def match(server):
features = list()
if parsedArgs.streaming:
features.append(FeatureEnum.STREAMING)
if parsedArgs.sc:
features.append(FeatureEnum.SECURE_CORE)
if parsedArgs.p2p:
features.append(FeatureEnum.P2P)
if parsedArgs.tor:
features.append(FeatureEnum.TOR)
return (parsedArgs.cc is None or server.exit_country.lower() == parsedArgs.cc.lower()) and (
all(feature in server.features for feature in features))
servers = session.servers.filter(match)
if len(servers) > 0:
if parsedArgs.fastest or not parsedArgs.random:
server = servers.get_fastest_server()
else:
server = servers.get_random_server()
run_proton(["connect", server.name])
else:
raise Exception(f"Unable to find a server matching the specified criteria {args[1:]}!")
else:
run_proton(args)

View file

@ -0,0 +1,121 @@
FROM walt3rl/proton-privoxy AS proton
FROM jesec/rtorrent AS rtorrent
FROM debian
ARG PVPN_CLI_VER=2.2.12
ARG USERNAME=proton
ENV PVPN_TAGS="+pmp" \
PVPN_PROTOCOL=udp \
PVPN_CMD_ARGS="connect --p2p --random" \
PVPN_DEBUG= \
HOST_NETWORK= \
DNS_SERVERS_OVERRIDE= \
PUID=1000 \
PGID=1000 \
PHOME=/home/${USERNAME} \
NATPMP_TIMEOUT=60 \
NATPMP_INTERVAL= \
MAX_UPTIME=
WORKDIR /root
COPY --from=rtorrent / /
RUN mkdir /app
COPY --from=proton /root/.pvpn-cli /root/.pvpn-cli
COPY --from=proton /app/proton-privoxy/run /app/proton
RUN \
sed -i \
-e "/^exec privoxy/d" \
-e "/^ln -s/d" \
/app/proton \
&& install -t /usr/local/bin /app/proton \
&& rm /app/proton
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y \
curl \
gnupg \
&& curl https://repo.protonvpn.com/debian/dists/stable/main/binary-all/protonvpn-stable-release_1.0.3-3_all.deb -o proton.deb \
&& dpkg --install proton.deb \
&& apt-get remove -y \
curl \
&& apt-get update -y \
&& apt-get install -y protonvpn-cli \
&& rm -rf /var/lib/apt/lists
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y \
git \
iproute2 \
iptables \
natpmpc \
pipenv \
python3-setuptools \
sudo \
&& rm -rf /var/lib/apt/lists
RUN \
cd /app \
&& PIPENV_VENV_IN_PROJECT=1 pipenv install git+https://github.com/Rafficer/linux-cli-community.git@v$PVPN_CLI_VER#egg=protonvpn-cli
RUN printf "%s\n" \
"#!/usr/bin/env -S dbus-run-session -- bash" \
"mkdir -p /proton/{keyrings,protonvpn}" \
"mkdir -p ~/.local/share" \
"mkdir -p ~/.config" \
"ln -Ts /proton/keyrings ~/.local/share/keyrings >/dev/null 2>&1" \
"ln -Ts /proton/protonvpn ~/.config/protonvpn >/dev/null 2>&1" \
"eval \"\$(echo -n 'root' | gnome-keyring-daemon --unlock)\"" \
"python3 /app/pvpn-cli.py \"\$@\"" > ./pvpn-cli \
&& install -Dm 755 ./pvpn-cli /usr/local/bin \
&& rm ./pvpn-cli
RUN printf "%s\n" \
"#!/bin/bash" \
"groupadd --gid \$PGID ${USERNAME} > /dev/null" \
"useradd --create-home --home-dir \$PHOME ${USERNAME} --uid \$PUID -g ${USERNAME} 2>/dev/null" \
'[ ! -z "$1" ] && [ "$1" = "init" ] && export PVPN_CMD_ARGS="$@"' \
"pvpn-cli || exit" \
'ip link show proton0 > /dev/null 2>&1 || exit' \
'fallback="$(expr ${NATPMP_TIMEOUT} \* 3 / 4)"' \
'export NATPMP_INTERVAL="${NATPMP_INTERVAL:-$fallback}"' \
'echo "Opening a port using NAT-PMP for $NATPMP_TIMEOUT seconds…"' \
'output="$(natpmpc -a 0 0 tcp "$NATPMP_TIMEOUT")"' \
'natpmpc -a 0 0 udp "$NATPMP_TIMEOUT"' \
'port="$(echo "$output" | grep -m 1 " public port [[:digit:]]\+ " | sed "s/.* public port \([[:digit:]]\+\).*/\\1/")"' \
'echo "Port $port has been opened for P2P data transfer!"' \
'echo "The NAT-PMP port forwarding will be updated every $NATPMP_INTERVAL seconds"' \
'export PEERPORT="$port"' \
"{" \
" while true" \
" do" \
' echo "Refreshing NAT-PMP port forwarding…"' \
' natpmp -a 0 0 udp "$NATPMP_TIMEOUT"' \
' natpmpc -a 0 0 tcp "$NATPMP_TIMEOUT"' \
' echo "NAT-PMP port forwarding has been refreshed!"' \
' sleep "$NATPMP_INTERVAL"' \
" done" \
"} &" \
"set -m" \
'[ ${MAX_UPTIME:-0} -gt 0 ] && {' \
' soudo -iu '"${USERNAME}"' rtorrent -o network.port_range.set=$port-$port,system.daemon.set=true $@ &' \
' pid=$!' \
' sleep "$MAX_UPTIME"' \
' pkill -9 $pid' \
'} || {' \
' sudo -u '"${USERNAME}"' rtorrent -o network.port_range.set=$port-$port,system.daemon.set=true $@' \
'}' > ./rtorrent-entrypoint \
&& install -Dm 755 ./rtorrent-entrypoint /usr/local/bin \
&& rm ./rtorrent-entrypoint
COPY pvpn-cli.py /app/pvpn-cli.py
#RUN apt-get update -y \
# && apt-get install -y sudo
# RUN echo "${USERNAME} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
VOLUME [ "/proton" ]
ENTRYPOINT [ "rtorrent-entrypoint" ]

View file

@ -0,0 +1,32 @@
services:
legacy:
image: itzg/minecraft-server
restart: unless-stopped
environment:
UID: 1337
GID: 1337
EULA: "TRUE"
ports:
- 25565:25565
volumes:
- /etc/localtime:/etc/localtime:ro
- ./mods:/mods
- ./config/legacy:/config
- ./data/legacy:/data
- ./worlds/legacy:/data/worlds
- ./legacy.properties:/data/server.properties
bedrock:
image: itzg/minecraft-bedrock-server
restart: unless-stopped
environment:
UID: 1337
GID: 1337
EULA: "TRUE"
ports:
- 19132:19132/udp
- 19133:19133/udp
volumes:
- /etc/localtime:/etc/localtime:ro
- ./data/bedrock:/data
- ./worlds/bedrock:/data/worlds
- ./bedrock.properties:/data/server.properties

View file

@ -0,0 +1,73 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l user "minecraft"
source "$dir/../service.fish"
function installSW -V dir -V domain -V server -V service
initializeServiceInstallation $argv
sudo cp "$dir/docker-compose.yml" (getServiceRoot $argv)
installDockerService $argv
end
function configureSW -V dir -V user -V service
set -l uid
set -l gid
set -l file (mktemp)
set -l root (getServiceRoot $argv)
set -l dirs "$root"/{mods,{data,config,worlds}/{legacy,bedrock}}
set -l files "$root"/{legacy,bedrock}.properties
set -l config "$root/docker-compose.yml"
configureDockerService $argv
and sudo useradd \
--system \
--shell /bin/false \
--comment 'Minecraft server' \
--groups docker \
$user
set uid (id -u $user)
set gid (id -g $user)
for service in (yq -0 ".services | keys[]" "$config" | string split0)
set -l envKey "$(getServiceKey "$service").environment"
cp "$config" "$file"
and yq "$envKey.UID = $uid" "$file" | \
yq "$envKey.GID = $gid" | \
sudo tee "$config" >/dev/null
end
and for dir in $dirs
sudo mkdir -p "$dir"
end
and begin
set -l file
for file in $files
sudo mkdir -p (dirname "$file")
sudo touch "$file"
end
end
and for item in $dirs $files
sudo chown -R $uid:$gid "$item"
end
rm "$file"
end
function getServiceServers -V server
end
function getServiceLocations
end
function getBackupArgs -V root
printf "%s\n" --hidden --no-ignore "config|data|mods|worlds|\.properties\$" --exclude "docker-compose.yml" "$root"
end
runInstaller --force $argv
end

View file

@ -0,0 +1 @@
*

View file

@ -0,0 +1,3 @@
FROM redis
ENV REDIS_HOST_PASSWORD default-password
CMD ["sh", "-c", "exec redis-server --requirepass \"${REDIS_HOST_PASSWORD}\""]

View file

@ -0,0 +1,33 @@
FROM nextcloud:fpm
# Workaround for Nextcloud image not including `bz2`
RUN apt-get update && \
apt-get install -y \
libbz2-dev \
libfcgi-bin && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-install bz2
RUN apt-get update && \
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libmagickcore-6.q16-6-extra \
libxss1 \
libx11-xcb1 \
wget && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install -y google-chrome-stable --no-install-recommends && \
apt-get remove -y wget gnupg && \
rm -rf /var/lib/apt/lists/* && \
rm /etc/apt/sources.list.d/google.list
RUN curl -Lo /usr/local/bin/php-fpm-healthcheck https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/v0.5.0/php-fpm-healthcheck && \
chmod +x /usr/local/bin/php-fpm-healthcheck
RUN npm install --global pageres-cli --unsafe-perm

View file

@ -0,0 +1,107 @@
services:
web:
image: nginx
extends:
file: docker-compose.core.yml
service: web
volumes:
- ./nginx/web.conf:/etc/nginx/nginx.conf
- ./cloud/logs/nginx:/var/log/nginx
depends_on:
core:
condition: service_healthy
installer:
extends:
file: docker-compose.core.yml
service: setup
image: nextcloud:fpm
restart: on-failure
entrypoint:
- bash
- -c
- /entrypoint.sh php-fpm & while ! echo '' 2> /dev/null > /dev/tcp/127.0.0.1/9000; do sleep 1; done; kill -9 $!; true;
db:
image: mariadb:lts
restart: unless-stopped
env_file: db.env
environment:
MARIADB_RANDOM_ROOT_PASSWORD: "yes"
MARIADB_MYSQL_LOCALHOST_USER: 1
volumes:
- ./cloud/database:/var/lib/mysql
command:
- --innodb_read_only_compressed=OFF
healthcheck:
test: [CMD, healthcheck.sh, --su-mysql, --connect, --innodb_initialized]
start_period: 1m
start_interval: 10s
interval: 1m
timeout: 5s
retries: 3
cache:
build:
context: .
dockerfile: cache.Dockerfile
restart: unless-stopped
env_file:
- cache.env
volumes:
- ./cloud/cache:/data
healthcheck:
test: [CMD, bash, -c, echo '' > /dev/tcp/127.0.0.1/6379]
interval: 5s
timeout: 3s
retries: 5
core:
extends:
file: docker-compose.core.yml
service: nextcloud
build:
context: .
dockerfile: cloud.Dockerfile
cap_add:
- SYS_ADMIN
depends_on: &nextcloud-conditions
db:
condition: service_healthy
cache:
condition: service_healthy
installer:
condition: service_completed_successfully
restart: true
healthcheck:
test: [CMD, bash, -c , php-fpm-healthcheck]
start_period: 1m
start_interval: 10s
interval: 1m
timeout: 5s
retries: 5
cron:
extends:
file: docker-compose.core.yml
service: nextcloud
image: nextcloud:fpm
depends_on:
<<: *nextcloud-conditions
entrypoint: /cron.sh
bridge:
image: shenxn/protonmail-bridge
restart: unless-stopped
volumes:
- ./bridge:/root
turn:
image: instrumentisto/coturn
restart: unless-stopped
collabora:
image: collabora/code
restart: unless-stopped
environment:
dictionaries: de_CH de en
extra_params: '--o:logging.level_startup=warning --o:ssl.enable=true --o:ssl.termination=true --o:user_interface.mode=notebookbar'
volumes:
- /etc/localtime:/etc/localtime:ro
cap_add:
- MKNOD
volumes:
webroot: {}

View file

@ -0,0 +1,32 @@
services:
web:
restart: unless-stopped
volumes:
- webroot:/var/www/html:z
- ./php.ini:/usr/local/etc/php/conf.d/nextcloud.ini
- ./cloud/apps:/var/www/html/custom_apps
- ./cloud/config:/var/www/html/config
- ./cloud/data:/var/www/html/data
- ./cloud/themes:/var/www/html/themes
- ./cloud/public:/public
- ../jellyfin/downloads:/downloads
setup:
extends:
service: web
environment:
FCGI_STATUS_PATH: "/fpm-status"
env_file:
- db.env
- cache.env
volumes:
- ./fpm/nextcloud.conf:/usr/local/etc/php-fpm.d/zz-nextcloud.conf
- ./fpm/status.conf:/usr/local/etc/php-fpm.d/zz-status.conf
nextcloud:
extends:
service: setup
env_file:
- nextcloud.env
environment:
MYSQL_HOST: db
REDIS_HOST: cache
TRUSTED_PROXIED: 172.16.0.0/12

View file

@ -0,0 +1,12 @@
services:
web:
ports:
- 127.0.0.1:1337:80
turn:
ports:
- 127.0.0.1:1337:3478/tcp
- 127.0.0.1:1337:3478/udp
command: [-n, --log-file=stdout, --min-port=49160, --max-port=49200, --use-auth-secret]
collabora:
ports:
- 127.0.0.1:1337:9980

View file

@ -0,0 +1,5 @@
[www]
; pm.max_children = 200
; pm.start_servers = 50
; pm.min_spare_servers = 50
; pm.max_spare_servers = 150

View file

@ -0,0 +1 @@
pm.status_path = /fpm-status

View file

@ -0,0 +1,114 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l turn turn
set -l domain cloud ""
set -l service web
set -l office collabora
set -l officeDomain "office" ""
set -l server $service $domain
set -l services \
$server \
$turn turn "" \
$office $officeDomain
source "$dir/../service.fish"
function installSW -V dir -V domain -V service -V turn -V office -V officeDomain
set -l genPW __generatePW
function $genPW -a length
if [ -z "$length" ]
set length 32
end
nix-shell -p keepassxc --run "keepassxc-cli generate --length $length"
end
set -l file (mktemp)
set -l root (getServiceRoot $argv)
set -l source "$dir/docker-compose.core.yml"
set -l core "$root/$(basename "$source")"
set -l domain (getServiceDomain $domain)
set -l base "$root/docker-compose.base.yml"
set -l baseSource "$dir/$(basename "$base")"
set -l secrets (getServiceSecretsConfig $argv)
set -l secretsSource "$dir/$(basename "$secrets")"
set -l turnKey "$(getServiceKey "$turn")"
set -l portKey "$turnKey.ports[1]"
set -l officeEnv "$(getServiceKey "$office").environment"
set -l dbPW ($genPW)
set -l turnPW ($genPW)
set -l turnPort
set -l redisPW ($genPW)
set -l nextcloudPW ($genPW 64)
initializeServiceInstallation $argv
sudo cp -r "$dir"/{cache.Dockerfile,cloud.Dockerfile,.dockerignore,fpm,nginx,php.ini} "$root"
begin
printf "%s\n" \
"MYSQL_DATABASE=Nextcloud" \
"MYSQL_USER=nextcloud" \
"MYSQL_PASSWORD=$dbPW"
end | sudo tee "$root/db.env" >/dev/null
echo "REDIS_HOST_PASSWORD=$redisPW" | sudo tee "$root/cache.env" >/dev/null
begin
printf "%s\n" \
"NEXTCLOUD_ADMIN_USER=admin" \
"NEXTCLOUD_ADMIN_PASSWORD=$nextcloudPW"
end | sudo tee "$root/nextcloud.env" >/dev/null
PROTO="https" DOMAIN="$domain" begin
set -l envKey "$(getServiceKey "$service").environment"
yq "$envKey.NEXTCLOUD_TRUSTED_DOMAINS = env(DOMAIN)" "$source" | \
yq "$envKey.OVERWRITEPROTOCOL = env(PROTO)" | \
yq "$envKey.OVERWRITEHOST = env(DOMAIN)" | \
URL="$PROTO://$DOMAIN" yq "$envKey.OVERWRITECLIURL = env(URL)" | \
sudo tee "$core" >/dev/null
DOMAIN=(getServiceDomain $officeDomain) yq "$officeEnv.server_name = env(DOMAIN)" "$baseSource" | \
URL="https://$(string escape --style regex "$DOMAIN"):443" yq "$officeEnv.aliasgroup1 = env(URL)" | \
sudo tee "$base" >/dev/null
end
begin
set -l key "$turnKey.command"
PW="--static-auth-secret=$turnPW" \
DOMAIN="--realm=$domain" \
yq "$key |= . + [env(PW), env(DOMAIN)]" "$secretsSource" | \
sudo tee "$secrets" >/dev/null
end
installDockerService $argv
set turnPort (yq (getServicePortKey "$turn") "$secrets" | extractPort)
set turnPort (yq "$portKey" "$secrets" | mutatePort "$turnPort")
cp "$secrets" "$file"
PORT="$turnPort" yq "$portKey = env(PORT)" "$file" | sudo tee "$secrets" >/dev/null
rm "$file"
end
function configureSW -V dir
configureDockerService $argv
end
function getServiceServers -V services
for i in (seq 1 3 (count $services))
printf "%s\0" $services[(math $i + 1)] $services[(math $i + 2)]
end
end
function getServiceLocations -V services -a index
set -l i (math (math (math $index - 1) / 2 "*" 3) + 1)
set -l name $services[$i]
printf "%s\0" "$name" /
end
runInstaller --force $argv
end

View file

@ -0,0 +1,185 @@
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
types {
application/javascript cjs mjs;
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
server_tokens off;
keepalive_timeout 65;
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
"" "";
default "immutable";
}
upstream php-handler {
server core:9000;
}
server {
listen 80;
# set max upload size and increase upload timeout:
client_max_body_size 512M;
client_body_timeout 300s;
fastcgi_buffers 64 4K;
# The settings allow you to optimize the HTTP2 bandwith.
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
# for tuning hints
client_body_buffer_size 512k;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
# HTTP response headers
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-XSS-Protection "1; mode=block" always;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
# Path to the root of your installation
root /var/www/html;
# Specify how to handle directories -- specifying `/index.php$request_uri`
# here as the fallback means that Nginx always exhibits the desired behaviour
# when a client requests a path that corresponds to a directory that exists
# on the server. In particular, if that directory contains an index.php file,
# that file is correctly served; if it doesn't, then the request is passed to
# the front-end controller. This consistent behaviour means that we don't need
# to specify custom rules for certain paths (e.g. images and other assets,
# `/updater`, `/ocm-provider`, `/ocs-provider`), and thus
# `try_files $uri $uri/ /index.php$request_uri`
# always provides the desired behaviour.
index index.php index.html /index.php$request_uri;
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make a regex exception for `/.well-known` so that clients can still
# access it despite the existence of the regex rule
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
# for `/.well-known`.
location ^~ /.well-known {
# The rules in this block are an adaptation of the rules
# in `.htaccess` that concern `/.well-known`.
location = /.well-known/carddav { return 301 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
# Let Nextcloud's API for `/.well-known` URIs handle all other
# requests by passing them to the front-end controller.
return 301 /index.php$request_uri;
}
# Rules borrowed from `.htaccess` to hide certain paths from clients
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
# Ensure this block, which passes PHP files to the PHP process, is above the blocks
# which handle static assets (as seen below). If this block is not declared first,
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
# to the URI, resulting in a HTTP 500 error response.
location ~ \.php(?:$|/) {
# Required for legacy support
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
fastcgi_param front_controller_active true; # Enable pretty urls
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_max_temp_file_size 0;
}
# Javascript mimetype fixes for nginx
# Note: The block below should be removed, and the js|mjs section should be
# added to the block below this one. This is a temporary fix until Nginx
# upstream fixes the js mime-type
location ~* \.(?:js|mjs)$ {
types {
text/javascript js mjs;
}
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463, $asset_immutable";
access_log off;
}
# Serve static files
location ~ \.(?:css|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463, $asset_immutable";
access_log off; # Optional: Don't log access to assets
location ~ \.wasm$ {
default_type application/wasm;
}
}
location ~ \.woff2?$ {
try_files $uri /index.php$request_uri;
expires 7d; # Cache-Control policy borrowed from `.htaccess`
access_log off; # Optional: Don't log access to assets
}
# Rule borrowed from `.htaccess`
location /remote {
return 301 /remote.php$request_uri;
}
location / {
try_files $uri $uri/ /index.php$request_uri;
}
}
}

View file

@ -0,0 +1,5 @@
memory_limit = 1G
upload_max_filesize = 16G
post_max_size = 1G
max_input_time = 3600
max_execution_time = 3600

View file

@ -0,0 +1,11 @@
services:
ryot:
image: ghcr.io/ignisda/ryot:latest
restart: unless-stopped
volumes:
- ./data:/data
db:
image: postgres
restart: unless-stopped
volumes:
- ./database:/var/lib/postgresql/data

View file

@ -0,0 +1,11 @@
services:
ryot:
environment:
DATABASE_URL: postgres://ryot:pw@db/Ryot
ports:
- 127.0.0.1:1337:8000
db:
environment:
POSTGRES_DB: Ryot
POSTGRES_USER: ryot
POSTGRES_PASSWORD: pw

View file

@ -0,0 +1,44 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l domain "tracker" ""
set -l service "ryot"
set -l source "$dir/docker-compose.secrets.yml"
source "$dir/../service.fish"
function installSW -V dir -V domain -V service -V source
set -l domain (getServiceDomain $domain)
set -l root (getServiceRoot $argv)
set -l file "$dir/docker-compose.base.yml"
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l envKey ".services.$service.environment"
set -l dbKey "$envKey.DATABASE_URL"
set -l dbUrl ( "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
initializeServiceInstallation $argv
sudo cp "$file" "$root"
URL=$dbUrl yq "$dbKey = env(URL)" "$source" | \
PW=$pw yq ".services.db.environment.POSTGRES_PASSWORD = env(PW)" | \
sudo tee (getServiceSecretsConfig $argv) >/dev/null
installDockerService $argv
end
function configureSW -V dir
configureDockerService $argv
end
function getServiceServers -V domain
printf "%s\0" $domain
end
function getServiceLocations -V service
printf "%s\0" $service /
end
function getBackupArgs
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv)
end
runInstaller --force $argv
end

View file

@ -4,70 +4,175 @@ begin
set -l root /usr/local/lib
set -l secretsFile "docker-compose.secrets.yml"
set -l nginxRoot "/etc/nginx/conf.d"
set -l portPattern "^\([.[:digit:]]\+:\)\([[:digit:]]\+\)\(:[[:digit:]]\+\)"
source "$dir/../../../../lib/software.fish"
function getRandomPort
random 49152 65535
end
function getPortPattern
echo "^\([.[:digit:]]\+:\)\([[:digit:]]\+\)\(:[[:digit:]]\+\(\/tcp\|udp\)\?\)"
end
function __substitutePort -a substitution
sed "s/$(getPortPattern)/$substitution/"
end
function extractPort
__substitutePort "\2"
end
function mutatePort -a port
__substitutePort "\1$port\3"
end
function getServiceName
argparse -i "name=" -- $argv
echo "$_flag_name"
end
function getMachineFQDN -V dir
source "$dir/../../../../lib/settings.fish"
getOSConfig fqdn
end
function getServiceRoot -V root
echo "$root/$(getServiceName $argv)"
end
function getServiceKey -a name
echo ".services.[$(echo "{}" | NAME="$name" jq "env.NAME")]"
end
function __getServiceNginxConfig -V nginxRoot
echo "$nginxRoot/$(getServiceName $argv).conf"
end
function __getServiceSecretsConfig -V secretsFile
function getServiceSecretsConfig -V secretsFile
echo "$(getServiceRoot $argv)/$secretsFile"
end
function __getServicePortKey -V secretsFile -a name
echo ".services.$name.ports[0]"
function getServicePortKey -V secretsFile -a name
echo "$(getServiceKey "$name").ports[0]"
end
function installDockerService -V dir -V nginxRoot -V portPattern
set -l services (getServiceConfigs $argv | string split0)
sudo cp (getServiceNginxConfigSource $argv) (__getServiceNginxConfig $argv)
function getServiceDomain -a subdomain domain
if [ -z "$domain" ]
set domain (getMachineFQDN)
end
for i in (seq 1 2 (count $services))
if [ -n "$subdomain" ]
set domain "$subdomain.$domain"
end
echo "$domain"
end
function getExtraServerConfig -a subdomain domain
end
function getServiceLocationConfig -a domain service location
getServiceDefaultProxy $domain $service $location "" $argv
end
function getServiceDefaultProxy -a domain service location
argparse -i "comment=" "path=" "url=" -- $argv
set -l url
set -l config (getServiceSecretsConfig $argv)
set -l portKey (getServicePortKey "$service")
set -l port (yq "$portKey" "$config" | extractPort)
if [ -n "$_flag_url" ]
set url "$_flag_url"
else
set url "http://127.0.0.1:$port"
if [ -n "$_flag_path" ]
set url "$url$_flag_path"
end
end
printf "%s\n" \
"location $location {" \
(if [ -n "$_flag_comment" ]
echo "# $_flag_comment"
end) \
"proxy_pass $url;" \
'proxy_set_header Host $host;' \
'proxy_set_header X-Real-IP $remote_addr;' \
'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' \
'proxy_set_header X-Forwarded-Proto $scheme;' \
'proxy_set_header X-Forwarded-Protocol $scheme;' \
'proxy_set_header X-Forwarded-Host $http_host;' \
(getExtraLocationSettings $argv) \
"}"
end
function getExtraLocationSettings -a domain service location
end
function initializeServiceInstallation -V dir -V nginxRoot
set -l root (getServiceRoot $argv)
sudo mkdir -p (getServiceRoot $argv)
sudo mkdir -p "$nginxRoot"
sudo mkdir -p (dirname (getServiceSecretsConfig $argv))
sudo cp "$dir/docker-compose.yml" "$root"
end
function installDockerService -V dir -V nginxRoot
set -l config (getServiceSecretsConfig $argv)
set -l servers (getServiceServers $argv | string split0)
for i in (seq 1 2 (count $servers))
set -l locations (getServiceLocations $i $argv | string split0)
for j in (seq 1 2 (count $locations))
set -l file (mktemp)
set -l config (__getServiceSecretsConfig $argv)
set -l service $services[$i]
set -l port (random 49152 65535)
set -l portKey (__getServicePortKey "$service")
set -l port (getRandomPort)
set -l service $locations[$j]
set -l portKey (getServicePortKey "$service")
set -l exposedPort
sudo mkdir -p (getServiceRoot $argv)
sudo mkdir -p "$nginxRoot"
cp "$config" "$file"
set exposedPort (yq --raw-output "$portKey" "$file" | sed "s/$portPattern/\1$port\3/")
PORT=$exposedPort yq -y "$portKey = env.PORT" "$file" | sudo tee "$config" >/dev/null
set exposedPort (yq "$portKey" "$file" | mutatePort $port)
PORT=$exposedPort yq "$portKey = env(PORT)" "$file" | sudo tee "$config" >/dev/null
end
end
end
function configureDockerService -V portPattern
set -l services (getServiceConfigs $argv | string split0)
for i in (seq 1 2 (count $services))
set -l config (__getServiceSecretsConfig $argv)
set -l service $services[$i]
set -l location $services[(math $i + 1)]
set -l portKey (__getServicePortKey "$service")
set -l port (yq --raw-output "$portKey" "$config" | sed "s/$portPattern/\2/")
function configureDockerService
set -l servers (getServiceServers $argv | string split0)
set -l nginxConfig (__getServiceNginxConfig $argv)
cat "$nginxConfig" | sed \
-e "\;location $location {;,/}/{" \
-e "s/\(proxy_pass \)\(.\+:\)\?[[:digit:]]\+\(;\)/\1\2$port\3/;" \
-e "}" | sudo tee "$nginxConfig" >/dev/null
for i in (seq 1 2 (count $servers))
set -l domain $servers[(math $i + 1)]
set -l subdomain $servers[(math $i)]
set -l locations (getServiceLocations $i $argv | string split0)
set domain (getServiceDomain "$subdomain" "$domain")
begin
printf "%s\n" \
"server {" \
"listen 80;" \
"server_name $domain;" \
(getExtraServerConfig $subdomain $domain $argv)
for j in (seq 1 2 (count $locations))
set -l service $locations[$j]
set -l location $locations[(math $j + 1)]
getServiceLocationConfig $domain $service $location $argv
end
echo "}"
end
end | nix-shell -p crossplane --run "crossplane format /dev/stdin" | sudo tee "$nginxConfig" >/dev/null
sudo systemctl restart nginx
end
function getBackupArgs -V root
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" "$root"
function getBackupArgs
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose"{,.base}".yml" (getServiceRoot $argv)
end
end

View file

@ -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

View file

@ -0,0 +1,6 @@
services:
teamspeak:
ports:
- 9987:9987/udp
- 10011:10011
- 30033:30033

View file

@ -0,0 +1,48 @@
#!/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 | \
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 -V root
printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" "$root"
end
runInstaller --force $argv
end

View file

@ -0,0 +1 @@
data/

View file

@ -0,0 +1,72 @@
services:
game:
build:
context: .
dockerfile: trackmania.Dockerfile
restart: unless-stopped
extends:
file: docker-compose.core.yml
service: tm
stdin_open: true
environment:
TM_XMLRPC_ALLOWED_REMOTE: xaseco
volumes:
- ./data/tm/cache:/app/GameData/Cache
healthcheck:
test: [CMD, bash, -c, echo '' >/dev/tcp/127.0.0.1/5000]
start_period: 1m
start_interval: 10s
interval: 5s
timeout: 3s
retries: 5
downloader:
extends:
file: docker-compose.core.yml
service: xaseco-installer
volumes:
- ./initdb.d:/cache/localdb
healthcheck:
test: [CMD, bash, -c, ls /cache/localdb/*]
start_period: 1m
start_interval: 10s
interval: 5s
timeout: 3s
retries: 5
xaseco:
restart: unless-stopped
extends:
file: docker-compose.core.yml
service: xaseco
depends_on:
game:
condition: service_healthy
db:
condition: service_healthy
environment:
TM_SERVER_HOST: game
MYSQL_HOST: db
volumes:
- ./data/xaseco:/data
db:
image: mysql:5
restart: unless-stopped
extends:
file: docker-compose.core.yml
service: db
depends_on:
downloader:
condition: service_completed_successfully
command: --sql_mode=""
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
volumes:
- ./data/db:/var/lib/mysql
- ./initdb.d:/docker-entrypoint-initdb.d
healthcheck:
test: [CMD, bash, -c, mysqladmin ping -hlocalhost -u "$$MYSQL_USER" -p"$$MYSQL_PASSWORD"]
timeout: 20s
retries: 10
volumes:
tm-server: {}
xaseco: {}

View file

@ -0,0 +1,19 @@
services:
tm:
environment: &tm-config
TM_SUPERADMIN_PASSWORD: pw
TM_SERVER_USER: null
TM_SERVER_PASSWORD: null
volumes: &tm-volumes
- ./data/tm/tracks:/app/GameData/Tracks/Challenges
db:
environment: &db-config
MYSQL_USER: xaseco
MYSQL_PASSWORD: pw
MYSQL_DATABASE: Aseco
xaseco:
environment:
<<:
- *tm-config
- *db-config
volumes: *tm-volumes

View file

@ -0,0 +1,30 @@
services:
tm:
extends:
file: docker-compose.core.secrets.yml
service: tm
volumes: &tm-volumes
- tm-server:/app
xaseco-installer:
build: &xaseco-build
context: .
dockerfile: xaseco.Dockerfile
restart: on-failure
command: "true"
<<: &xaseco-base
privileged: true
volumes: &xaseco-volumes
- xaseco:/cache
xaseco:
extends:
file: docker-compose.core.secrets.yml
service: xaseco
<<:
- *xaseco-base
- volumes: *tm-volumes
- volumes: *xaseco-volumes
build: *xaseco-build
db:
extends:
file: docker-compose.core.secrets.yml
service: db

View file

@ -0,0 +1,12 @@
services:
game:
ports:
- 2350:2350
- 2350:2350/udp
- 2353:2353
- 2353:2353/udp
command:
- /game_settings=MatchSettings/Nations/NationsBlue.txt
environment: {}
xaseco:
environment: {}

View file

@ -0,0 +1,4 @@
include:
- path:
- docker-compose.base.yml
- docker-compose.secrets.yml

View file

@ -0,0 +1,37 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l source "$dir/docker-compose.core.secrets.yml"
source "$dir/../service.fish"
function installSW -V dir -V domain -V source
set -l root (getServiceRoot $argv)
set -l tmPW (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l sqlPW (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
initializeServiceInstallation $argv
cp -rf "$dir"/{.dockerignore,docker-compose{.base,{,.core}{,.secrets}}.yml,parser.patch,tmforever-entrypoint.sh,trackmania.Dockerfile,xaseco-entrypoint.sh,xaseco.Dockerfile} "$root"
PW="$tmPW" yq "$(getServiceKey "tm").environment.TM_SUPERADMIN_PASSWORD = env(PW)" "$source" | \
PW="$sqlPW" yq "$(getServiceKey "db").environment.MYSQL_PASSWORD = env(PW)" | \
sudo tee "$root/$(basename "$source")" >/dev/null
installDockerService $argv
end
function configureSW -V dir
configureDockerService $argv
end
function getServiceServers
end
function getServiceLocations
end
function getBackupArgs
printf "%s\n" --hidden --no-ignore "^docker-compose\.(.*\.)\?.secrets.yml|data\$" (getServiceRoot $argv)
end
runInstaller --force $argv
end

View file

@ -0,0 +1,11 @@
--- a/includes/xmlparser.inc.php
+++ b/includes/xmlparser.inc.php
@@ -37,8 +37,6 @@
else
$this->data = $source;
- // escape '&' characters
- $this->data = str_replace('&', '<![CDATA[&]]>', $this->data);
// parse xml file
$parsed = xml_parse($this->parser, $this->data);

View file

@ -0,0 +1,145 @@
#!/bin/bash
set -e
configSource="GameData/Config/dedicated_cfg"
configFile="GameData/Config/live_config.xml"
settingsPath="/dedicated"
authLevelsPath="$settingsPath/authorization_levels/level"
accountPath="$settingsPath/masterserver_account"
serverPath="$settingsPath/server_options"
systemPath="$settingsPath/system_config"
TM_SUPERADMIN_PASSWORD="${TM_SUPERADMIN_PASSWORD:-$(openssl rand -base64 33)}"
TM_ADMIN_PASSWORD="${TM_ADMIN_PASSWORD:-$(openssl rand -base64 33)}"
echo "Checking whether the server is present…"
levels=(
TM_SUPERADMIN_PASSWORD 1
TM_ADMIN_PASSWORD 2
TM_USER_PASSWORD 3
)
accountOption=(
TM_SERVER_USER login
TM_SERVER_PASSWORD password
TM_SERVER_VALIDATION_KEY validation_key
)
serverOptions=(
TM_TITLE name
TM_COMMENT comment
TM_HIDDEN hide_server
TM_MAX_PLAYERS max_players
TM_PLAYER_PASSWORD password
TM_MAX_SPECTATORS max_spectators
TM_SPECTATOR_PASSWORD password_spectator
TM_LADDER_MODE ladder_mode
TM_LADDER_LIMIT_MIN ladder_serverlimit_min
TM_LADDER_LIMIT_MAX ladder_serverlimit_max
TM_ENABLE_P2P_UPLOAD enable_p2p_upload
TM_ENABLE_P2P_DOWNLOAD enable_p2p_download
TM_CALLVOTE_TIMEOUT callvote_timeout
TM_CALLVOTE_RATIO callvote_ratio
TM_ALLOW_CHALLENGE_DOWNLOAD allow_challenge_download
TM_AUTOSAVE_REPLAYS autosave_replays
TM_AUTOSAVE_VALIDATION_REPLAYS autosave_validation_replays
TM_REFEREE_PASSWORD referee_password
TM_REFEREE_VALIDATION_MODE referee_validation_mode
TM_USE_CHANGING_VALIDATION_SEED use_changing_validation_seed
)
systemOptions=(
TM_BIND_IP bind_ip_address
TM_BIND_PORT server_port
TM_P2P_PORT server_p2p_port
TM_CLIENT_PORT client_port
TM_USE_NAT_UPNP use_nat_upnp
TM_XMLRPC_PORT xmlrpc_port
TM_XMLRPC_ALLOWED_REMOTE xmlrpc_allowremote
TM_PACKMASK packmask
TM_CONNECTION_UPLOADRATE connection_uploadrate
TM_CONNECTION_DOWNLOADRATE connection_downloadrate
TM_P2P_CACHE_SIZE p2p_cache_size
TM_BLACKLIST_URL blacklist_url
TM_GUESTLIST_FILENAME guestlist_filename
TM_BLACKLIST_FILENAME blacklist_filename
TM_ALLOW_SPECTATOR_RELAYS allow_spectator_relays
TM_USE_PROXY use_proxy
TM_PROXY_LOGIN proxy_login
TM_PROXY_PASSWORD proxy_password
)
if [[ ! -x "./TrackmaniaServer" ]] || [ ! -f "$configSource".* ]; then
echo "Server not found!"
echo "Downloading TrackMania Forever Dedicated Server…"
file="$(mktemp)"
dir="$(mktemp -d)"
wget http://files2.trackmaniaforever.com/TrackmaniaServer_2011-02-21.zip -O "$file" && unzip -o "$file" -d .
fi
if [ -f "$configSource.xml" ]; then
cp "$configSource.xml" "$configFile"
elif [ -f "$configSource.txt" ]; then
cp "$configSource.txt" "$configFile"
fi
for i in $(seq 0 2 $((${#levels[@]} - 1))); do
var="${levels[$i]}"
index="${levels[$(($i + 1))]}"
password="${!var}"
if [ -n "$password" ]; then
xmlstarlet edit --inplace --update "$authLevelsPath[$index]/password" --value "$password" "$configFile"
fi
done
for i in $(seq 0 2 $((${#accountOption[@]} - 1))); do
var="${accountOption[$i]}"
option="${accountOption[$(($i + 1))]}"
value="${!var}"
if [ -n "$value" ]; then
xmlstarlet edit --inplace --update "$accountPath/$option" --value "$value" "$configFile"
fi
done
for i in $(seq 0 2 $((${#serverOptions[@]} - 1))); do
var="${serverOptions[$i]}"
option="${serverOptions[$(($i + 1))]}"
value="${!var}"
if [ -n "$value" ]; then
xmlstarlet edit --inplace --update "$serverPath/$option" --value "$value" "$configFile"
fi
done
for i in $(seq 0 2 $((${#systemOptions[@]} - 1))); do
var="${systemOptions[$i]}"
option="${systemOptions[$(($i + 1))]}"
value="${!var}"
if [ -n "$value" ]; then
xmlstarlet edit --inplace --update "$systemPath/$option" --value "$value" "$configFile"
fi
done
if [ -z "$TM_LOG_FILES" ]; then
set -- "$@" /nologs
fi
unbuffer -p ./TrackmaniaServer /dedicated_cfg="$(basename "$configFile")" /nodaemon $@

View file

@ -0,0 +1,78 @@
FROM debian:11.3
RUN apt-get update -y \
&& apt-get install -y \
expect \
inotify-tools \
parallel \
rsync \
unzip \
wget \
xmlstarlet \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /app
WORKDIR /app
COPY ./tmforever-entrypoint.sh /usr/local/bin/tmforever-foreground
ENV \
TM_BIND_IP="" \
TM_BIND_PORT="" \
TM_P2P_PORT="" \
TM_CLIENT_PORT="" \
TM_USE_NAT_UPNP="" \
\
TM_XMLRPC_PORT="" \
TM_XMLRPC_ALLOWED_REMOTE="" \
\
TM_SERVER_USER="" \
TM_SERVER_PASSWORD="" \
TM_SERVER_VALIDATION_KEY="" \
\
TM_TITLE="" \
TM_COMMENT="" \
TM_HIDDEN="" \
\
TM_PACKMASK="" \
\
TM_MAX_PLAYERS="" \
TM_PLAYER_PASSWORD="" \
\
TM_MAX_SPECTATORS="" \
TM_SPECTATOR_PASSWORD="" \
\
TM_LADDER_MODE="" \
TM_LADDER_LIMIT_MIN="" \
TM_LADDER_LIMIT_MAX="" \
\
TM_ENABLE_P2P_UPLOAD="" \
TM_ENABLE_P2P_DOWNLOAD="" \
\
TM_CALLVOTE_TIMEOUT="" \
TM_CALLVOTE_RATIO="" \
\
TM_ALLOW_CHALLENGE_DOWNLOAD="" \
TM_AUTOSAVE_REPLAYS="" \
TM_AUTOSAVE_VALIDATION_REPLAYS="" \
\
TM_REFEREE_PASSWORD="" \
TM_REFEREE_VALIDATION_MODE="" \
\
TM_USE_CHANGING_VALIDATION_SEED="" \
\
TM_SUPERADMIN_PASSWORD="" \
TM_ADMIN_PASSWORD="" \
\
TM_CONNECTION_UPLOADRATE="" \
TM_CONNECTION_DOWNLOADRATE="" \
TM_P2P_CACHE_SIZE="" \
TM_BLACKLIST_URL="" \
TM_GUESTLIST_FILENAME="" \
TM_BLACKLIST_FILENAME="" \
TM_ALLOW_SPECTATOR_RELAYS="" \
TM_USE_PROXY="" \
TM_PROXY_LOGIN="" \
TM_PROXY_PASSWORD="" \
\
TM_LOG_FILES=""
ENTRYPOINT [ "tmforever-foreground" ]

View file

@ -0,0 +1,155 @@
#!/bin/bash
export TM_USER="${TM_USER:-SuperAdmin}"
export TM_PASSWORD="${TM_PASSWORD:-$TM_SUPERADMIN_PASSWORD}"
export TM_SERVER_PORT="${TM_SERVER_PORT:-$TM_XMLRPC_PORT}"
export DEDI_USER="${DEDI_USER:-$TM_SERVER_USER}"
export DEDI_PASSWORD="${DEDI_PASSWORD:-$TM_SERVER_PASSWORD}"
overlay="$(mktemp -d)"
upperDir="$overlay/upper"
workDir="$overlay/work"
cache="/cache"
data="/data"
runDir="/opt/xaseco"
entrypoint="$cache/aseco.php"
config="$runDir/config.xml"
dbConfig="$runDir/localdatabase.xml"
dediConfig="$runDir/dedimania.xml"
pluginConfig="$runDir/plugins.xml"
settingsPath="/settings"
serverPath="$settingsPath/tmserver"
pluginTag="plugin"
pluginPath="/aseco_plugins"
tmOptions=(
TM_SERVER_HOST ip
TM_SERVER_PORT port
TM_USER login
TM_PASSWORD password
TM_TIMEOUT timeout
)
sqlOptions=(
MYSQL_HOST mysql_server
MYSQL_USER mysql_login
MYSQL_PASSWORD mysql_password
MYSQL_DATABASE mysql_database
)
dediOptions=(
DEDI_URL url
DEDI_NAME name
DEDI_USER login
DEDI_PASSWORD password
DEDI_NATION nation
DEDI_LOG_NEWS log_news
DEDI_SHOW_MOTD show_welcome
)
if [ ! -f "$entrypoint" ]; then
file="$(mktemp -u).zip"
root="$(mktemp -d)"
mkdir -p "$(dirname "$file")"
curl -v --insecure https://www.gamers.org/tmn/xaseco_116.zip -o "$file"
unzip -o "$file" -d "$root"
cp -r "$root"/xaseco/* "$cache"
fi
script="$(
printf "%s\n" \
'file="$(basename "$1")";' \
'if [[ "$file" == *".php" ]];' \
' then dir="includes";' \
'else' \
' dir=".";' \
'fi;' \
'if [ ! -f "$0/$dir/$file" ]; then' \
' mkdir -p "$0/$dir";' \
' cp "$1" "$0/$dir";' \
'fi;'
)"
find "$cache/newinstall" -type f -exec bash -c "$script" "$cache" \{\} \;
mount -t tmpfs tmpfs "$overlay"
mkdir -p "$upperDir" "$workDir"
mount -t overlay overlay -o lowerdir="$cache:$data",upperdir="$upperDir",workdir="$workDir" "$runDir"
cd "$runDir"
dos2unix "/root/parser.patch" ./includes/xmlparser.inc.php
patch -p 1 ./includes/xmlparser.inc.php "/root/parser.patch"
if [ -n "$MASTERADMIN_USER" ]; then
loginTag="tmlogin"
ipTag="ipaddress"
adminPath="$settingsPath/aseco/masteradmins"
nodesPath="$adminPath/*"
namePath="$nodesPath[1]"
ipPath="$nodesPath[2]"
if [ "$(xmlstarlet select --template -v "count($nodesPath)" "$config")" -lt 1 ]; then
xmlstarlet edit --inplace --subnode "$adminPath" --type elem -n "$loginTag" "$config"
fi
if [ "$(xmlstarlet select --template -v "count($nodesPath)" "$config")" -lt 2 ] ||
[ "$(xmlstarlet select --template -v "name($ipPath)" "$config")" != "$ipTag" ]; then
xmlstarlet edit --inplace --append "$namePath" --type elem -n "$ipTag" "$config"
fi
xmlstarlet edit --inplace --update "$namePath" --value "$MASTERADMIN_USER" "$config"
if [ -z "$MASTERADMIN_IP" ]; then
xmlstarlet edit --inplace --delete "$ipPath" "$config"
else
xmlstarlet edit --inplace --update "$ipPath" --value "$MASTERADMIN_IP" "$config"
fi
fi
for i in $(seq 0 2 $((${#tmOptions[@]} - 1))); do
var="${tmOptions[$i]}"
option="${tmOptions[$(($i + 1))]}"
value="${!var}"
if [ -n "$value" ]; then
xmlstarlet edit --inplace --update "$serverPath/$option" --value "$value" "$config"
fi
done
for i in $(seq 0 2 $((${#sqlOptions[@]} - 1))); do
var="${sqlOptions[$i]}"
option="${sqlOptions[$(($i + 1))]}"
value="${!var}"
xmlstarlet edit --inplace --update "$settingsPath/$option" --value "$value" "$dbConfig"
done
for i in $(seq 0 2 $((${#dediOptions[@]} - 1))); do
var="${dediOptions[$i]}"
option="${dediOptions[$(($i + 1))]}"
value="${!var}"
if [ -n "$value" ]; then
xmlstarlet edit --inplace --update "/dedimania/masterserver_account/$option" --value "$value" "$dediConfig"
fi
done
if [ -n "$X1_EXTRA_PLUGINS" ]; then
echo "adding plugins: $X1_EXTRA_PLUGINS"
for plugin in $X1_EXTRA_PLUGINS; do
xmlstarlet edit --inplace --subnode "$pluginPath" --type elem -n "$pluginTag" --value "$plugin" "$pluginConfig"
done
fi
if [ -n "$X1_DISABLED_PLUGINS" ]; then
for i in $(seq 1 "$(xmlstarlet select --template -v "count($pluginPath/$pluginTag)" "$pluginConfig")"); do
for plugin in $X1_DISABLED_PLUGINS; do
path="$pluginPath/$pluginTag[$i]"
if [ "$(xmlstarlet select --template -v "$path/text()" "$pluginConfig")" == "$plugin" ]; then
xmlstarlet edit --inplace --delete "$path" "$pluginConfig"
fi
done
done
fi
if [ "$1" != "download" ]; then
$@
fi

View file

@ -0,0 +1,58 @@
FROM alpine:3.14 AS base
RUN apk add xmlstarlet
FROM php:5.5-alpine
USER root
RUN apk update \
&& apk add \
bash \
unzip \
ca-certificates \
# xmlstarlet dependencies
musl \
libxslt \
libxml2
RUN update-ca-certificates
RUN docker-php-ext-install mysql
COPY --from=base /usr/bin/xmlstarlet /usr/bin
COPY ./xaseco-entrypoint.sh /usr/local/bin/xaseco-foreground
COPY ./parser.patch /root/parser.patch
# Server dir
RUN mkdir /cache
# Override dir
RUN mkdir /data
# Merged dir
RUN mkdir -p /opt/xaseco
WORKDIR /opt/xaseco
ENV \
MASTERADMIN_USER="" \
MASTERADMIN_IP="" \
\
X1_EXTRA_PLUGINS="" \
X1_DISABLED_PLUGINS="" \
\
TM_SERVER_HOST="" \
TM_SERVER_PORT="" \
TM_XMLRPC_PORT="" \
TM_TIMEOUT="" \
\
TM_USER="" \
TM_PASSWORD="" \
TM_SUPERADMIN_PASSWORD="" \
\
MYSQL_HOST="" \
MYSQL_USER="" \
MYSQL_PASSWORD="" \
MYSQL_DATABASE="" \
\
DEDI_URL="" \
DEDI_NAME="" \
DEDI_USER="" \
DEDI_PASSWORD="" \
DEDI_NATION="" \
DEDI_LOG_NEWS="" \
DEDI_SHOW_MOTD=""
ENTRYPOINT [ "xaseco-foreground" ]
CMD [ "php", "./aseco.php" ]

View file

@ -2,16 +2,13 @@ services:
vaultwarden:
image: vaultwarden/server
restart: unless-stopped
extends:
file: docker-compose.secrets.yml
service: vaultwarden
volumes:
- ./data:/data
- /etc/localtime:/etc/localtime:ro
environment:
DOMAIN: https://passwords.nuth.ch
DOMAIN: null
SMTP_HOST: bridge
SMTP_FROM: no-reply@nuth.ch
SMTP_FROM: null
SMTP_FROM_VALUE: vaultwarden
SMTP_PORT: 25
SMTP_ACCEPT_INVALID_CERTS: "true"
@ -20,9 +17,6 @@ services:
db:
image: mariadb
restart: unless-stopped
extends:
file: docker-compose.secrets.yml
service: db
volumes:
- ./db:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro

View file

@ -1,18 +1,25 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l domain "passwords"
set -l source "$dir/docker-compose.secrets.yml"
source "$dir/../service.fish"
function installSW -V dir -V source
function installSW -V dir -V domain -V source
set -l file "$dir/docker-compose.base.yml"
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
set -l dbKey ".services.vaultwarden.environment.DATABASE_URL"
set -l dbUrl (yq --raw-output "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
sudo cp "$dir/docker-compose.yml" (getServiceRoot $argv)
set -l envKey ".services.vaultwarden.environment"
set -l dbKey "$envKey.DATABASE_URL"
set -l dbUrl (yq "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/")
initializeServiceInstallation $argv
URL=$dbUrl yq "$dbKey = env.URL" "$source" | \
PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env.PW" | \
sudo tee (__getServiceSecretsConfig $argv) >/dev/null
URL="https://$domain.$(getMachineFQDN)" yq "$envKey.DOMAIN = env(URL)" "$file" | \
ADDRESS="noreply@$(getMachineFQDN)" yq "$envKey.SMTP_FROM = env(ADDRESS)" | \
sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null
URL=$dbUrl yq "$dbKey = env(URL)" "$source" | \
PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env(PW)" | \
sudo tee (getServiceSecretsConfig $argv) >/dev/null
installDockerService $argv
end
@ -21,13 +28,13 @@ begin
configureDockerService $argv
end
function getServiceNginxConfigSource -V dir
echo "$dir/vaultwarden.conf"
function getServiceServers -V domain
printf "%s\0" "$domain" ""
end
function getServiceConfigs
function getServiceLocations
argparse -i "name=" -- $argv
printf "%s\0" "$_flag_name" "/"
printf "%s\0" "$_flag_name" /
end
function getBackupArgs -V root

View file

@ -1,12 +0,0 @@
server {
listen 80;
server_name passwords.nuth.ch;
location / {
proxy_pass http://127.0.0.1:1337;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View file

@ -21,7 +21,9 @@ function runActionConfigure
end
end
function disposeAction
function disposeAction -V dir
source "$dir/hooks.fish"
source "$dir/nix.fish"
runHook actionPostRun || true
and uninstallNixPkgs
and sudo git config remove-section --system safe || true

View file

@ -10,11 +10,16 @@ sudo mkdir -p "$containerDir/rootfs/$valhallaRoot"
begin
printf "%s\n" \
"# For docker" \
"" \
"# Docker" \
"lxc.apparmor.profile = unconfined" \
"" \
"# Shared Folder" \
"lxc.mount.entry = $(realpath "$dir/../..") $valhallaRoot none bind 0 0"
"lxc.mount.entry = $(realpath "$dir/../..") $valhallaRoot none bind 0 0" \
"" \
"# VPN" \
"lxc.cgroup.devices.allow = c 10:200 rwm"
"lxc.mount.entry = /dev/net dev/net none bind,create=dir 0 0"
end | sudo tee -a "$containerDir/config" > /dev/null
sudo lxc-start "$container"