File size: 2,224 Bytes
84e8204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
#
# install_godot.sh - install the latest stable Godot editor + export templates
# on a Debian/Ubuntu Linux development machine.
#
# This is the scripted form of STEP 1.1 from docs/BUILD_ANDROID.md.
# It is safe to re-run; it overwrites the previous binary.
#
set -euo pipefail

GODOT_VERSION="${GODOT_VERSION:-4.7.2-stable}"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

echo "==> Installing Godot ${GODOT_VERSION} into ${INSTALL_DIR}"

# 1. Fetch the editor binary.
#    The version-numbered name on the release server is the download URL.
EDITOR_URL="https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}/Godot_v${GODOT_VERSION}_linux.x86_64.zip"
curl -fL --retry 3 --max-time 600 -o "${TMP_DIR}/godot.zip" "${EDITOR_URL}"

# 2. Unzip and install.
unzip -o -q "${TMP_DIR}/godot.zip" -d "${TMP_DIR}"
install -m 0755 "${TMP_DIR}/Godot_v${GODOT_VERSION}_linux.x86_64" "${INSTALL_DIR}/godot"

# 3. Redirect the .editor_settings templates dir so export works on first run.
TEMPLATE_DIR="${HOME}/.local/share/godot/export_templates/$(echo "${GODOT_VERSION}" | sed 's/-stable/.stable/')"
mkdir -p "${TEMPLATE_DIR}"
TPZ_URL="https://github.com/godotengine/godot/releases/download/${GODOT_VERSION}/Godot_v${GODOT_VERSION}_export_templates.tpz"
curl -fL --retry 3 --max-time 600 -o "${TMP_DIR}/templates.tpz" "${TPZ_URL}" || {
  echo "!! Could not auto-download export templates." >&2
  echo "   In the editor: Editor > Manage Export Templates > Download and Install." >&2
}
if [ -f "${TMP_DIR}/templates.tpz" ]; then
  unzip -o -q "${TMP_DIR}/templates.tpz" -d "${TMP_DIR}/tpl"
  cp -f "${TMP_DIR}"/tpl/templates/* "${TEMPLATE_DIR}/" 2>/dev/null || true
fi

# 4. Runtime libraries Godot needs on a headless Debian box.
#    (Only the libs are installed here; skip if you already have a desktop.)
if command -v apt-get >/dev/null 2>&1; then
  export DEBIAN_FRONTEND=noninteractive
  apt-get update -qq || true
  apt-get install -y -qq \
    libfontconfig1 libfreetype6 libx11-6 libxcursor1 libxinerama1 \
    libxrandr2 libxi6 libgl1 libasound2 libpulse0 unzip curl || true
fi

echo "==> Done. Verify with: godot --version"
godot --version