-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit
More file actions
executable file
·78 lines (66 loc) · 3.02 KB
/
Copy pathinit
File metadata and controls
executable file
·78 lines (66 loc) · 3.02 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
#!/usr/bin/env bash
# Developer Environment Bootstrapper
# This script resolves the chicken-and-egg bootstrapping issue on brand-new computers.
# It installs Homebrew, retrieves your credentials from 1Password, logins to GitHub CLI,
# clones your private devenv repo, and executes the main installer.
#
# Usage:
# 1. Open macOS Terminal (not Kitty).
# 2. Copy and run the curl command from the README to start this script.
set -e
echo "=========================================================="
echo " New Machine Dev Environment Setup"
echo "=========================================================="
# 1. Install Xcode Command Line Tools if not already installed
if ! xcode-select -p >/dev/null 2>&1; then
echo -e "\nInstalling Xcode Command Line Tools..."
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
if [[ -n "$PROD" ]]; then
sudo softwareupdate -i "$PROD" --verbose
fi
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
fi
# 2. Install Homebrew if not already installed
if ! command -v brew >/dev/null 2>&1; then
echo -e "\n[1/5] Installing Homebrew..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Load Homebrew environment into the current shell
if [[ -f "/opt/homebrew/bin/brew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -f "/usr/local/bin/brew" ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
else
echo -e "\n[1/5] Homebrew is already installed."
fi
# 2. Install 1Password and GitHub CLIs
echo -e "\n[2/5] Installing 1Password CLI and GitHub CLI via Homebrew..."
brew install 1password-cli gh
# 3. Authenticate 1Password
echo -e "\n[3/5] Setting up 1Password CLI..."
echo "Please sign in to your 1Password account."
op account add --address my.1password.com --email danpshumaker@gmail.com --signin
# Prompt user to perform initial sign-in so we can read tokens
echo "Signing in to 1Password to authorize token retrieval..."
eval $(op signin)
# 4. Authenticate GitHub CLI via 1Password Token
echo -e "\n[4/5] Retrieving GitHub Access Token and authenticating GitHub CLI..."
op read "op://Shumaker-Shared/github.com/GH_TOKEN" | gh auth login -p https --with-token
# Verify GitHub CLI is authenticated before proceeding
if ! gh auth status; then
echo "Error: GitHub CLI authentication failed! Cannot proceed to cloning." >&2
exit 1
fi
# 5. Clone and Launch devenv UI
echo -e "\n[5/5] Cloning private devenv repository..."
if [[ ! -d "devenv" ]]; then
gh repo clone danshumaker/devenv
# GH_TOKEN=$(op read "op://Shumaker-Shared/github.com/GH_TOKEN")
# git clone https://x-access-token:${GH_TOKEN}@github.com/danshumaker/homebrew-devenv.git
fi
echo -e "\n=========================================================="
echo " Bootstrapping Complete! Handing over to Devenv Install..."
echo "=========================================================="
cd devenv
./install