@@ -100,35 +100,58 @@ export function generateInstallScript(
100100 const safeSlug = sanitizeShellArg ( slug ) ;
101101
102102 return `#!/bin/bash
103- set -e
103+ set -euo pipefail
104+
105+ TAP_NAME="openbootdotdev/tap"
104106
105107main() {
106108# When run via "curl | bash", stdin is the script content, not the terminal.
107- # Reopen stdin from /dev/tty so interactive prompts (sudo, Homebrew) work.
108- if [ ! -t 0 ] && [ -e /dev/tty ]; then
109+ # Reopen stdin from /dev/tty so interactive prompts (read, sudo, Homebrew) work.
110+ if [[ ! -t 0 ]] && [[ -e /dev/tty ] ]; then
109111 exec < /dev/tty || true
110112fi
111113
112- echo "========================================"
113- echo " OpenBoot - Custom Install"
114+ echo ""
115+ echo "OpenBoot Installer"
116+ echo "=================="
114117echo " Config: @${ safeUsername } /${ safeSlug } "
115- echo "========================================"
116118echo ""
117119
118- TMPDIR="\${TMPDIR:-/tmp}"
119- OPENBOOT_BIN="\$TMPDIR/openboot-\$\$"
120+ detect_os() {
121+ local os
122+ os=\$(uname -s | tr '[:upper:]' '[:lower:]')
123+ case "\$os" in
124+ darwin) echo "darwin" ;;
125+ *) echo "Error: OpenBoot only supports macOS" >&2; exit 1 ;;
126+ esac
127+ }
120128
121- trap 'rm -f "\$OPENBOOT_BIN"' EXIT
129+ detect_arch() {
130+ local arch
131+ arch=\$(uname -m)
132+ case "\$arch" in
133+ x86_64) echo "amd64" ;;
134+ arm64) echo "arm64" ;;
135+ aarch64) echo "arm64" ;;
136+ *) echo "unsupported: \$arch" >&2; exit 1 ;;
137+ esac
138+ }
122139
123140install_xcode_clt() {
124141 if xcode-select -p &>/dev/null; then
125142 return 0
126143 fi
127- echo "Installing Xcode Command Line Tools..."
128- echo "(A dialog may appear - please click 'Install')"
144+
145+ echo ""
146+ echo "Xcode Command Line Tools need to be installed."
147+ echo "A dialog will appear - please click 'Install' and enter your password."
148+ echo ""
149+ read -p "Press Enter to launch installer..." -r
129150 echo ""
151+
130152 xcode-select --install 2>/dev/null || true
131- echo "Waiting for Xcode Command Line Tools installation..."
153+
154+ echo "Waiting for installation to complete..."
132155 until xcode-select -p &>/dev/null; do
133156 sleep 5
134157 done
@@ -140,36 +163,80 @@ install_homebrew() {
140163 if command -v brew &>/dev/null; then
141164 return 0
142165 fi
166+
143167 echo "Installing Homebrew..."
144168 echo ""
145- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
146- if [ "$(uname -m)" = "arm64" ]; then
147- eval "$(/opt/homebrew/bin/brew shellenv)"
148- else
149- eval "$(/usr/local/bin/brew shellenv)"
150- fi
169+
170+ /bin/bash -c "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
171+
172+ local arch
173+ arch=\$(uname -m)
174+ case "\$arch" in
175+ arm64)
176+ if [[ -x "/opt/homebrew/bin/brew" ]]; then
177+ export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:\$PATH"
178+ export HOMEBREW_PREFIX="/opt/homebrew"
179+ export HOMEBREW_CELLAR="/opt/homebrew/Cellar"
180+ export HOMEBREW_REPOSITORY="/opt/homebrew"
181+ fi
182+ ;;
183+ x86_64)
184+ if [[ -x "/usr/local/bin/brew" ]]; then
185+ export PATH="/usr/local/bin:/usr/local/sbin:\$PATH"
186+ export HOMEBREW_PREFIX="/usr/local"
187+ export HOMEBREW_CELLAR="/usr/local/Cellar"
188+ export HOMEBREW_REPOSITORY="/usr/local/Homebrew"
189+ fi
190+ ;;
191+ *)
192+ echo "Error: Unsupported architecture: \$arch" >&2
193+ exit 1
194+ ;;
195+ esac
196+
197+ echo ""
151198 echo "Homebrew installed!"
152199 echo ""
153200}
154201
202+ local os arch
203+ os=\$(detect_os)
204+ arch=\$(detect_arch)
205+
206+ echo "Detected: \${os}/\${arch}"
207+ echo ""
208+
155209install_xcode_clt
156210install_homebrew
157211
158- ARCH="$(uname -m)"
159- if [ "$ARCH" = "arm64" ]; then
160- ARCH="arm64"
212+ if brew list openboot &>/dev/null 2>&1; then
213+ echo "OpenBoot is already installed via Homebrew."
214+ echo ""
215+ read -p "Reinstall? (y/N) " -n 1 -r
216+ echo
217+
218+ if [[ \$REPLY =~ ^[Yy]\$ ]]; then
219+ echo "Reinstalling OpenBoot..."
220+ brew reinstall \${TAP_NAME}/openboot
221+ echo ""
222+ echo "OpenBoot reinstalled!"
223+ else
224+ echo "Using existing installation."
225+ fi
161226else
162- ARCH="amd64 "
163- fi
227+ echo "Installing OpenBoot via Homebrew... "
228+ echo ""
164229
165- OPENBOOT_URL="https://github.com/openbootdotdev/openboot/releases/latest/download/openboot-darwin- \${ARCH}"
230+ brew install \${TAP_NAME}/openboot
166231
167- echo "Downloading OpenBoot... "
168- curl -fsSL "\$OPENBOOT_URL" -o "\$OPENBOOT_BIN "
169- chmod +x "\$OPENBOOT_BIN"
232+ echo ""
233+ echo "OpenBoot installed! "
234+ fi
170235
171- echo "Using remote config: @${ safeUsername } /${ safeSlug } "
172- "\$OPENBOOT_BIN" --user "${ safeUsername } /${ safeSlug } " "\$@"
236+ echo ""
237+ echo "Starting OpenBoot setup with config: @${ safeUsername } /${ safeSlug } "
238+ echo ""
239+ openboot --user "${ safeUsername } /${ safeSlug } " "\$@"
173240
174241${
175242 customScript
0 commit comments