#!/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 printf "%s\n" --hidden --no-ignore "config|data|mods|worlds|\.properties\$" --exclude "docker-compose.yml" (getServiceRoot $argv) end runInstaller --force $argv end