Add scripts for installing Minecraft
This commit is contained in:
parent
0a8e21c3da
commit
c68aca4a12
2 changed files with 106 additions and 0 deletions
|
@ -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
|
74
scripts/Common/Software/docker/services/minecraft/main.fish
Normal file
74
scripts/Common/Software/docker/services/minecraft/main.fish
Normal file
|
@ -0,0 +1,74 @@
|
|||
#!/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 --raw-output0 ".services | keys[]" "$config" | string split0)
|
||||
set -l envKey "$(getServiceKey "$service").environment"
|
||||
cp "$config" "$file"
|
||||
|
||||
and yq "$envKey.UID = $uid" "$file" | \
|
||||
yq "$envKey.GID = $gid" | \
|
||||
yq -y . | \
|
||||
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
|
Loading…
Reference in a new issue