Upload files to "/"

Initial
This commit is contained in:
2026-10-29 21:20:05 +00:00
commit 4689fe94a8
8 changed files with 417 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# AMP update stage: installs/updates Horizon into the instance and prepares the game files.
# amp-install.sh <instance-base-dir> [tag]
set -euo pipefail
BASE=${1:?base dir}; TAG=${2:-latest}
cd "$BASE"
command -v python3 >/dev/null || { echo "python3 is required on the host (apt install python3)"; exit 1; }
args=(--dir "$BASE/horizon" --bin "$BASE/bin")
[ "$TAG" = latest ] || [ "$TAG" = nightly ] || args+=(--version "$TAG")
echo "Installing Horizon ($TAG)..."
curl -fsSL https://raw.githubusercontent.com/horizon-rust/horizon/main/packaging/server/install.sh | sh -s -- "${args[@]}"
# Game files: Minecraft 26.3 from Mojang (pinned + verified) -> horizon-prepare. Java 25 is fetched if missing.
HORIZON_FETCH_JAVA=1 HORIZON_PREP_WORK="$BASE/.prep" bash "$BASE/prepare-headless.sh" "$BASE/horizon/current"
echo "Horizon install complete."
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# AMP start: first run writes server/server.toml from the AMP settings, then runs the server in the
# foreground with its console on stdin (AMP's console). amp-start.sh <base-dir> <port>
set -euo pipefail
BASE=${1:?base dir}; PORT=${2:-25565}
cd "$BASE"; mkdir -p server
HS="$BASE/bin/horizon-server"
if [ ! -f server/server.toml ]; then
[ "${HORIZON_EULA:-false}" = true ] || { echo "Accept the Minecraft EULA in AMP's Horizon settings first."; exit 1; }
[ -n "${HORIZON_SEED:-}" ] || unset HORIZON_SEED
[ -n "${HORIZON_OP:-}" ] || unset HORIZON_OP
[ -n "${HORIZON_OP:-}" ] && export HORIZON_PLAYERS="${HORIZON_PLAYERS:-$HORIZON_OP}"
HORIZON_PORT="$PORT" "$HS" --dir server init --yes
else
# Keep the port in step with AMP's port setting (ignored if this Horizon build names the key differently).
"$HS" --dir server config set "server.port=$PORT" >/dev/null 2>&1 || true
fi
exec "$HS" --dir server run
+109
View File
@@ -0,0 +1,109 @@
Meta.DisplayName=Horizon (Minecraft 26.3 in Rust)
Meta.Description=Horizon dedicated server: a Rust rewrite of Minecraft Java Edition 26.3. Vanilla 26.3 and Horizon clients can join.
Meta.OS=Linux
Meta.AarchSupport=None
Meta.Arch=x86_64
Meta.Author=Horizon Ports
Meta.URL=https://playhorizon.dev
Meta.DisplayImageSource=
Meta.EndpointURIFormat=
Meta.ConfigManifest=horizon-serverconfig.json
Meta.MetaConfigManifest=horizon-servermetaconfig.json
Meta.ConfigRoot=horizon-server.kvp
Meta.MinAMPVersion=2.6.3.0
Meta.SpecificDockerImage=cubecoders/ampbase:debian
Meta.DockerRequired=False
Meta.DockerBaseReadOnly=False
Meta.ContainerPolicy=Supported
Meta.ContainerPolicyReason=
Meta.ExtraSetupStepsURI=
Meta.Prerequisites=[]
Meta.ExtraContainerPackages=["python3","curl","ca-certificates"]
Meta.ConfigReleaseState=NotSpecified
Meta.NoCommercialUsage=False
Meta.ConfigVersion=1
Meta.ReleaseNotes=
Meta.BreakingReleaseNotes=
Meta.AppConfigId=954e5650-c94e-4618-b590-a0aeb6a518fd
Meta.ImportableExtensions=[]
Meta.AppIsMultiIPAware=False
App.DisplayName=Horizon
App.RootDir=./horizon/
App.BaseDirectory=./horizon/
App.SteamWorkshopDownloadLocation=
App.ExecutableWin=
App.ExecutableLinux=/bin/bash
App.WorkingDir=
App.LinuxCommandLineArgs=
App.WindowsCommandLineArgs=
App.CommandLineArgs="{{$FullBaseDir}}amp-start.sh" "{{$FullBaseDir}}" {{$ServerPort}}
App.UseLinuxIOREDIR=False
App.AppSettings={}
App.EnvironmentVariables={"HORIZON_EULA":"{{HorizonEula}}","HORIZON_WORLD":"{{HorizonWorld}}","HORIZON_SEED":"{{HorizonSeed}}","HORIZON_WHITELIST":"{{HorizonWhitelist}}","HORIZON_OP":"{{HorizonOp}}","HORIZON_NO_AUDIO":"1"}
App.CommandLineParameterFormat=--{0} {1}
App.CommandLineParameterDelimiter=
App.ExitMethod=String
App.ExitTimeout=180
App.ExitString=stop
App.ExitFile=app_exit.lck
App.HasWriteableConsole=True
App.HasReadableConsole=True
App.UDPLogger=False
App.SupportsLiveSettingsChanges=False
App.LiveSettingChangeCommandFormat=
App.ForceIPBinding=False
App.SupportsIPv6=False
App.ApplicationIPBinding=0.0.0.0
App.Ports=@IncludeJson[horizon-serverports.json]
App.AdminPortRef=0
App.PrimaryApplicationPortRef=ServerPort
App.UniversalSleepApplicationUDPPortRef=0
App.UniversalSleepSteamQueryPortRef=0
App.MaxUsers=20
App.UseRandomAdminPassword=False
App.PersistRandomPassword=False
App.RemoteAdminPassword=
App.AdminMethod=STDIO
App.IgnoreSTDOUTAfterRCON=False
App.AdminLoginTransform=None
App.LoginTransformPrefix=
App.RCONConnectDelaySeconds=5
App.RCONConnectRetrySeconds=5
App.RCONHeartbeatMinutes=0
App.RCONHeartbeatCommand=
App.TelnetLoginFormat={0}
App.UpdateSources=@IncludeJson[horizon-serverupdates.json]
App.PreStartStages=[]
App.UserActions=[]
App.ForceUpdate=False
App.ForceUpdateReason=
App.Compatibility=None
App.SteamUpdateAnonymousLogin=True
App.SteamForceLoginPrompt=False
App.RapidStartup=False
App.SmartExcludeExemptions=["*.toml","*.json","*.properties","*.txt"]
App.SmartExcludeSupported=True
App.DumpFullChildProcessTree=False
App.MonitorChildProcessName=
App.MonitorDirectChildOnly=False
App.SupportsUniversalSleep=False
App.WakeupMode=Any
App.ApplicationReadyMode=RegexMatch
Console.FilterMatchRegex=\e\[(\d+;)*(\d+)?[ABCDHJKfmsu]
Console.FilterMatchReplacement=
Console.ThrowawayMessageRegex=
Console.AppReadyRegex=^.*\]: Done \([\d.]+s\)!
Console.UserJoinRegex=^.*\]: (?<username>\w+) joined the game$
Console.UserLeaveRegex=^.*\]: (?<username>\w+) left the game$
Console.UserChatRegex=^.*\]: (?:\[Not Secure\] )?<(?<username>\w+)> (?<message>.+)$
Console.UpdateAvailableRegex=^$
Console.MetricsRegex=
Console.SuppressLogAtStart=False
Console.ActivateLogRegex=
Console.UserActions={}
Limits.SleepMode=False
Limits.SleepOnStart=False
Limits.SleepDelayMinutes=5
Limits.DozeDelay=2
Limits.AutoRetryCount=2
Limits.SleepStartThresholdSeconds=25
+93
View File
@@ -0,0 +1,93 @@
[
{
"DisplayName": "Accept Minecraft EULA",
"Category": "Horizon:stadia_controller",
"Subcategory": "Server:dns:1",
"Description": "Required to start. https://aka.ms/MinecraftEULA",
"Keywords": "eula",
"FieldName": "HorizonEula",
"InputType": "checkbox",
"ParamFieldName": "HorizonEula",
"IncludeInCommandLine": false,
"DefaultValue": "false",
"EnumValues": { "True": "true", "False": "false" }
},
{
"DisplayName": "World Name",
"Category": "Horizon:stadia_controller",
"Subcategory": "Server:dns:1",
"Description": "World folder. Only used on the first start (after that, edit server/server.toml)",
"Keywords": "world,level",
"FieldName": "HorizonWorld",
"InputType": "text",
"ParamFieldName": "HorizonWorld",
"IncludeInCommandLine": false,
"DefaultValue": "world",
"EnumValues": {}
},
{
"DisplayName": "Seed",
"Category": "Horizon:stadia_controller",
"Subcategory": "Server:dns:1",
"Description": "Empty for random. First start only",
"Keywords": "seed",
"FieldName": "HorizonSeed",
"InputType": "text",
"ParamFieldName": "HorizonSeed",
"IncludeInCommandLine": false,
"DefaultValue": "",
"EnumValues": {}
},
{
"DisplayName": "Whitelist",
"Category": "Horizon:stadia_controller",
"Subcategory": "Server:dns:1",
"Description": "Only whitelisted players can join (vanilla default). First start only; then use 'whitelist on|off' in the console",
"Keywords": "whitelist",
"FieldName": "HorizonWhitelist",
"InputType": "checkbox",
"ParamFieldName": "HorizonWhitelist",
"IncludeInCommandLine": false,
"DefaultValue": "true",
"EnumValues": { "True": "true", "False": "false" }
},
{
"DisplayName": "First Operator",
"Category": "Horizon:stadia_controller",
"Subcategory": "Server:dns:1",
"Description": "Your Minecraft name: whitelisted and made operator on the first start",
"Keywords": "op,admin,operator",
"FieldName": "HorizonOp",
"InputType": "text",
"ParamFieldName": "HorizonOp",
"IncludeInCommandLine": false,
"DefaultValue": "",
"EnumValues": {}
},
{
"DisplayName": "Horizon Release",
"Category": "Horizon:stadia_controller",
"Subcategory": "Install:download:2",
"Description": "latest (current Nightly) or a tag such as v0.2.97. Applied on Update",
"Keywords": "version,tag,release",
"FieldName": "HorizonTag",
"InputType": "text",
"ParamFieldName": "HorizonTag",
"IncludeInCommandLine": false,
"DefaultValue": "latest",
"EnumValues": {}
},
{
"DisplayName": "Template Repo",
"Category": "Horizon:stadia_controller",
"Subcategory": "Install:download:2",
"Description": "owner/repo/branch holding amp-install.sh, amp-start.sh and prepare-headless.sh",
"Keywords": "repo,template",
"FieldName": "TemplateRepo",
"InputType": "text",
"ParamFieldName": "TemplateRepo",
"IncludeInCommandLine": false,
"DefaultValue": "REPLACE_ME/horizon-amp/main",
"EnumValues": {}
}
]
+1
View File
@@ -0,0 +1 @@
[]
+9
View File
@@ -0,0 +1,9 @@
[
{
"Protocol": "TCP",
"Port": 25565,
"Ref": "ServerPort",
"Name": "Game Port",
"Description": "Port players join on (Java Edition 26.3 and Horizon clients)"
}
]
+48
View File
@@ -0,0 +1,48 @@
[
{
"UpdateStageName": "Fetch install script",
"UpdateSourcePlatform": "Linux",
"UpdateSource": "FetchURL",
"UpdateSourceData": "https://raw.githubusercontent.com/{{TemplateRepo}}/amp-install.sh",
"UpdateSourceArgs": "amp-install.sh",
"UpdateSourceTarget": "{{$FullBaseDir}}",
"OverwriteExistingFiles": true,
"SkipOnFailure": false
},
{
"UpdateStageName": "Fetch start script",
"UpdateSourcePlatform": "Linux",
"UpdateSource": "FetchURL",
"UpdateSourceData": "https://raw.githubusercontent.com/{{TemplateRepo}}/amp-start.sh",
"UpdateSourceArgs": "amp-start.sh",
"UpdateSourceTarget": "{{$FullBaseDir}}",
"OverwriteExistingFiles": true,
"SkipOnFailure": false
},
{
"UpdateStageName": "Fetch prepare script",
"UpdateSourcePlatform": "Linux",
"UpdateSource": "FetchURL",
"UpdateSourceData": "https://raw.githubusercontent.com/{{TemplateRepo}}/prepare-headless.sh",
"UpdateSourceArgs": "prepare-headless.sh",
"UpdateSourceTarget": "{{$FullBaseDir}}",
"OverwriteExistingFiles": true,
"SkipOnFailure": false
},
{
"UpdateStageName": "Set Executable Flag",
"UpdateSourcePlatform": "Linux",
"UpdateSource": "SetExecutableFlag",
"UpdateSourceArgs": "{{$FullBaseDir}}amp-start.sh",
"SkipOnFailure": false
},
{
"UpdateStageName": "Install Horizon + prepare game files",
"UpdateSourcePlatform": "Linux",
"UpdateSourceArch": "x86_64",
"UpdateSource": "Executable",
"UpdateSourceData": "/bin/bash",
"UpdateSourceArgs": "\"{{$FullBaseDir}}amp-install.sh\" \"{{$FullBaseDir}}\" \"{{HorizonTag}}\"",
"SkipOnFailure": false
}
]
+125
View File
@@ -0,0 +1,125 @@
#!/usr/bin/env bash
# Prepares Horizon's game files on a headless box (VPS, Docker, AMP) with no Minecraft launcher.
#
# It builds the launcher layout horizon-prepare reads (versions/<v>/<v>.json, <v>.jar, libraries/)
# straight from Mojang's CDN, using the exact files research-lock.json pins (every file is
# SHA-1 checked here and again by horizon-prepare), then runs horizon-prepare.
#
# prepare-headless.sh <horizon-release-dir>
#
# Needs: bash, python3, and Java 25 (JAVA_HOME or `java` on PATH). With HORIZON_FETCH_JAVA=1
# and no Java 25 found, it downloads an Eclipse Temurin 25 JRE into the work folder.
# By running this you accept the Minecraft EULA (https://aka.ms/MinecraftEULA). You should own
# Minecraft Java Edition.
set -euo pipefail
ROOT=${1:?usage: prepare-headless.sh <horizon-release-dir>}
ROOT=$(cd "$ROOT" && pwd)
LOCK="$ROOT/research-lock.json"
[ -f "$LOCK" ] || { echo "prepare: no research-lock.json in $ROOT" >&2; exit 1; }
[ -x "$ROOT/horizon-prepare" ] || { echo "prepare: no horizon-prepare in $ROOT" >&2; exit 1; }
command -v python3 >/dev/null || { echo "prepare: python3 is needed" >&2; exit 1; }
WORK=${HORIZON_PREP_WORK:-"$ROOT/.prep-work"}
mkdir -p "$WORK"
VERSION=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["minecraft"]["version"])' "$LOCK")
JAVA_MAJOR=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["minecraft"]["java_major"])' "$LOCK")
# Skip when these exact pins were already prepared (a Horizon update that changes them re-prepares).
STAMP="$ROOT/.local/horizon-client/.prepared-lock.sha256"
LOCK_SUM=$(python3 -c 'import hashlib,sys; print(hashlib.sha256(open(sys.argv[1],"rb").read()).hexdigest())' "$LOCK")
if [ "${HORIZON_REPREPARE:-0}" != 1 ] && [ -f "$STAMP" ] && [ "$(cat "$STAMP")" = "$LOCK_SUM" ] \
&& [ -n "$(ls -A "$ROOT/.local/horizon-client/$VERSION" 2>/dev/null)" ]; then
echo "prepare: $VERSION already prepared for this Horizon build (HORIZON_REPREPARE=1 to redo)"
exit 0
fi
echo "prepare: fetching the pinned Minecraft $VERSION files from Mojang..."
python3 - "$LOCK" "$WORK/minecraft" "$WORK/server.jar" <<'PY'
import hashlib, json, os, sys, urllib.request
from concurrent.futures import ThreadPoolExecutor
lock = json.load(open(sys.argv[1]))["minecraft"]
mc, server_jar = sys.argv[2], sys.argv[3]
v = lock["version"]
def sha1(path):
h = hashlib.sha1()
with open(path, "rb") as f:
for chunk in iter(lambda: f.read(1 << 20), b""):
h.update(chunk)
return h.hexdigest()
def get(url, dest, want):
if os.path.isfile(dest) and sha1(dest) == want:
return
os.makedirs(os.path.dirname(dest), exist_ok=True)
tmp = dest + ".part"
for attempt in range(3):
try:
with urllib.request.urlopen(url, timeout=60) as r, open(tmp, "wb") as f:
while chunk := r.read(1 << 20):
f.write(chunk)
break
except Exception as e:
if attempt == 2:
raise SystemExit(f"prepare: download failed: {url}: {e}")
got = sha1(tmp)
if got != want:
os.remove(tmp)
raise SystemExit(f"prepare: {url} has sha1 {got}, expected {want}")
os.replace(tmp, dest)
manifest_path = os.path.join(mc, "versions", v, f"{v}.json")
get(f"https://piston-meta.mojang.com/v1/packages/{lock['manifest_sha1']}/{v}.json",
manifest_path, lock["manifest_sha1"])
manifest = json.load(open(manifest_path))
d = manifest["downloads"]
assert d["client"]["sha1"] == lock["client_sha1"] and d["server"]["sha1"] == lock["server_sha1"]
jobs = [(d["client"]["url"], os.path.join(mc, "versions", v, f"{v}.jar"), d["client"]["sha1"]),
(d["server"]["url"], server_jar, d["server"]["sha1"])]
# Every library artifact, any OS: horizon-prepare picks the ones it needs.
for lib in manifest.get("libraries", []):
a = lib.get("downloads", {}).get("artifact")
if a and a.get("url") and a.get("path"):
jobs.append((a["url"], os.path.join(mc, "libraries", a["path"]), a["sha1"]))
with ThreadPoolExecutor(8) as pool:
list(pool.map(lambda j: get(*j), jobs))
print(f"prepare: {len(jobs)} files verified")
PY
# Java: JAVA_HOME, PATH, or (opt-in) a downloaded Temurin JRE.
java_ok() { "$1" -version 2>&1 | grep -Eq "version \"$JAVA_MAJOR([.\"]|$)"; }
if [ -n "${JAVA_HOME:-}" ] && [ -x "$JAVA_HOME/bin/java" ] && java_ok "$JAVA_HOME/bin/java"; then :
elif command -v java >/dev/null && java_ok "$(command -v java)"; then
JAVA_HOME=$(dirname "$(dirname "$(readlink -f "$(command -v java)")")"); export JAVA_HOME
elif [ "${HORIZON_FETCH_JAVA:-0}" = 1 ]; then
if [ ! -x "$WORK/jre/bin/java" ]; then
echo "prepare: downloading Temurin $JAVA_MAJOR JRE..."
mkdir -p "$WORK/jre"
python3 - "$JAVA_MAJOR" "$WORK/jre.tar.gz" <<'PY'
import sys, urllib.request
url = f"https://api.adoptium.net/v3/binary/latest/{sys.argv[1]}/ga/linux/x64/jre/hotspot/normal/eclipse"
urllib.request.urlretrieve(url, sys.argv[2])
PY
tar -xzf "$WORK/jre.tar.gz" -C "$WORK/jre" --strip-components=1
rm -f "$WORK/jre.tar.gz"
fi
export JAVA_HOME="$WORK/jre"
else
echo "prepare: Java $JAVA_MAJOR not found (set JAVA_HOME, or HORIZON_FETCH_JAVA=1 to download one)" >&2
exit 1
fi
export PATH="$JAVA_HOME/bin:$PATH"
echo "prepare: running horizon-prepare (a few minutes)..."
"$ROOT/horizon-prepare" --root "$ROOT" --prepare \
--server-jar "$WORK/server.jar" --minecraft-dir "$WORK/minecraft"
# The launcher copy and the JRE aren't needed after this; keep them only if asked.
[ "${HORIZON_KEEP_WORK:-0}" = 1 ] || rm -rf "$WORK/minecraft" "$WORK/server.jar"
echo "$LOCK_SUM" > "$STAMP"
echo "prepare: done -> $ROOT/.local/horizon-client/$VERSION"