-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·109 lines (95 loc) · 3.26 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·109 lines (95 loc) · 3.26 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
#!/usr/bin/env bash
# setup.sh — Entry point for dev-setup on Linux/macOS/WSL
#
# This script detects the operating system and routes to the correct
# platform-specific installer. It does NOT install any tools itself.
#
# Usage:
# bash setup.sh
# ./setup.sh (after: chmod +x setup.sh)
#
# Supported platforms:
# linux — native Linux
# wsl — Windows Subsystem for Linux (routed as Linux)
# macos — macOS (Darwin)
# windows-compat — Cygwin/MSYS2/Git Bash (limited support, use setup.ps1)
set -euo pipefail
exec 2>&1 # Merge stderr into stdout for ordered output in piped/Devcontainer environments
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
. "${SCRIPT_DIR}/scripts/linux/lib/log.sh"
# ── OS Detection ─────────────────────────────────────────────────────────────
detect_os() {
local os
os="$(uname -s)"
case "$os" in
Linux*)
# Check for WSL — /proc/version contains "microsoft" in WSL1 and WSL2
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
else
echo "linux"
fi
;;
Darwin*)
echo "macos"
;;
CYGWIN*|MINGW*|MSYS*)
# Running in a Unix emulation layer on Windows (Git Bash, MSYS2, Cygwin)
# setup.ps1 is the correct entry point; this path is a fallback warning only
echo "windows-compat"
;;
*)
echo "unknown"
;;
esac
}
# ── Routing ──────────────────────────────────────────────────────────────────
main() {
local detected_os
detected_os="$(detect_os)"
log_info "dev-setup — entry point"
log_info "Detected OS: ${detected_os}"
case "$detected_os" in
linux)
log_ok "Platform: Linux"
run_linux_setup
;;
wsl)
log_ok "Platform: WSL (running Linux scripts)"
run_linux_setup
;;
macos)
log_ok "Platform: macOS"
run_linux_setup
;;
windows-compat)
log_warn "Detected a Windows compatibility layer (Cygwin/MSYS2/Git Bash)."
log_warn "For native Windows, run setup.ps1 in PowerShell instead:"
log_warn " powershell -ExecutionPolicy Bypass -File setup.ps1"
log_warn "Attempting Linux-compatible path — some steps may fail."
run_linux_setup
;;
unknown)
log_error "Unrecognised operating system: $(uname -s)"
log_error "Supported platforms: Linux, macOS, WSL"
log_error "For Windows, use: powershell -ExecutionPolicy Bypass -File setup.ps1"
exit 1
;;
esac
}
run_linux_setup() {
local linux_script="${SCRIPT_DIR}/scripts/linux/setup.sh"
if [[ ! -f "$linux_script" ]]; then
log_error "Platform script not found: ${linux_script}"
log_error "The repository may be incomplete. Please re-clone and try again."
exit 1
fi
if [[ ! -x "$linux_script" ]]; then
log_warn "${linux_script} is not executable — fixing with chmod +x"
chmod +x "$linux_script"
fi
log_info "Handing off to: scripts/linux/setup.sh"
exec bash "$linux_script"
}
main "$@"