-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·367 lines (325 loc) · 12.7 KB
/
install.sh
File metadata and controls
executable file
·367 lines (325 loc) · 12.7 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#!/usr/bin/env bash
# install.sh - Complete Serious Games Lab installer
#
# Performs a full installation:
# 1. Distributes binaries from downloads/sglBinaries_* to game INSTALL/ directories
# 2. Installs all system dependencies (apt packages, venvs, git clones)
# 3. Installs FlightGear (AppImage)
# 4. Downloads Lutris wine runners for binary games
# 5. Applies Wine fixes for Rowan games (MiG Alley, Battle of Britain)
#
# Usage:
# sudo ./install.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$SCRIPT_DIR"
DOWNLOADS_DIR="$REPO_ROOT/downloads"
# --- Must run as root (for apt-get) ---
if [[ $EUID -ne 0 ]]; then
echo "This script must be run with sudo."
echo "Usage: sudo $0"
exit 1
fi
REAL_USER="${SUDO_USER:-$USER}"
REAL_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
echo ""
echo "=============================================="
echo " Serious Games Lab - Complete Installer"
echo "=============================================="
echo ""
# ==========================================================
# System Audit
# ==========================================================
echo "=============================================="
echo " System Audit"
echo "=============================================="
echo ""
AUDIT_WARNINGS=0
# --- OS version ---
if [[ -f /etc/os-release ]]; then
. /etc/os-release
if [[ "$ID" == "ubuntu" && "$VERSION_ID" == "24.04" ]]; then
echo " [OK] OS: Ubuntu ${VERSION_ID} (${PRETTY_NAME})"
else
echo " [WARN] OS: ${PRETTY_NAME:-$ID $VERSION_ID} — Ubuntu 24.04 expected"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
else
echo " [WARN] OS: could not detect — Ubuntu 24.04 expected"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
# --- Disk space ---
AVAIL_KB=$(df --output=avail "$REPO_ROOT" | tail -1)
AVAIL_GB=$(( AVAIL_KB / 1048576 ))
RECOMMENDED_GB=500
if [[ $AVAIL_GB -lt $RECOMMENDED_GB ]]; then
echo " [WARN] Disk space: ${AVAIL_GB} GB available (${RECOMMENDED_GB} GB recommended)"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
else
echo " [OK] Disk space: ${AVAIL_GB} GB available (${RECOMMENDED_GB} GB recommended)"
fi
# --- Graphics driver ---
if lsmod | grep -q nouveau; then
echo " [WARN] Graphics: nouveau driver — proprietary NVIDIA recommended (not essential)"
echo " Fix: sudo ubuntu-drivers autoinstall && sudo reboot"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
elif NVIDIA_VER=$(dpkg -l 2>/dev/null | grep -oP 'nvidia-driver-\K[0-9]+' | head -1) && [[ -n "$NVIDIA_VER" ]]; then
if [[ $NVIDIA_VER -ge 525 && $NVIDIA_VER -le 575 ]]; then
echo " [OK] Graphics: NVIDIA driver $NVIDIA_VER (DXVK compatible)"
else
echo " [WARN] Graphics: NVIDIA driver $NVIDIA_VER — not DXVK compatible"
echo " Fix: sudo apt install nvidia-driver-535 && sudo reboot"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
else
echo " [OK] Graphics: non-NVIDIA GPU (no action needed)"
fi
# --- Joystick ---
shopt -s nullglob
JS_DEVICES=(/dev/input/js*)
shopt -u nullglob
if [[ ${#JS_DEVICES[@]} -gt 0 ]]; then
JS_NUM="${JS_DEVICES[0]##*/}"
JS_NAME="unknown"
if [[ -f "/sys/class/input/${JS_NUM}/device/name" ]]; then
JS_NAME=$(cat "/sys/class/input/${JS_NUM}/device/name")
fi
echo " [OK] Joystick: $JS_NAME"
else
echo " [WARN] Joystick: none detected — recommended for flight sims"
echo " Logitech Extreme 3D Pro is ideal"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
# --- Display resolution (primary monitor, not combined span) ---
CURRENT_RES=""
if command -v xrandr &>/dev/null; then
# Pick the highest-resolution connected monitor
CURRENT_RES=$(sudo -u "$REAL_USER" xrandr 2>/dev/null \
| grep -oP '\d+x\d+(?=\+)' \
| sort -t'x' -k1 -rn | head -1)
fi
if [[ -z "$CURRENT_RES" ]]; then
CURRENT_RES=$(sudo -u "$REAL_USER" xdpyinfo 2>/dev/null | grep -oP 'dimensions:\s+\K[0-9]+x[0-9]+' | head -1)
fi
if [[ -n "$CURRENT_RES" ]]; then
RES_W="${CURRENT_RES%x*}"
RES_H="${CURRENT_RES#*x}"
if (( RES_W >= 1920 && RES_H >= 1080 )); then
echo " [OK] Display: ${CURRENT_RES}"
else
echo " [WARN] Display: ${CURRENT_RES} — 1920x1080 or greater recommended"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
else
echo " [WARN] Display: could not detect resolution — 1920x1080 or greater recommended"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
# --- GPU memory ---
VRAM_MB=""
if command -v nvidia-smi &>/dev/null; then
VRAM_MB=$(nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits 2>/dev/null | head -1)
fi
if [[ -z "$VRAM_MB" ]] && [[ -d /sys/class/drm ]]; then
for card in /sys/class/drm/card[0-9]*/device; do
mem_file="$card/mem_info_vram_total"
if [[ -f "$mem_file" ]]; then
VRAM_BYTES=$(cat "$mem_file" 2>/dev/null)
if [[ -n "$VRAM_BYTES" && "$VRAM_BYTES" -gt 0 ]] 2>/dev/null; then
VRAM_MB=$(( VRAM_BYTES / 1048576 ))
break
fi
fi
done
fi
if [[ -z "$VRAM_MB" ]] && command -v glxinfo &>/dev/null; then
VRAM_LINE=$(sudo -u "$REAL_USER" glxinfo 2>/dev/null | grep -iP '(video memory|dedicated video|vram)' | grep -oP '[0-9]+' | head -1)
if [[ -n "$VRAM_LINE" && "$VRAM_LINE" -gt 0 ]] 2>/dev/null; then
VRAM_MB="$VRAM_LINE"
fi
fi
if [[ -n "$VRAM_MB" ]]; then
if (( VRAM_MB >= 1024 )); then
echo " [OK] GPU memory: ${VRAM_MB} MB"
else
echo " [WARN] GPU memory: ${VRAM_MB} MB — 1 GB or greater recommended"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
else
echo " [WARN] GPU memory: could not detect — 1 GB or greater recommended"
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
# --- sglBinaries_1.tar.gz ---
shopt -s nullglob
WP_DIRS=("$REPO_ROOT"/*/WP/ "$REPO_ROOT"/*/*/WP/)
shopt -u nullglob
shopt -s nullglob
SGL_BIN_DIRS=("$DOWNLOADS_DIR"/sglBinaries_*/)
shopt -u nullglob
if [[ -f "$DOWNLOADS_DIR/sglBinaries_1.tar.gz" ]]; then
echo " [OK] sglBinaries_1.tar.gz found in downloads/"
elif [[ -f "$DOWNLOADS_DIR/.extracted_sglBinaries_1.tar.gz" ]]; then
echo " [OK] sglBinaries_1.tar.gz (already extracted)"
elif [[ ${#SGL_BIN_DIRS[@]} -gt 0 ]]; then
echo " [OK] sglBinaries data found in downloads/ (${#SGL_BIN_DIRS[@]} dir(s))"
elif [[ ${#WP_DIRS[@]} -gt 0 ]]; then
echo " [OK] Binary game data already distributed"
else
echo " [WARN] sglBinaries_1.tar.gz not found in downloads/"
echo " Recommended — contains core binary games for all days."
AUDIT_WARNINGS=$((AUDIT_WARNINGS + 1))
fi
echo ""
if [[ $AUDIT_WARNINGS -gt 0 ]]; then
read -rp "Warnings found. Continue? (y/N) " answer
if [[ ! "$answer" =~ ^[Yy]$ ]]; then
echo "Aborting."
exit 1
fi
echo ""
fi
# ============================================================
# PHASE 1: Distribute sglBinaries_* from downloads/ to game INSTALL/ dirs
# ============================================================
echo "PHASE 1: Distributing binary game archives..."
echo ""
mkdir -p "$DOWNLOADS_DIR"
chown "$REAL_USER:$REAL_USER" "$DOWNLOADS_DIR"
# Extract sglBinaries_*.tar.gz archives before distributing
for f in "$DOWNLOADS_DIR"/sglBinaries_*.tar.gz; do
[[ -f "$f" ]] || continue
base="$(basename "$f")"
marker="$DOWNLOADS_DIR/.extracted_${base}"
if [[ -f "$marker" ]]; then
echo " Already extracted: $base"
else
echo " Extracting $base ..."
sudo -u "$REAL_USER" tar xzf "$f" -C "$DOWNLOADS_DIR/"
sudo -u "$REAL_USER" touch "$marker"
echo " [OK] Extracted: $base"
fi
done
# Distribute binary files from downloads/sglBinaries_* to game INSTALL directories
echo " Distributing binary files to game INSTALL directories..."
sudo -u "$REAL_USER" "$REPO_ROOT/scripts/distribute_binaries.sh"
echo ""
# ============================================================
# PHASE 2: Install system dependencies
# ============================================================
echo "PHASE 2: Installing system dependencies..."
echo ""
"$REPO_ROOT/scripts/install_dependencies.sh" --yes
echo ""
# ============================================================
# PHASE 3: Install FlightGear (as real user, not root)
# ============================================================
echo "PHASE 3: Installing FlightGear..."
echo ""
FG_VERSION="2024.1.4"
FG_DIR="$REAL_HOME/.local/share/flightgear"
FG_BIN="$FG_DIR/bin"
APPIMAGE_NAME="fgfs-${FG_VERSION}.AppImage"
APPIMAGE_PATH="$FG_DIR/$APPIMAGE_NAME"
DOWNLOAD_URL="https://download.flightgear.org/release-2024.1/flightgear-${FG_VERSION}-linux-amd64.AppImage"
if [[ -f "$APPIMAGE_PATH" ]]; then
echo " FlightGear $FG_VERSION already installed."
else
sudo -u "$REAL_USER" mkdir -p "$FG_DIR" "$FG_BIN"
echo " Downloading FlightGear $FG_VERSION AppImage..."
if sudo -u "$REAL_USER" curl -fSL --progress-bar -o "$APPIMAGE_PATH" "$DOWNLOAD_URL"; then
chmod +x "$APPIMAGE_PATH"
cat > "$FG_BIN/fgfs" << EOF
#!/bin/bash
exec "$APPIMAGE_PATH" "\$@"
EOF
chmod +x "$FG_BIN/fgfs"
chown "$REAL_USER:$REAL_USER" "$FG_BIN/fgfs"
echo " FlightGear $FG_VERSION installed."
else
echo " WARNING: FlightGear download failed. Install manually later:"
echo " ./scripts/setup_flightgear.sh"
rm -f "$APPIMAGE_PATH"
fi
fi
echo ""
# ============================================================
# Check if any binary games were distributed (WP directories exist)
# ============================================================
shopt -s nullglob
_WP_DIRS=("$REPO_ROOT"/*/WP/ "$REPO_ROOT"/*/*/WP/)
shopt -u nullglob
HAS_BINARY_GAMES=${#_WP_DIRS[@]}
# ============================================================
# PHASE 4: Download Lutris wine runners (as real user)
# ============================================================
echo "PHASE 4: Setting up Lutris wine runners..."
echo ""
if [[ $HAS_BINARY_GAMES -eq 0 ]]; then
echo " No binary games installed; skipping wine runner setup."
else
CSV_FILE="$REPO_ROOT/config/wine_runners.csv"
RUNNERS_DIR="$REAL_HOME/.local/share/lutris/runners/wine"
if [[ -f "$CSV_FILE" ]]; then
sudo -u "$REAL_USER" mkdir -p "$RUNNERS_DIR"
# Extract unique runners from CSV (skip header, column 2)
mapfile -t RUNNERS < <(tail -n +2 "$CSV_FILE" | cut -d',' -f2 | sort -u)
for runner in "${RUNNERS[@]}"; do
if [[ -d "$RUNNERS_DIR/$runner" ]]; then
echo " [OK] $runner"
continue
fi
# Build download URL
asset="wine-${runner}.tar.xz"
base_runner="$runner"
base_runner="${base_runner%-x86_64}"
base_runner="${base_runner%-i686}"
if [[ "$runner" == *GE-Proton* ]]; then
tag="${base_runner#lutris-}"
url="https://github.com/GloriousEggroll/wine-ge-custom/releases/download/${tag}/${asset}"
elif [[ "$runner" == *fshack* ]]; then
tag="${base_runner//-fshack/}"
url="https://github.com/lutris/wine/releases/download/${tag}/${asset}"
else
tag="$base_runner"
url="https://github.com/lutris/wine/releases/download/${tag}/${asset}"
fi
echo " [DOWNLOAD] $runner ..."
tmpfile="$(sudo -u "$REAL_USER" mktemp /tmp/runner-XXXXXX.tar.xz)"
if sudo -u "$REAL_USER" curl -fSL --progress-bar -o "$tmpfile" "$url"; then
sudo -u "$REAL_USER" tar -xJf "$tmpfile" -C "$RUNNERS_DIR/"
rm -f "$tmpfile"
if [[ -d "$RUNNERS_DIR/$runner" ]]; then
echo " [OK] $runner installed"
else
echo " [WARN] $runner: extracted but directory name mismatch"
fi
else
echo " [WARN] Failed to download $runner"
rm -f "$tmpfile"
fi
done
else
echo " No wine_runners.csv found; skipping."
fi
fi
echo ""
# ============================================================
# PHASE 5: Apply Rowan game Wine fixes (if games are present)
# ============================================================
echo "PHASE 5: Applying Wine fixes for Rowan games..."
echo ""
if [[ -d "$REPO_ROOT/TUE/MigAlley/WP" ]] && [[ -d "$REPO_ROOT/TUE/BattleOfBritain/WP" ]]; then
sudo -u "$REAL_USER" "$REPO_ROOT/scripts/fix_rowan_games.sh" all || true
else
echo " Rowan games not yet installed; skipping."
fi
echo ""
echo ""
echo "=============================================="
echo " Installation complete!"
echo ""
echo " To launch the game menu:"
echo " ./launcher/main_launcher.sh"
echo ""
echo " To add more binary game archives:"
echo " Place sglBinaries_* dirs in downloads/ and re-run sudo ./install.sh"
echo "=============================================="