summaryrefslogtreecommitdiff
path: root/user_install_script.sh
blob: cb76b579404d9740ac719819162eaea1dc329ba6 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
set -euo pipefail

# Hardcoded mirror host for GitHub/API/RAW substitutions
DECKY_MIRROR_HOST="__DECKY_MIRROR_HOST__"
DECKY_PLUGIN_MIRROR_HOST="__DECKY_PLUGIN_MIRROR_HOST__"
DECKY_PLUGIN_TARGET_ID="__DECKY_PLUGIN_ID__"

# Check if Decky Loader is already installed and running on SteamOS
echo "Checking if Decky Loader is already installed and running..."
if systemctl is-active --quiet plugin_loader.service 2>/dev/null; then
  echo "Decky Loader (plugin_loader.service) is already running. Skipping Decky Loader installation."
  SKIP_DECKY_INSTALL=true
else
  echo "Decky Loader is not running or not installed. Proceeding with installation."
  SKIP_DECKY_INSTALL=false
fi

# Download the official installer script, rewrite domains to the mirror, then execute.
# This keeps the original installer logic intact while swapping network endpoints.
tmp_script="/tmp/decky_user_install_script.sh"

if [ "$SKIP_DECKY_INSTALL" != true ]; then
  if ! curl -fsSL "https://${DECKY_MIRROR_HOST}/SteamDeckHomebrew/decky-installer/releases/latest/download/user_install_script.sh" \
    | sed -E \
        -e "s#github\.com#${DECKY_MIRROR_HOST}#g" \
        -e "s#api\.github\.com#api.${DECKY_MIRROR_HOST}#g" \
        -e "s#raw\.githubusercontent\.com/([^/]+)/([^/]+)/([^/]+)/#${DECKY_MIRROR_HOST}/\1/\2/plain/#g" \
    > "${tmp_script}"; then
    echo "Failed to download or rewrite the official installer script." >&2
    exit 1
  fi

  bash "${tmp_script}"
fi

# Download and verify Decky Loader client (mirror-hosted).
decky_client="/tmp/decky_client.py"
decky_client_checksum="/tmp/decky_client.py.sha256"

# Download the client script
if ! curl -fsSL "https://${DECKY_MIRROR_HOST}/AeroCore-IO/decky-installer/releases/latest/download/decky_client.py" -o "${decky_client}"; then
  echo "Failed to download Decky Loader client script." >&2
  exit 1
fi

# Download the checksum file
if ! curl -fsSL "https://${DECKY_MIRROR_HOST}/AeroCore-IO/decky-installer/releases/latest/download/decky_client.py.sha256" -o "${decky_client_checksum}"; then
  echo "Failed to download checksum file for Decky Loader client." >&2
  exit 1
fi

# Verify the checksum
if command -v sha256sum >/dev/null 2>&1; then
  if ! (cd /tmp && sha256sum -c decky_client.py.sha256); then
    echo "Checksum verification failed for Decky Loader client. File may be compromised." >&2
    rm -f "${decky_client}" "${decky_client_checksum}"
    exit 1
  fi
elif command -v shasum >/dev/null 2>&1; then
  if ! (cd /tmp && shasum -a 256 -c decky_client.py.sha256); then
    echo "Checksum verification failed for Decky Loader client. File may be compromised." >&2
    rm -f "${decky_client}" "${decky_client_checksum}"
    exit 1
  fi
else
  echo "Warning: No checksum tool available (sha256sum or shasum). Skipping integrity verification." >&2
  echo "This is a security risk. Consider installing sha256sum or shasum." >&2
fi

# Install the plugin
python3 "${decky_client}" install \
  --store-url "https://${DECKY_PLUGIN_MIRROR_HOST}/plugins" \
  --target-id "${DECKY_PLUGIN_TARGET_ID}"

# Configure the custom store URL for future use
python3 "${decky_client}" configure-store "https://${DECKY_PLUGIN_MIRROR_HOST}/plugins"

# Clean up
rm -f "${decky_client}" "${decky_client_checksum}"